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

Class OrderedSet

xarray/core/utils.py:609–648  ·  view source on GitHub ↗

A simple ordered set. The API matches the builtin set, but it preserves insertion order of elements, like a dict. Note that, unlike in an OrderedDict, equality tests are not order-sensitive.

Source from the content-addressed store, hash-verified

607
608
609class OrderedSet(MutableSet[T]):
610 """A simple ordered set.
611
612 The API matches the builtin set, but it preserves insertion order of elements, like
613 a dict. Note that, unlike in an OrderedDict, equality tests are not order-sensitive.
614 """
615
616 _d: dict[T, None]
617
618 __slots__ = ("_d",)
619
620 def __init__(self, values: Iterable[T] | None = None):
621 self._d = {}
622 if values is not None:
623 self.update(values)
624
625 # Required methods for MutableSet
626
627 def __contains__(self, value: Hashable) -> bool:
628 return value in self._d
629
630 def __iter__(self) -> Iterator[T]:
631 return iter(self._d)
632
633 def __len__(self) -> int:
634 return len(self._d)
635
636 def add(self, value: T) -> None:
637 self._d[value] = None
638
639 def discard(self, value: T) -> None:
640 del self._d[value]
641
642 # Additional methods
643
644 def update(self, values: Iterable[T]) -> None:
645 self._d.update(dict.fromkeys(values))
646
647 def __repr__(self) -> str:
648 return f"{type(self).__name__}({list(self)!r})"
649
650
651class NdimSizeLenMixin:

Callers 4

_copy_listedMethod · 0.90
interpFunction · 0.90
interpolate_variableFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…