Skip to content

BUG: Allow integer inputs for pow-related functions in array_api#20762

Merged
charris merged 1 commit intonumpy:mainfrom
honno:xp-pow-fixes
Jan 12, 2022
Merged

BUG: Allow integer inputs for pow-related functions in array_api#20762
charris merged 1 commit intonumpy:mainfrom
honno:xp-pow-fixes

Conversation

@honno
Copy link
Copy Markdown
Contributor

@honno honno commented Jan 7, 2022

Updates xp.pow(), x.__pow__(), x.__ipow()__ and x.__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_api philosophy of not implementing beyond the spec... and conveniently already covered nicely by the internal use of result_type().

This is smoke tested via the xptests/test_operators_and_elementwise_functions.py::test_pow test case(s) in array-api-tests. Better testing would be ideal, but these pow-related functions are using NumPy proper's pow-related functions anywho.

Updates `xp.power()`, `x.__pow__()`, `x.__ipow()__` and `x.__rpow()__`
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jan 11, 2022
@charris
Copy link
Copy Markdown
Member

charris commented Jan 11, 2022

This may need typeing fixes. @BvB93 Thoughts?

@BvB93
Copy link
Copy Markdown
Member

BvB93 commented Jan 11, 2022

This may need typeing fixes. @BvB93 Thoughts?

Looks like the necessary fixes are already included in e3406ed.

@charris charris merged commit f98c60a into numpy:main Jan 12, 2022
@charris
Copy link
Copy Markdown
Member

charris commented Jan 12, 2022

Thanks @honno .

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 12, 2022
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.

BUG: In numpy.array_api, divide and pow related functions/methods do not accept integer arrays

4 participants