You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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_key abstract property in order to support re-indexing and alignment.
Take care of coordinate order (and maybe other things) inside Index.join and Index.equals, e.g., for PandasMultiIndex maybe 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.
The text was updated successfully, but these errors were encountered:
If a multi-coordinate index needs to care about order, it can implement that logic itself.
Agreed.
Option 4 would be nice indeed but it might be difficult to implement in the current Aligner class.
Another (easier) option would be to sort the names of the coordinates of each unique index before using it as a hash for finding the list of indexes to compare together, i.e.,
What is your issue?
(From #5647 (comment)).
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:
Index.create_variables()
, to ensure consistent orderIndex.matching_key
abstract property in order to support re-indexing and alignment.Index.join
andIndex.equals
, e.g., forPandasMultiIndex
maybe reorder the levels beforehand.The text was updated successfully, but these errors were encountered: