Skip to content

Commit 262a54d

Browse files
committed
pybricks.geometry.Matrix: fix missing scale in subscr
1 parent 607075a commit 262a54d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

pybricks/geometry/pb_type_matrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ STATIC mp_obj_t pb_type_Matrix_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
473473
}
474474

475475
// Return result
476-
return mp_obj_new_float_from_f(self->data[idx]);
476+
return mp_obj_new_float_from_f(self->scale * self->data[idx]);
477477
}
478478
return MP_OBJ_NULL;
479479
}

tests/ev3dev/geometry/matrix.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
print("A * 3 =", A * 3)
2323
print("3 * A =", 3 * A)
2424

25+
# Reading elements
26+
print("B[0, 1] =", B[0, 1])
27+
print("B.T[0, 1] =", B.T[0, 1])
28+
2529
# Vector basics
2630
b = vector(3, 4, 0)
2731
c = b.T

tests/ev3dev/geometry/matrix.py.exp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ A * 3 = Matrix([
4444
[ 12.000, 15.000, 18.000],
4545
[ 21.000, 24.000, 27.000],
4646
])
47+
B[0, 1] = -2.0
48+
B.T[0, 1] = -4.0
4749
b = vector(3, 4, 0) = Matrix([
4850
[ 3.000],
4951
[ 4.000],

0 commit comments

Comments
 (0)