Custom indexes and coordinate (re)ordering
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?
(From https://github.com/pydata/xarray/issues/5647#issuecomment-946546464).
The current alignment logic (as refactored in #5692) requires that two compatible indexes (i.e., of the same type) must relate to one or more coordinates with matching names but also in a matching order.
For some multi-coordinate indexes like PandasMultiIndex this makes sense. However, for other multi-coordinate indexes (e.g., staggered grid indexes) the order of the coordinates doesn't matter much.
Possible options:
- Setting new Xarray indexes may reorder the coordinate variables, possibly via
Index.create_variables(), to ensure consistent order - Xarray indexes must implement a
Index.matching_keyabstract property in order to support re-indexing and alignment. - Take care of coordinate order (and maybe other things) inside
Index.joinandIndex.equals, e.g., forPandasMultiIndexmaybe reorder the levels beforehand.- pros: more flexible
- cons: not great to implicitly reorder levels if it's a costly operation?
- Find matching indexes using a two-passes approach: (1) group all indexes by dimension name and (2) check compatibility between the indexes listed in each group.
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 by reading the alignment logic refactored in #5692 and the Index.create_variables(), Index.join(), and Index.equals() entry points named in the issue. Compare the four proposed approaches, then establish a decision and tests covering coordinate reordering for compatible multi-coordinate indexes; the issue is complete when alignment handles the intended coordinate-order cases consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100