Fix optional keyword argument in take signature#644
Merged
rgommers merged 2 commits intodata-apis:mainfrom Jul 10, 2023
Merged
Conversation
This commit fixes the function signature for `take`. Namely, when an input array is one-dimensional, the `axis` kwarg is optional; when the array has more than one dimension, the `axis` kwarg is required. Unfortunately, the type signature cannot encode this duality, and we must rely on the specification text to clarify that the `axis` kwarg is required for arrays having ranks greater than unity. Ref: data-apis/array-api-compat#34
Member
|
Looks good. I'm OK with backporting this because it makes the signature match what the text of the specification already said. We will also need to update the compat library and numpy.array_api. |
Member
|
And the test suite. I'm pretty sure |
rgommers
approved these changes
Jul 10, 2023
Member
rgommers
left a comment
There was a problem hiding this comment.
LGTM too, in it goes. Thanks @kgryte and @asmeurer.
There's already data-apis/array-api-compat#34 for the follow-up action.
asmeurer
added a commit
to asmeurer/numpy
that referenced
this pull request
Jul 15, 2023
The array_api take() doesn't flatten the array by default, so the axis argument must be provided for multidimensional arrays. However, it should be optional when the input array is 1-D, which the signature previously did not allow. c.f. data-apis/array-api#644
Member
|
I made a fix for numpy.array_api at numpy/numpy#24187 |
charris
pushed a commit
to charris/numpy
that referenced
this pull request
Jul 23, 2023
The array_api take() doesn't flatten the array by default, so the axis argument must be provided for multidimensional arrays. However, it should be optional when the input array is 1-D, which the signature previously did not allow. c.f. data-apis/array-api#644
asmeurer
added a commit
to data-apis/array-api-strict
that referenced
this pull request
Jan 22, 2024
The array_api take() doesn't flatten the array by default, so the axis argument must be provided for multidimensional arrays. However, it should be optional when the input array is 1-D, which the signature previously did not allow. c.f. data-apis/array-api#644 Original NumPy Commit: 37ba69c7b7404e4ae67ef2e4db9584852baa963a
asmeurer
added a commit
to data-apis/array-api-strict
that referenced
this pull request
Jan 22, 2024
The array_api take() doesn't flatten the array by default, so the axis argument must be provided for multidimensional arrays. However, it should be optional when the input array is 1-D, which the signature previously did not allow. c.f. data-apis/array-api#644 Original NumPy Commit: 37ba69c7b7404e4ae67ef2e4db9584852baa963a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR:
takein which the default value for theaxiskeyword argument should beNone. Without this change, theaxiskeyword argument is always required (as arguments must always be bound to a value), even for the one-dimensional case. This PR corrects this error in the original PR.Ref: data-apis/array-api-compat#34