BUG: Allow integer inputs for pow-related functions in array_api#20762
Merged
charris merged 1 commit intonumpy:mainfrom Jan 12, 2022
Merged
BUG: Allow integer inputs for pow-related functions in array_api#20762charris merged 1 commit intonumpy:mainfrom
array_api#20762charris merged 1 commit intonumpy:mainfrom
Conversation
Updates `xp.power()`, `x.__pow__()`, `x.__ipow()__` and `x.__rpow()__`
Member
|
This may need typeing fixes. @BvB93 Thoughts? |
Member
Member
|
Thanks @honno . |
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.
Updates
xp.pow(),x.__pow__(),x.__ipow()__andx.__rpow()__to accept integer inputs. Partially resolves #20752. @asmeurer initially wrote these when the Array API spec said only float inputs were allowed, but it has since changed to accept all numeric dtypes.This PR notably only enables integer arrays to work with integer arrays, and not allow the mix of integer arrays with floating arrays, which is out-of-scope for the Array API (i.e. mixing non-promotable dtypes together). This is to keep with the
numpy.array_apiphilosophy of not implementing beyond the spec... and conveniently already covered nicely by the internal use ofresult_type().This is smoke tested via the
xptests/test_operators_and_elementwise_functions.py::test_powtest case(s) inarray-api-tests. Better testing would be ideal, but these pow-related functions are using NumPy proper's pow-related functions anywho.