Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make asarray work with array-api-compat CuPy arrays #80

Closed
mdhaber opened this issue Jan 22, 2025 · 0 comments · Fixed by #81
Closed

Make asarray work with array-api-compat CuPy arrays #80

mdhaber opened this issue Jan 22, 2025 · 0 comments · Fixed by #81

Comments

@mdhaber
Copy link
Owner

mdhaber commented Jan 22, 2025

This should work:

from array_api_compat import cupy as cp
import marray
mcp = marray._get_namespace(cp)
x = cp.asarray([1, 2, 3])
mcp.asarray(x)  # ValueError: Unsupported dtype object

This happens because x has an attribute data, but cp.asarray(x.data) doesn't work (like it does for NumPy).
asarray (and other functions) probably shouldn't be using the data attribute of an object just because it exists; we only really mean to do that if the array has a mask.

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 a pull request may close this issue.

1 participant