Converts integer codes for groups to group indices.
(codes: np.ndarray, N: int)
| 89 | |
| 90 | |
| 91 | def _codes_to_group_indices(codes: np.ndarray, N: int) -> GroupIndices: |
| 92 | """Converts integer codes for groups to group indices.""" |
| 93 | assert codes.ndim == 1 |
| 94 | groups: GroupIndices = tuple([] for _ in range(N)) |
| 95 | for n, g in enumerate(codes): |
| 96 | if g >= 0: |
| 97 | groups[g].append(n) |
| 98 | return groups |
| 99 | |
| 100 | |
| 101 | def _dummy_copy(xarray_obj): |