`NamedArray` typing audit
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
See: https://github.com/pydata/xarray/pull/9671#issuecomment-2642542167
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:
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with xarray/namedarray/_typing.py at lines 188-192 and read the linked PR comment. Compare the declared NamedArray backing-data contract with the behavior of PandasIndexingAdapter, PandasExtensionArray, and NumPy arrays, including the dtype and getitem/array concerns. Done means the typing model accurately reflects these implementations and the remaining design is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, python
- Domain
- data, developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100