Skip to content

Commit eb1fccf

Browse files
author
Joao Felipe Rocha
committed
Error message is different from 3.8 and 3.10. Created a generic error message
1 parent ae2bf1c commit eb1fccf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_data.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,17 @@ def test_inverse_transform_sparse_svd():
385385
IndexError, "index 64 is out of bounds for axis 1 with size 64"
386386
):
387387
G.inverse_transform(G.data_nu, columns=data.shape[1])
388+
389+
# Flexible regex pattern that works across Python versions
390+
sparse_error_pattern = ".*sparse.*was passed, but dense data is required.*toarray.*to convert.*dense.*array.*"
388391
with assert_raises_message(
389392
TypeError,
390-
"Sparse data was passed, but dense data is required. Use '.toarray()' to convert to a dense numpy array.",
393+
sparse_error_pattern,
391394
):
392395
G.inverse_transform(sp.csr_matrix(G.data)[:, 0])
393396
with assert_raises_message(
394397
TypeError,
395-
"Sparse data was passed, but dense data is required. Use '.toarray()' to convert to a dense numpy array.",
398+
sparse_error_pattern,
396399
):
397400
G.inverse_transform(sp.csr_matrix(G.data)[:, :15])
398401
with assert_raises_message(

0 commit comments

Comments
 (0)