Skip to content

Commit 1f85d7d

Browse files
fix non-positive determinant error in tests/scipy_spatial_test.py::...::testRotationFromMatrix0 (#362)
Co-authored-by: Jake VanderPlas <[email protected]>
1 parent 5c681d8 commit 1f85d7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/scipy_spatial_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ def testRotationFromEuler(self, size, dtype, seq, degrees):
196196
)
197197
def testRotationFromMatrix(self, shape, dtype):
198198
rng = jtu.rand_default(self.rng())
199-
args_maker = lambda: (rng(shape, dtype),)
199+
def args_maker():
200+
# Use QR to ensure valid positive-definite rotation matrix.
201+
q, _ = onp.linalg.qr(rng(shape, dtype))
202+
return [q]
200203
jnp_fn = lambda m: jsp_Rotation.from_matrix(m).as_rotvec()
201204
np_fn = lambda m: osp_Rotation.from_matrix(m).as_rotvec().astype(dtype)
202205
self._CheckAgainstNumpy(np_fn, jnp_fn, args_maker, check_dtypes=True, tol=1e-4)

0 commit comments

Comments
 (0)