Skip to content

Commit 16c292c

Browse files
Use numpy.random.seed in test_linalg
1 parent a198de0 commit 16c292c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/test_linalg.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,10 @@ class TestQr:
703703
ids=["r", "raw", "complete", "reduced"],
704704
)
705705
def test_qr(self, dtype, shape, mode):
706-
a = numpy.random.rand(*shape).astype(dtype)
706+
numpy.random.seed(76)
707+
a = numpy.random.randn(*shape).astype(dtype)
708+
if numpy.issubdtype(dtype, numpy.complexfloating):
709+
a += 1j * numpy.random.randn(*shape)
707710
ia = inp.array(a)
708711

709712
if mode == "r":
@@ -773,7 +776,8 @@ def test_qr_empty(self, dtype, shape, mode):
773776
ids=["r", "raw", "complete", "reduced"],
774777
)
775778
def test_qr_strides(self, mode):
776-
a = numpy.random.rand(5, 5)
779+
numpy.random.seed(76)
780+
a = numpy.random.randn(5, 5)
777781
ia = inp.array(a)
778782

779783
# positive strides
@@ -1130,6 +1134,7 @@ def test_svd(self, dtype, shape):
11301134
ids=["(2, 2)", "(16, 16)"],
11311135
)
11321136
def test_svd_hermitian(self, dtype, compute_vt, shape):
1137+
numpy.random.seed(76)
11331138
a = numpy.random.randn(*shape).astype(dtype)
11341139
if numpy.issubdtype(dtype, numpy.complexfloating):
11351140
a += 1j * numpy.random.randn(*shape)
@@ -1207,7 +1212,10 @@ def check_types_shapes(self, dp_B, np_B):
12071212
],
12081213
)
12091214
def test_pinv(self, dtype, shape):
1210-
a = numpy.random.rand(*shape).astype(dtype)
1215+
numpy.random.seed(76)
1216+
a = numpy.random.randn(*shape).astype(dtype)
1217+
if numpy.issubdtype(dtype, numpy.complexfloating):
1218+
a += 1j * numpy.random.randn(*shape)
12111219
a_dp = inp.array(a)
12121220

12131221
B = numpy.linalg.pinv(a)
@@ -1232,6 +1240,7 @@ def test_pinv(self, dtype, shape):
12321240
ids=["(2, 2)", "(16, 16)"],
12331241
)
12341242
def test_pinv_hermitian(self, dtype, shape):
1243+
numpy.random.seed(76)
12351244
a = numpy.random.randn(*shape).astype(dtype)
12361245
if numpy.issubdtype(dtype, numpy.complexfloating):
12371246
a += 1j * numpy.random.randn(*shape)
@@ -1272,7 +1281,8 @@ def test_pinv_empty(self, dtype, shape):
12721281
assert_dtype_allclose(B_dp, B)
12731282

12741283
def test_pinv_strides(self):
1275-
a = numpy.random.rand(5, 5)
1284+
numpy.random.seed(76)
1285+
a = numpy.random.randn(5, 5)
12761286
a_dp = inp.array(a)
12771287

12781288
self.get_tol(a_dp.dtype)

0 commit comments

Comments
 (0)