From cd7092078b8f74ac5f873c9547676688ffd22276 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Tue, 23 Feb 2021 18:54:43 -0700 Subject: Support array_api.ndarray in array_api.asarray() --- numpy/_array_api/_creation_functions.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'numpy/_array_api/_creation_functions.py') 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}") -- cgit v1.2.1