Decompose the interpolation into a succession of independent interpolation keeping the order
(indexes_coords: SourceDest)
| 844 | |
| 845 | |
| 846 | def decompose_interp(indexes_coords: SourceDest) -> Generator[SourceDest, None]: |
| 847 | """Decompose the interpolation into a succession of independent interpolation keeping the order""" |
| 848 | |
| 849 | dest_dims = [ |
| 850 | dest[1].dims if dest[1].ndim > 0 else (dim,) |
| 851 | for dim, dest in indexes_coords.items() |
| 852 | ] |
| 853 | partial_dest_dims: list[tuple[Hashable, ...]] = [] |
| 854 | partial_indexes_coords: SourceDest = {} |
| 855 | for i, index_coords in enumerate(indexes_coords.items()): |
| 856 | partial_indexes_coords.update([index_coords]) |
| 857 | |
| 858 | if i == len(dest_dims) - 1: |
| 859 | break |
| 860 | |
| 861 | partial_dest_dims += [dest_dims[i]] |
| 862 | other_dims = dest_dims[i + 1 :] |
| 863 | |
| 864 | s_partial_dest_dims = {dim for dims in partial_dest_dims for dim in dims} |
| 865 | s_other_dims = {dim for dims in other_dims for dim in dims} |
| 866 | |
| 867 | if not s_partial_dest_dims.intersection(s_other_dims): |
| 868 | # this interpolation is orthogonal to the rest |
| 869 | |
| 870 | yield partial_indexes_coords |
| 871 | |
| 872 | partial_dest_dims = [] |
| 873 | partial_indexes_coords = {} |
| 874 | |
| 875 | yield partial_indexes_coords |