Skip to content

feat: automatically generate Protocol for array-api-namespace #858

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fix typing
  • Loading branch information
34j committed Nov 24, 2024
commit 782b15ae26c99b0d6aaa683a8d06e1171ae63d50
10 changes: 4 additions & 6 deletions src/array_api_stubs/_draft/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
array = TypeVar("array", bound="Array")
device = TypeVar("device")
dtype = TypeVar("dtype", bound=DType)
device_ = TypeVar("device_") # only used in this file
dtype_ = TypeVar("dtype_", bound=DType) # only used in this file
SupportsDLPack = TypeVar("SupportsDLPack")
SupportsBufferProtocol = TypeVar("SupportsBufferProtocol")
PyCapsule = TypeVar("PyCapsule")
Expand Down Expand Up @@ -149,12 +147,12 @@ def dtypes(
)


class Array(Protocol[array, dtype_, device_, PyCapsule]): # type: ignore
class Array(Protocol[array, "dtype", "device", PyCapsule]): # type: ignore
def __init__(self: array) -> None:
"""Initialize the attributes for the array object class."""

@property
def dtype(self: array) -> dtype_:
def dtype(self: array) -> "dtype":
"""
Data type of the array elements.

Expand All @@ -165,7 +163,7 @@ def dtype(self: array) -> dtype_:
"""

@property
def device(self: array) -> device_:
def device(self: array) -> "device":
"""
Hardware device the array data resides on.

Expand Down Expand Up @@ -1344,7 +1342,7 @@ def __xor__(self: array, other: Union[int, bool, array], /) -> array:
"""

def to_device(
self: array, device: device_, /, *, stream: Optional[Union[int, Any]] = None
self: array, device: "device", /, *, stream: Optional[Union[int, Any]] = None # type: ignore
) -> array:
"""
Copy the array from the device on which it currently resides to the specified ``device``.
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy