Skip to content

Commit 7bae3b7

Browse files
committed
ENH: allow copy= in from_dlpack
1 parent 78ec53a commit 7bae3b7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

array_api_strict/_creation_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ def from_dlpack(
212212
if copy is not _undef:
213213
raise ValueError("The copy argument to from_dlpack requires at least version 2023.12 of the array API")
214214

215-
# Going to wait for upstream numpy support
216215
if device is not _undef:
217216
_check_device(device)
218217
else:
219218
device = None
220-
if copy not in [_undef, None]:
221-
raise NotImplementedError("The copy argument to from_dlpack is not yet implemented")
219+
if copy in [_undef, None]:
220+
# numpy 1.26 does not have the copy= arg
221+
return Array._new(np.from_dlpack(x), device=device)
222222

223-
return Array._new(np.from_dlpack(x), device=device)
223+
return Array._new(np.from_dlpack(x, copy=copy), device=device)
224224

225225

226226
def full(

0 commit comments

Comments
 (0)