MCPcopy Index your code
hub / github.com/pydata/xarray / _factorize_given_labels

Function _factorize_given_labels

xarray/groupers.py:641–653  ·  view source on GitHub ↗
(data: np.ndarray, labels: np.ndarray)

Source from the content-addressed store, hash-verified

639
640
641def _factorize_given_labels(data: np.ndarray, labels: np.ndarray) -> np.ndarray:
642 # Copied from flox
643 sorter = np.argsort(labels)
644 is_sorted = array_all(sorter == np.arange(sorter.size))
645 codes = np.searchsorted(labels, data, sorter=sorter)
646 mask = ~np.isin(data, labels) | isnull(data) | (codes == len(labels))
647 # codes is the index in to the sorted array.
648 # if we didn't want sorting, unsort it back
649 if not is_sorted:
650 codes[codes == len(labels)] = -1
651 codes = sorter[(codes,)]
652 codes[mask] = -1
653 return codes
654
655
656def unique_value_groups(

Callers

nothing calls this directly

Calls 5

array_allFunction · 0.90
isnullFunction · 0.90
arangeMethod · 0.80
isinMethod · 0.80
argsortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…