Skip to content

Commit 542b599

Browse files
committed
Add __array_namespace__ method
1 parent 659629d commit 542b599

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

dpnp/dpnp_array.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(
9494
offset=offset,
9595
order=order,
9696
buffer_ctor_kwargs={"queue": sycl_queue_normalized},
97+
array_namespace=dpnp,
9798
)
9899

99100
@property
@@ -201,6 +202,31 @@ def __and__(self, other):
201202
# '__array_ufunc__',
202203
# '__array_wrap__',
203204

205+
def __array_namespace__(self, /, *, api_version=None):
206+
"""
207+
Returns array namespace, member functions of which implement data API.
208+
209+
Parameters
210+
----------
211+
api_version : str, optional
212+
Request namespace compliant with given version of array API. If
213+
``None``, namespace for the most recent supported version is
214+
returned.
215+
Default: ``None``.
216+
217+
Returns
218+
-------
219+
out : any
220+
An object representing the array API namespace. It should have
221+
every top-level function defined in the specification as
222+
an attribute. It may contain other public names as well, but it is
223+
recommended to only include those names that are part of the
224+
specification.
225+
226+
"""
227+
228+
return self._array_obj.__array_namespace__(api_version=api_version)
229+
204230
def __bool__(self):
205231
"""``True`` if self else ``False``."""
206232
return self._array_obj.__bool__()

0 commit comments

Comments
 (0)