Skip to content

Commit

Permalink
feat(geometry): no longer support nx3 sequence in Transform3D.__mul__()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-000 committed Mar 25, 2021
1 parent 579230a commit 26f6818
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tensorbay/geometry/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def test_eq(self):
assert (transform_1 == transform_3) == False

def test_mul(self):
sequence = [1, 1, 1]
sequence_1 = [1, 1, 1]
sequence_2 = [[1, 2, 3], [4, 5, 6]]
quaternion_1 = quaternion(0, 1, 0, 0)
transform_1 = Transform3D(translation=[1, 2, 3], rotation=[0, 1, 0, 0])
transform_2 = Transform3D(translation=[2, 0, 0], rotation=[-1, 0, 0, 0])
Expand All @@ -61,7 +62,9 @@ def test_mul(self):
transform_1 * 1
assert transform_1 * transform_1 == transform_2
assert transform_1 * quaternion_1 == transform_3
assert transform_1 * sequence == Vector3D(2.0, 1.0, 2.0)
assert transform_1 * sequence_1 == Vector3D(2.0, 1.0, 2.0)
with pytest.raises(TypeError):
transform_1 * sequence_2

def test_rmul(self):
quaternion_1 = quaternion(0, 1, 0, 0)
Expand Down
3 changes: 1 addition & 2 deletions tensorbay/geometry/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def __mul__(self: _T, other: Sequence[float]) -> Vector3D:

def __mul__(self: _T, other: Union[_T, Sequence[float]]) -> Union[_T, Vector3D]:
if isinstance(other, Sequence): # pylint: disable=W1116
result: Vector3D = self._translation + rotate_vectors(self._rotation, other)
return result
return self._translation.__radd__(rotate_vectors(self._rotation, other))

# mypy does not recognize quaternion type, and will infer it as Any.
# This typing problem to be resolved.
Expand Down

0 comments on commit 26f6818

Please sign in to comment.