-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
TST tests for non-canonical input to sparse matrix operations #3254
Conversation
if indptr is None: | ||
return (data,) + inds | ||
else: | ||
return (data,) + inds + 2 * indptr |
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.
This probably should read 2 * (indptr,)
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.
No, we're duplicating the data entries; 2*indptr
fixes the indptr to point correctly.
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.
And I'd created this helper function in part to work with LIL as well, until I realised (I suppose) that LIL's not meant to handle duplicates like COO and CSR.
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.
Then it probably should be (data,) + inds + (2 * indptr,)
?
indptr is an array and cannot be added to a tuple (check the Travis-CI output)
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.
Yes, that ;)
This test would indeed be useful to add. knownfailures can be added by overriding the corresponding functions in the Test*NonCanonical classes. |
Do we want this case to work? Or do you mean that we should test that every method throws an error (do we need to be validating that often?)? |
I was wondering whether len(indices) = len(data) = indptr[-1] should be taken as an invariant in the code or not. But maybe it's clearest to assume it's an invariant (doesn't need to be checked, except maybe in |
I think we can assume len(indices) == len(data) == indptr[-1] except where I'm pushing some known failures... On 31 January 2014 07:05, Pauli Virtanen notifications@github.com wrote:
|
That's a whole lot of failures, and some are truly broken (abs, add_sub, bool, minmax, sparse_format_conversions, unary_ufunc_overrides; in CSR/C: sparse boolean indexing, broadcast element-wise multiply, inverse, solve and getnnz_axis). I'll rebase on master and try the changes to min/max. |
It'll be nice to remove many of the known failures when #3233 is merged, but those cases largely throw an error at the moment, while other cases will silently return the wrong values, and at a minimum should have comments to note this fact. |
It turns out |
The remaining |
TST: sparse: tests for non-canonical input to sparse matrix operations A number of sparse matrix formats are designed to treat duplicate values as their sum; they prefer indices in sorted order, but should be capable when unsorted. The current test suite largely compares functionality to numpy arrays/matrices, and so constructs sparse matrices from those, producing only canonical sparse forms. These commits introduce tests for non-canonical forms.
Thanks, merged. |
A number of sparse matrix formats are designed to treat duplicate values as their sum; they prefer indices in sorted order, but should be capable when unsorted. The current test suite largely compares functionality to numpy arrays/matrices, and so constructs sparse matrices from those, producing only canonical sparse forms.
This introduces tests for non-canonical forms, but finds many test failures. I don't intend to fix them all here, but we can perhaps add known failure decorations.