Skip to content

ENH: Updates to numpy.array_api #19937

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

Merged
merged 9 commits into from
Sep 25, 2021
Merged

Conversation

asmeurer
Copy link
Member

There have been several updates to the array API spec since #19739. There are still a few changes that are planned to be made before the spec is finalized next month. If this is merged I will just make new PRs as those come in. I also plan to make a separate PR adding support for the linear algebra extension.

CC @leofang

The spec specifies that they should only work on arrays with corresponding
dtypes. __index__ is new in the spec since the initial PR, and works
identically to np.array.__index__.
This method is new since numpy#18585. It does nothing in NumPy since NumPy does not
support non-CPU devices.
transpose() was renamed to matrix_transpose() and now operates on stacks of
matrices. A function to permute dimensions will be added once it is finalized
in the spec. The attribute mT was added and the T attribute was updated to
only operate on 2-dimensional arrays as per the spec.
permute_dims() is the replacement for transpose(), which was split into
permute_dims() and matrix_transpose().
@charris charris merged commit 2d112a9 into numpy:main Sep 25, 2021
@charris
Copy link
Member

charris commented Sep 25, 2021

Thanks Aaron.

howjmay pushed a commit to howjmay/numpy that referenced this pull request Sep 29, 2021
* Add __index__ to array_api and update __int__, __bool__, and __float__

The spec specifies that they should only work on arrays with corresponding
dtypes. __index__ is new in the spec since the initial PR, and works
identically to np.array.__index__.

* Add the to_device method to the array_api

This method is new since numpy#18585. It does nothing in NumPy since NumPy does not
support non-CPU devices.

* Update transpose methods in the array_api

transpose() was renamed to matrix_transpose() and now operates on stacks of
matrices. A function to permute dimensions will be added once it is finalized
in the spec. The attribute mT was added and the T attribute was updated to
only operate on 2-dimensional arrays as per the spec.

* Restrict input dtypes in the array API statistical functions

* Add the dtype parameter to the array API sum() and prod()

* Add the function permute_dims() to the array_api namespace

permute_dims() is the replacement for transpose(), which was split into
permute_dims() and matrix_transpose().

* Add tril and triu to the array API namespace

* Fix the array_api Array.__repr__ to indent the array properly

* Make the Device type in the array_api just accept the string "cpu"
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.

3 participants