Skip to content

Commit

Permalink
Update __array_namespace__ to accept api_version. (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 authored Jul 1, 2024
1 parent 0563003 commit e56a4ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit e56a4ad

Please sign in to comment.