Skip to content

Commit 4c6b360

Browse files
authored
Merge pull request #197 from ev-br/from_dlpack_copy
ENH: allow `copy=` in `from_dlpack`
2 parents e92d063 + 7bae3b7 commit 4c6b360

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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)