summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_creation_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-02-23 18:54:43 -0700
committerAaron Meurer <asmeurer@gmail.com>2021-02-23 18:54:43 -0700
commitcd7092078b8f74ac5f873c9547676688ffd22276 (patch)
treea35da828524e982c2074558c47a52212d6631941 /numpy/_array_api/_creation_functions.py
parenta42f71ac8ac559d0ef770bdfd2f62bd1be4848d5 (diff)
downloadnumpy-cd7092078b8f74ac5f873c9547676688ffd22276.tar.gz
Support array_api.ndarray in array_api.asarray()
Diffstat (limited to 'numpy/_array_api/_creation_functions.py')
-rw-r--r--numpy/_array_api/_creation_functions.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py
index 06d9e6dad..6d9a767b4 100644
--- a/numpy/_array_api/_creation_functions.py
+++ b/numpy/_array_api/_creation_functions.py
@@ -19,6 +19,8 @@ def asarray(obj: Union[float, NestedSequence[bool|int|float], SupportsDLPack, Su
if copy is not None:
# Note: copy is not yet implemented in np.asarray
raise NotImplementedError("The copy keyword argument to asarray is not yet implemented")
+ if isinstance(obj, ndarray):
+ return obj
res = np.asarray(obj, dtype=dtype)
if res.dtype not in _dtypes._all_dtypes:
raise TypeError(f"The array_api namespace does not support the dtype {res.dtype}")