Skip to content
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

Test array api protocol #7902

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

Illviljan
Copy link
Contributor

  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

@TomNicholas TomNicholas added the topic-arrays related to flexible array support label Jun 8, 2023
@TomNicholas
Copy link
Member

Oh cool!

Do you think it would be difficult for me to extend this protocol to make one for chunked array types, to test typing of functionality in #7019?

@Illviljan
Copy link
Contributor Author

I think you should be able to subclass Array and add the missing properties. But I haven't played around with this much at all yet.

@TomNicholas TomNicholas added the array API standard Support for the Python array API standard label Jan 25, 2024
# NOTE: when working with py3.11+ this can be ``typing.array``.


class Array(Protocol):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that numpy.array_api exists, can we replace this entire class with that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's possible since the types becomes too specific.
For example .mT would always return numpy.array_api._array_object.Array which wouldn't work with cubed.

np.array_api also implements a few methods that aren't required by the spec either making it too specific for us.

This code was vendored from a PR in the array-api github so we could hopefully import from there whenever it has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array API standard Support for the Python array API standard topic-arrays related to flexible array support topic-typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants