Skip to content

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

@honno

Description

@honno

The Array API initially only allowed floating arrays and Python scalars for these functions, but has since allowed all numeric arrays/Python scalars. They currently do work for integer Python scalars, but are restricted from using integer arrays.

Power functions: xp.pow(), x.__pow()__ and x.__ipow()__
Divide functions: xp.divide(), x.__truediv__() and x.__itruediv__()

Note scalar scenarios can still fail as the left argument could be an integer array.

cc @asmeurer @IvanYashchuk

Reproduce the code example:

>>> import numpy.array_api as xp
>>> xp.asarray(2) / xp.asarray(2)
TypeError: Only floating-point dtypes are allowed in __truediv__
>>> xp.asarray(2) ** xp.asarray(2)
TypeError: Only floating-point dtypes are allowed in __pow__

NumPy/Python version information:

1.23.0.dev0+358.g1684a933d 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions