We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd798e1 commit 391b08bCopy full SHA for 391b08b
numpy_array_api_compat/_aliases.py
@@ -164,6 +164,13 @@ def asarray(
164
if copy in (False, np._CopyMode.IF_NEEDED):
165
# copy=False is not yet implemented in np.asarray
166
raise NotImplementedError("copy=False is not yet implemented")
167
+ if isinstance(obj, np.ndarray):
168
+ if dtype is not None and obj.dtype != dtype:
169
+ copy = True
170
+ if copy in (True, np._CopyMode.ALWAYS):
171
+ return np.array(obj, copy=True, dtype=dtype)
172
+ return obj
173
+
174
return np.asarray(obj, dtype=dtype)
175
176
def arange(
0 commit comments