summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_creation_functions.py
diff options
context:
space:
mode:
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: