Skip to content

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

Merged
charris merged 1 commit intonumpy:maintenance/1.22.xfrom
charris:backport-20762
Jan 13, 2022
Merged

BUG: Allow integer inputs for pow-related functions in array_api#20807
charris merged 1 commit intonumpy:maintenance/1.22.xfrom
charris:backport-20762

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Jan 12, 2022

Backport of 20762.

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 this to the 1.22.1 release milestone Jan 12, 2022
@charris charris merged commit f90c972 into numpy:maintenance/1.22.x Jan 13, 2022
@charris charris deleted the backport-20762 branch January 13, 2022 03:10
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.

2 participants