From da5dc954ea5e5a1c4fc43240f4ddfec051d71845 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Thu, 11 Mar 2021 16:44:39 -0700 Subject: Only return the same array in asarray if the dtype is the same --- numpy/_array_api/_creation_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 5b73c8f5c..cee379f59 100644 --- a/numpy/_array_api/_creation_functions.py +++ b/numpy/_array_api/_creation_functions.py @@ -21,7 +21,7 @@ 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): + if isinstance(obj, ndarray) and (dtype is None or obj.dtype == dtype): return obj res = np.asarray(obj, dtype=dtype) if res.dtype not in _all_dtypes: -- cgit v1.2.1