FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add protocols for array object methods by NeilGirdhar · Pull Request #69 · data-apis/array-api-typing · GitHub

Add protocols for array object methods - #69

Open
NeilGirdhar wants to merge 8 commits into
data-apis:mainfrom
NeilGirdhar:array-protocols
Open

Add protocols for array object methods#69
NeilGirdhar wants to merge 8 commits into
data-apis:mainfrom
NeilGirdhar:array-protocols

Conversation

Copy link
Copy Markdown
Contributor

Once you finish #34, could someone take a look this? @jorenham @lucascolley @nstarman

Add protocols for array object methods:

  • DLPack export via HasDLPack
  • Indexing via HasGetItem
  • Indexed assignment via HasSetItem
  • Device transfer via HasToDevice

Also composes these protocols into Array, exports them from the
top-level package, and adds NumPy integration assignments for the new
protocol surfaces.

nstarman and others added 8 commits August 19, 2025 19:22
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
- DLPack export via `HasDLPack`
- Indexing via `HasGetItem`
- Indexed assignment via `HasSetItem`
- Device transfer via `HasToDevice`

Also composes these protocols into `Array`, exports them from the
top-level package, and adds NumPy integration assignments for the new
protocol surfaces.
Comment thread src/array_api_typing/__init__.py Outdated
Comment on lines +17 to +11
from ._array import (
Array,
HasArrayNamespace,
HasDevice,
HasDType,
HasMatrixTranspose,
HasNDim,
HasShape,
HasSize,
HasTranspose,
)
from ._array import Array, HasArrayNamespace, HasDType

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

could you elaborate on the implications of removing these here and composing them into Array instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Did you want to expose them for some reason? I thought they were internal details?

And don't you ultimately want Array to imply all of the protocols?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what is the reason for exposing HasDType but not HasShape, for example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That was the state of the line before my change, and I didn't want to change it. But yes, as far as I know, there is no reason to expose it either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cool. Could you add a review comment to gh-34 which suggests to stop exposing all of them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'll add a question 😄

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL