Skip to content
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

ENH: raise early exception if 0d array is used in np.cross #24098

Merged
merged 10 commits into from
Jul 5, 2023

Conversation

DhavalParmar61
Copy link
Contributor

No description provided.

@mattip
Copy link
Member

mattip commented Jul 2, 2023

Fixes #24079

@mattip mattip changed the title Resolve issue #24079 ENH: raise early exception if 0d array is used in np.cross Jul 2, 2023
@@ -1581,6 +1581,10 @@ def cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None):
axisa, axisb, axisc = (axis,) * 3
a = asarray(a)
b = asarray(b)

if (a.ndim < 1) or (b.ndim < 1):
raise Exception("At least one array has zero dimension")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to catch a ValueError, you need to use ValueError as an exception. Also, there is still a grammar error in the message.

Suggested change
raise Exception("At least one array has zero dimension")
raise ValueError("At least one array has zero dimensions")

@DhavalParmar61
Copy link
Contributor Author

@mattip Made necessary changes.

@mattip mattip merged commit 67c862a into numpy:main Jul 5, 2023
59 checks passed
@mattip
Copy link
Member

mattip commented Jul 5, 2023

Thanks @DhavalParmar61

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jul 6, 2023
@charris
Copy link
Member

charris commented Jul 6, 2023

Lesson from this: don't merge main for something that might be backported :) Or if you do, squash commit the result.

Looks like this should not be backported.

@charris charris added 01 - Enhancement and removed 09 - Backport-Candidate PRs tagged should be backported labels Jul 6, 2023
@mattip
Copy link
Member

mattip commented Jul 6, 2023

Sorry, I didn't consider the implications of merging this vis-a-vis backporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants