8000 API: deprecate size-2 inputs for `np.cross` [Array API] by mtsokol · Pull Request #24818 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

API: deprecate size-2 inputs for np.cross [Array API] #24818

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

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

mtsokol
Copy link
Member
@mtsokol mtsokol commented Sep 27, 2023

Hi @rgommers,

As NEP 52 comes closer to the end I decided to start a warmup for the next milestone. IIRC you mentioned I could potentially focus on "Array API support in NumPy" workstream.

From our conversation in July I noted such introductory tasks:

making `cross` avoid size-2 inputs (deprecating that first), 
adding a new `svdvals` function, 
adding `np.linalg.trace` or `np.linalg.diagonal`.

Some questions:

This small PR adds a deprecation to np.cross for 2-size input.

@rgommers
Copy link
Member

Hey Mateusz, good idea to get started on this topic.

but you meant adding these methods to np.linalg directly, right?

Indeed. We want the numpy namespace, and the numpy.fft and numpy.linalg ones, to be compatible with what's in the standard. The numpy.array_api is a much more strict and limited implementation that is primarily useful for testing compliance with the standard and not assuming any "extra" behavior or syntax.

For a reference I'm looking at:

Yep, that's a good place to start. The other place to look at is https://numpy.org/devdocs/reference/array_api.html#table-of-differences-between-numpy-array-api-and-numpy; the "compatible" and "breaking" entries there are the things to add/change.

@mtsokol mtsokol force-pushed the array-api-support-warmup branch from d5b5cda to 8664533 Compare September 27, 2023 10:40
@mtsokol mtsokol changed the title DOC: deprecate size-2 inputs for np.cross DOC: deprecate size-2 inputs for np.cross [Array API] Oct 17, 2023
@mtsokol mtsokol force-pushed the array-api-support-warmup branch from 8664533 to f2f9e8c Compare October 20, 2023 14:35
# Deprecated in NumPy 2.0, 2023-09-26
warnings.warn(
"2-dimensional input arrays are deprecated. Use 3-dimensional "
"instead. (deprecated in NumPy 2.0)",
Copy link
Member
@ngoldbaum ngoldbaum Oct 25, 2023

Choose a reason for hiding this comment

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

This is a little confusing, since n-dimensional stacks of vectors are fine, the only thing that matters is if the final dimension is 2. Maybe rephrase this to talk about arrays of 2D and 3D vectors instead of just 2D or 3D arrays?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure - I changed warning to:

"Arrays of 2-dimensional vectors are deprecated. Use arrays of "
"3-dimensional vectors instead. (deprecated in NumPy 2.0)"

@mtsokol mtsokol force-pushed the array-api-support-warmup branch 2 times, most recently from 7f6fc45 to 3f5dee9 Compare October 25, 2023 20:39
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
@mtsokol mtsokol force-pushed the array-api-support-warmup branch from 3f5dee9 to ea42abc Compare October 25, 2023 20:41
@mtsokol mtsokol changed the title DOC: deprecate size-2 inputs for np.cross [Array API] API: deprecate size-2 inputs for np.cross [Array API] Oct 25, 2023
@ngoldbaum
Copy link
Member

Thanks @mtsokol!

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.

3 participants
0