-
Notifications
You must be signed in to change notification settings - Fork 191
chore: add sparse index dtype checks to assert_equal #2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
420ea56
6cb2b35
eee48e6
fab9c47
5119b20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,21 @@ def test_assert_equal_dask_arrays(): | |
| assert_equal(c, d) | ||
|
|
||
|
|
||
| def test_assert_equal_sparse_index_dtype(): | ||
| """assert_equal(exact=True) should detect indptr/indices dtype mismatches.""" | ||
| a = sparse.random(10, 10, format="csr", density=0.3) | ||
| b = a.copy() | ||
| b.indptr = b.indptr.astype(np.int64) | ||
| b.indices = b.indices.astype(np.int64) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please parametrize this test to change each of these one-at-a-time and then have the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done — parametrized with |
||
|
|
||
| # Non-exact comparison should pass (values are identical) | ||
| assert_equal(a, b, exact=False) | ||
|
|
||
| # Exact comparison should catch the dtype mismatch | ||
| with pytest.raises(AssertionError, match="indptr dtype mismatch"): | ||
| assert_equal(a, b, exact=True) | ||
|
|
||
|
|
||
| def test_assert_equal_dask_sparse_arrays(): | ||
| import dask.array as da | ||
| from scipy import sparse | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the mismatch's contents are already reported by
assertThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done — simplified the assert messages and included
elem_namefor context. Updated in 6cb2b35.