MCPcopy
hub / github.com/pydata/xarray / groupby_defaultdict

Function groupby_defaultdict

xarray/structure/combine.py:727–736  ·  view source on GitHub ↗

replacement for itertools.groupby

(
    iter: list[T],
    key: Callable[[T], K],
)

Source from the content-addressed store, hash-verified

725
726
727def groupby_defaultdict(
728 iter: list[T],
729 key: Callable[[T], K],
730) -> Iterator[tuple[K, Iterator[T]]]:
731 """replacement for itertools.groupby"""
732 idx = defaultdict(list)
733 for i, obj in enumerate(iter):
734 idx[key(obj)].append(i)
735 for k, ix in idx.items():
736 yield k, (iter[i] for i in ix)
737
738
739def _combine_single_variable_hypercube(

Callers 2

combine_by_coordsFunction · 0.85

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…