Skip to content

Commit c0c754a

Browse files
committed
test broadcasting abilities
1 parent 3c3324f commit c0c754a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: python/tests/test_Rotation.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ def test_broadcastcomposition(self,shape):
990990
(Rotation.from_axis_angle, np.array([1,0,0,4])),
991991
(Rotation.from_axis_angle, np.array([1,1,0,1])),
992992
(Rotation.from_matrix, np.random.rand(3,3)),
993+
(Rotation.from_matrix, np.array([[2,0,0],[0,2,0],[0,1,0]])),
993994
(Rotation.from_matrix, np.array([[1,1,0],[1,2,0],[0,0,1]])),
994995
(Rotation.from_Rodrigues_vector, np.array([1,0,0,-1])),
995996
(Rotation.from_Rodrigues_vector, np.array([1,1,0,1])),
@@ -1128,10 +1129,13 @@ def test_invariant(self):
11281129
R = Rotation.from_random()
11291130
assert (R/R).isclose(R*R**(-1)) and (R/R).isclose(Rotation())
11301131

1131-
@pytest.mark.parametrize('item',[np.ones(3),np.ones((3,3)), np.ones((3,3,3,3))])
1132-
def test_apply(self,item):
1133-
r = Rotation.from_random()
1134-
assert (r.apply(item) == r@item).all()
1132+
@pytest.mark.parametrize('shape',[None,2,(2,3),(2,2),(2,3,3,3)])
1133+
@pytest.mark.parametrize('item',[np.random.rand(3),np.random.rand(3,3), np.random.rand(3,3,3,3)])
1134+
def test_apply(self,item,shape):
1135+
r = Rotation.from_random(shape)
1136+
i = r*~r
1137+
applied = i.apply(item)
1138+
assert np.allclose(np.broadcast_to(item,applied.shape),applied)
11351139

11361140
@pytest.mark.parametrize('angle',[10,20,30,40,50,60,70,80,90,100,120])
11371141
def test_average(self,angle):

0 commit comments

Comments
 (0)