-
Notifications
You must be signed in to change notification settings - Fork 52
Fix optional keyword argument in take
signature
#644
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
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
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. |
And the test suite. I'm pretty sure |
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 too, in it goes. Thanks @kgryte and @asmeurer.
There's already data-apis/array-api-compat#34 for the follow-up action.
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
I made a fix for numpy.array_api at numpy/numpy#24187 |
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
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
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 PR:
take
in which the default value for theaxis
keyword argument should beNone
. Without this change, theaxis
keyword 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