You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[RFC]: resolving an array namespace from a dtype #1021
Ah, that would be a pity. I should probably have tested that the returned __array_namespace__() is actually the one I want in the second proposal 😄
The second form has the issue that the dtype= and array_namespace= arguments can be incompatible. But even just in general terms, "where does this dtype come from?" seems a perfectly reasonable question to ask.
This is known and isn't solvable. SciPy has adopted the xp= keyword for the limited number of functions that need this (see for example the scipy.fft.fftfreq docs), so it isn't many characters.
This is not possible to address, both because of the shared NumPy dtype issues Lucas pointed out, and because it will add unacceptable overhead to dtypes (and possibly other implementation issues) so PyTorch et al. won't want to implement this. So I suggest we close this issue.
Activity
lucascolley commentedon Nov 26, 2026
I think that in multiple cases, the dtype class is not unique to the namespace — IIRC CuPy and Dask just expose the NumPy dtype classes as aliases.
I don't mind the second option tbh, although I would spell the parameter
xp.ntessore commentedon Nov 27, 2026
Ah, that would be a pity. I should probably have tested that the returned
__array_namespace__()is actually the one I want in the second proposal 😄The second form has the issue that the
dtype=andarray_namespace=arguments can be incompatible. But even just in general terms, "where does this dtype come from?" seems a perfectly reasonable question to ask.rgommers commentedon Nov 27, 2026
This is known and isn't solvable. SciPy has adopted the
xp=keyword for the limited number of functions that need this (see for example thescipy.fft.fftfreqdocs), so it isn't many characters.This is not possible to address, both because of the shared NumPy dtype issues Lucas pointed out, and because it will add unacceptable overhead to dtypes (and possibly other implementation issues) so PyTorch et al. won't want to implement this. So I suggest we close this issue.
[-]From dtype to array namespace[/-][+][RFC]: resolving an array namespace from a dtype[/+]