Skip to content

Fix test failure if no device parameter - #459

Open
prady0t wants to merge 3 commits into
data-apis:masterfrom
prady0t:device-fix
Open

Fix test failure if no device parameter#459
prady0t wants to merge 3 commits into
data-apis:masterfrom
prady0t:device-fix

Conversation

@prady0t

@prady0t prady0t commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #458

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Comment thread array_api_tests/dtype_helpers.py
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@ev-br

ev-br commented Aug 21, 2026

Copy link
Copy Markdown
Member

I tried testing this PR with MLX since that's the only library which supports DLPack but does not have the .device attribute. Running dlpack tests is blocked on the lack of __array_namespace_info__, thus I think we should come back to this PR after ml-explore/mlx#4334 lands upstream.

try:
x = xp.empty(2, device=device)
except:
# 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, device=device)
try:
x = xp.empty(2, device=device)
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test fails if no device parameter.

3 participants