-
Notifications
You must be signed in to change notification settings - Fork 474
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
Adopt NEP-37 and NEP-47 (array module and Python Array API) #1592
Comments
I fully agree that we can move forward. One nice thing about the current facets organization is that we can create a Is there a good testsuite for compliance with the API that we can use? |
The test suite at https://github.com/data-apis/array-api-tests is very thorough, and easy to set up on CI too. |
The work I've been doing on uncertainties might be good grist for this mill. xref #1611, #1615 |
I would really like to see pint conform to the array API standard. That effort is really being broadly adopted, and helps out wrapper libraries like xarray immensely. It would particularly help fix this frustrating issue with |
I would like to move this forward. Should we put schedule it for 0.24? We need PR, tests and a good deprecation policy if some behavior needs to go away. See also #1895 |
As mentioned above, we've been discussing this a bit in the def hasattr(obj, attr):
try:
getattr(obj, attr)
except Exception:
return False
else:
return True which means that properties are always executed, and the checks could become One option to resolve this would be to split into A different option, which I think would be much easier to deal with, is to have separate modes of the registry: a scalar mode, where any function takes a scalar and returns a scalar, and a array mode that follows the array API and takes arrays and returns arrays (and scalars should be passed through Unlike |
I don't see why that would be a problem. If you are a On the other hand, there are other reasons where a separation would be helpful, see #1128 (comment) (i.e scalars should not conform to the array API). |
While Pint was a reasonably early adopter of NEP 18 (
__array_function__
) for array type compatibility, there have been several compatibility efforts in the NumPy (and Python arrays more generally) ecosystem recently that Pint has not yet taken advantage of, particularly the open NEPs 37 and 47, and with those, the Python Array API standards. It would be wonderful to see these implemented in Pint, and I believe that it should not be too onerous of a task (at least compared to the initial NEP 18 implementation)...perhaps all that would be needed is exposing the registries of functions in https://github.com/hgrecco/pint/blob/master/pint/facets/numpy/numpy_func.py as a module, which could then be returned as appropriate in the__array_module__
and__array_namespace__
protocols? That being said, given that__array_namespace__
denotes compliance with the Python Array API, perhaps rigorous testing against the API standard should be done prior to implementing that?xref pydata/xarray#7067, pydata/duck-array-discussion#3
The text was updated successfully, but these errors were encountered: