-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
BUG: sparse: Validate explicit shape if given with dense argument to coo_matrix #9920
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
Conversation
@mattip another random PyPy failure, haven't seen this before:
does that need a bug report somewhere, or is it a flake? |
That would indeed break quite some code. There may be a couple of exceptions, but in general I think we can only use keyword-only arguments for new code. |
This was fixed in #9840. Rebase the pr off master. It is using an old pypy version. |
Ah right. The failure didn't look familiar and it was a fresh PR, so I didn't expect that. Sorry for the noise. What we need to do is fix CircleCI if we can, this is getting really annoying. It should test the merge commit, not the commit from the PR itself. EDIT: or better, move away from CircleCI, since we're using too many resources there anyway (gh-9111) |
I tracked down the relevant CircleCI issue and explained the problem again: https://circleci.com/ideas/?idea=CCI-I-926. There's a voting feature, if people want to push the vote button that may be useful. |
@perimosocordiae could you add the example from the issue as a regression test? |
b866ba4
to
3f4f3b9
Compare
With a motivating test case added.
3f4f3b9
to
eb58eaa
Compare
@rgommers Sure, tests added. I also rebased, so hopefully we'll see the pypy tests pass. |
All green, in it goes. Thanks @perimosocordiae |
It might be that this broke a test in pandas (a test constructing a sparse matrix started failing the last hours). The test basically does:
So using lists and not arrays to create a small dummy matrix. That worked before, but now started raising an error in It's only in the testing code, not in actual functionality, so not a big problem for pandas (and it is also easy to fix the testing code to use arrays). But, just wanted to signal this (not sure what guarantees scipy gives on coercing the input). |
Looking into it further, this is actually a wrong usage on our side, which was exactly the purpose of this PR to catch such shape mistakes ;-) We are passing the So ignore my message above. |
Glad to see the PR is already helping! 👍 |
Fixes gh-9919.
There are a couple routes we could take when validating the
shape
kwarg in this situation, but given the context of the original bug, it should be sufficient to raise an error whenever the given shape (intentional or not) doesn't match the shape of the dense matrix being converted (the first argument).Note that once scipy starts converting code to be explicitly py3k-only, we could consider marking the
shape
anddtype
arguments as keyword only. This would prevent these sorts of errors more broadly, though perhaps at the expense of breaking existing user code.