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

Update __array_namespace__ to accept api_version. #12

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Changelog

- ndonnx now exports type annotations.

**Bug fixes**

- ``__array_namespace__`` now accepts the optional ``api_version`` argument to specify the version of the Array API to use.

0.4.0 (2024-05-16)
------------------

Expand Down
10 changes: 8 additions & 2 deletions ndonnx/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,14 @@ def spox_var(self) -> Var:
return self._core().var

@staticmethod
def __array_namespace__():
return ndx
def __array_namespace__(*, api_version: str | None = None):
if api_version is None:
api_version = "2023.12"

if api_version == "2023.12":
return ndx
else:
raise ValueError(f"Unsupported API version {api_version}")

def __float__(self) -> float:
eager_value = self.to_numpy()
Expand Down