Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion array_api_tests/dtype_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def is_device_dlpack_compatible(device):
"""If device is dlpack compatible, return True, else False"""
# XXX: there seems to be no better way than try-catch for __dlpack_device__()

x = xp.empty(2, device=device)
try:
x = xp.empty(2, device=device)
Comment thread
prady0t marked this conversation as resolved.
except:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make this except TypeError (I think this is the exception?) to make sure we only catch errors that are due to the fact that there is no device keyword argument.

Even better would be having a way to inspect the array library/function to determine if there is a device argument or not. This would be explicitly checking what we want to know

# also covers libraries that does not support device parameter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# also covers libraries that does not support device parameter
# also covers libraries that do not support device parameter

x = xp.empty(2)
try:
x.__dlpack_device__()
except:
Expand Down
Loading