-
Notifications
You must be signed in to change notification settings - Fork 491
Description
When working with the new __array_function__ implementation in #764, seeing what it takes to get pint Quantity's working inside xarray (pydata/xarray#525), and trying to wrap my head around NEP 18, I realized that (to the best of what I could find) pint's expected behavior with other ndarray-like types is not well-documented or tested for. And so, I hope that this issue could be a discussion on clarifying those expected behaviors and determining how to document and test them.
To start that discussion, I think it would make sense to split other array-like types into two categories, those that should wrap pint, and those that should be wrapped by pint, or in other words, determine where pint should fall in the "type casting hierarchy". Based on pydata/xarray#525 (comment) and other comments I've seen, a split like the following seems to be desired:
Wrap pint Quantity
- xarray DataArray
Wrapped by pint Quantity
- dask array
- cupy array
- sparse array
- numpy masked array (and of course ndarray)
(Pandas seems to have special handling through pint-pandas, and hopefully others that I'm missing can be added to either list as appropriate)
Does this make sense as a division, and should a list like this be documented anywhere?
Also, once #764 is in place, it seems like there will be a need for explicit identification of types in each category...types that should wrap pint are used in
Line 70 in 4dcbe78
| if other.__class__.__name__ in ["PintArray", "Series"]: |
Quantity-related operations be assured?
Finally, should pint implement tests for all the types it expects to be able to wrap? I got the impression from pydata/xarray#525 and pydata/xarray#2956 that tests fit best with the type higher in the type casting hierarchy (the one doing the wrapping).
Please do correct me on anything I am mistaken about with the above rambling 😄.
xref pydata/xarray#525, pydata/xarray#2956, #764, #633, Unidata/MetPy#996
EDIT: Discussion about arbitrarily nested metadata with NEP 18 implementers is ongoing at dask/dask#5329, which will be good to keep in mind here too.