summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_creation_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-03-11 16:44:39 -0700
committerAaron Meurer <asmeurer@gmail.com>2021-03-11 16:44:39 -0700
commitda5dc954ea5e5a1c4fc43240f4ddfec051d71845 (patch)
tree07fbd989c02802c90ddf490d7207346e97756cfa /numpy/_array_api/_creation_functions.py
parent8671a368cff459d5a00c5b43d330d084e2f6ed3d (diff)
downloadnumpy-da5dc954ea5e5a1c4fc43240f4ddfec051d71845.tar.gz
Only return the same array in asarray if the dtype is the same
Diffstat (limited to 'numpy/_array_api/_creation_functions.py')
-rw-r--r--numpy/_array_api/_creation_functions.py2
1 files changed, 1 insertions, 1 deletions
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: