-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
BUG: Adds asanyarray to start of linalg.cross #26667
Conversation
Currently linalg.cross fails when given two 3D lists. This adds `asanyarray` at the start of the code, mimicing the other Array API compatible additions. This was discussed in PR numpy#26640, with a bug fix requested.
The function linalg.cross has a current bug. With the current development version, we get
It's missing an After either change is made, we get:
I also addded a test to check that lists are converted properly to arrays. There is another issue happening, namely an IndexError can still occur, rather than an AxisError. Compare the behavoir of
I'm not sure if we want to call this a bug, or a feature, that different error messages are thrown. I had to deal with this while creating I can addreses the inconsistency of error messages in this PR, or a separate, or just call it a feature. Either way, a user is being told they have an indexing issue, though I think the AxisError message is more informative. |
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.
LGTM and seems to work as advertised now. Thanks @bmwoodruff!
It's missing an
asanyarray
orasarray
before asking for the shape. Which is preferrable?
It doesn't seem to matter either way. The code in _linalg.py
uses a mix, so it seems to not have a consistent design. The return type is an ndarray
in any case, subclasses don't get preserved.
The issue comes by not using
normalize_axes_index
inlinalg.cross
before trying to access theshape
. Fixing it would result in callingnormalize_axis_index
twice (as the check is done incross
).
Consistency would be nice, AxisError
seems better. It's less critical though, so let's do it in a separate PR after this one (can be backported, but not critical for 2.0.0, landing in 2.0.1 is fine). Calling normalize_axes_index
twice doesn't sound like the end of the world, it's cheap.
@charris this one would be nice to backport for 2.0.0 |
Currently linalg.cross fails when given two 3D lists. This adds `asanyarray` at the start of the code, mimicing the other Array API compatible additions. This was discussed in PR numpy#26640, with a bug fix requested.
BUG: Adds asanyarray to start of linalg.cross (#26667)
Currently linalg.cross fails when given two 3D lists. This adds `asanyarray` at the start of the code, mimicing the other Array API compatible additions. This was discussed in PR numpy#26640, with a bug fix requested.
Currently linalg.cross fails when given two 3D lists. This adds
asanyarray
at the start of the code,mimicking the other Array API compatible additions. This was discussed in PR #26640, with a bug fix requested.