Skip to content

Commit 1cbf71b

Browse files
ogriselthomasjpfan
andauthored
FIX seed test_large_sparse_matrix (scikit-learn#26672)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
1 parent f108e2a commit 1cbf71b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/linear_model/tests/test_logistic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,15 +1998,16 @@ def test_sample_weight_not_modified(multi_class, class_weight):
19981998

19991999

20002000
@pytest.mark.parametrize("solver", SOLVERS)
2001-
def test_large_sparse_matrix(solver):
2001+
def test_large_sparse_matrix(solver, global_random_seed):
20022002
# Solvers either accept large sparse matrices, or raise helpful error.
20032003
# Non-regression test for pull-request #21093.
20042004

20052005
# generate sparse matrix with int64 indices
2006-
X = sparse.rand(20, 10, format="csr")
2006+
X = sparse.rand(20, 10, format="csr", random_state=global_random_seed)
20072007
for attr in ["indices", "indptr"]:
20082008
setattr(X, attr, getattr(X, attr).astype("int64"))
2009-
y = np.random.randint(2, size=X.shape[0])
2009+
rng = np.random.RandomState(global_random_seed)
2010+
y = rng.randint(2, size=X.shape[0])
20102011

20112012
if solver in ["liblinear", "sag", "saga"]:
20122013
msg = "Only sparse matrices with 32-bit integer indices"

0 commit comments

Comments
 (0)