Skip to content

Commit c1696ed

Browse files
authored
TST Sets random state in test_csr_row_norms (#16509)
1 parent 78dc597 commit c1696ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sklearn/utils/tests/test_sparsefuncs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,11 @@ def test_inplace_normalize():
551551
def test_csr_row_norms(dtype):
552552
# checks that csr_row_norms returns the same output as
553553
# scipy.sparse.linalg.norm, and that the dype is the same as X.dtype.
554-
X = sp.random(100, 10, format='csr', dtype=dtype)
554+
X = sp.random(100, 10, format='csr', dtype=dtype, random_state=42)
555555

556556
scipy_norms = sp.linalg.norm(X, axis=1)**2
557557
norms = csr_row_norms(X)
558558

559559
assert norms.dtype == dtype
560-
assert_allclose(norms, scipy_norms)
560+
rtol = 1e-6 if dtype == np.float32 else 1e-7
561+
assert_allclose(norms, scipy_norms, rtol=rtol)

0 commit comments

Comments
 (0)