-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
What is your issue?
See: #9671 (comment)
At the moment, NamedArray's backing data can fulfill _arrayfunction although in practice, PandasIndexingAdapter and PandasExtensionArray don't actually fulfill this contract (although the later is much closer than the former). The following two lines are particularly problematic for non-numeric data:
xarray/xarray/namedarray/_typing.py
Lines 188 to 192 in d57f05c
| @property | |
| def imag(self) -> _arrayfunction[_ShapeType_co, Any]: ... | |
| @property | |
| def real(self) -> _arrayfunction[_ShapeType_co, Any]: ... |
FWIW numpy arrays do always fulfill this even when it doesn't make sense (even object dtypes have a imag and real). So I'm not sure how to move forward.
Of course, another issue is the whole _DType_co being bound to numpy. __getitem__ can return pandas dtypes but __array__ won't so maybe we need a base dtype and then a numpy one as well in the generic for the class?