NamedValueSet¶
- class lsst.daf.butler.NamedValueSet(elements: Iterable[K] = ())¶
- Bases: - NameMappingSetView[- K],- NamedValueMutableSet[- K]- Custom mutable set class. - A custom mutable set class that requires elements to have a - .nameattribute, which can then be used as keys in- dict-like lookup.- Names and elements can both be used with the - inand- deloperators,- remove, and- discard. Names (but not elements) can be used with- []-based element retrieval (not assignment) and the- getmethod.- Parameters:
- elementscollections.abc.Iterable
- Iterable over elements to include in the set. 
 
- elements
- Raises:
- AttributeError
- Raised if one or more elements do not have a - .nameattribute.
 
 - Notes - Iteration order is guaranteed to be the same as insertion order (with the same general behavior as - dictordering). Like- dicts, sets with the same elements will compare as equal even if their iterator order is not the same.- Methods Summary - add(element)- Add an element to the set. - clear()- This is slow (creates N new iterators!) but effective. - copy()- Return a new - NamedValueSetwith the same elements.- discard(element)- Remove an element from the set if it exists. - freeze()- Disable all mutators. - issubset(other)- issuperset(other)- pop(*args)- Remove and return an element from the set. - remove(element)- Remove an element from the set. - update(elements)- Add multiple new elements to the set. - Methods Documentation - add(element: K) None¶
- Add an element to the set. - Parameters:
- elementtyping.Any
- The element to add. 
 
- element
- Raises:
- AttributeError
- Raised if the element does not have a - .nameattribute.
 
 
 - copy() NamedValueSet[K]¶
- Return a new - NamedValueSetwith the same elements.
 - discard(element: str | K) Any¶
- Remove an element from the set if it exists. - Does nothing if no matching element is present. 
 - freeze() NamedValueAbstractSet[K]¶
- Disable all mutators. - Effectively transforming - selfinto an immutable set.- Returns:
- selfNamedValueAbstractSet
- While - selfis modified in-place, it is also returned with a type annotation that reflects its new, frozen state; assigning it to a new variable (and considering any previous references invalidated) should allow for more accurate static type checking.
 
- self
 
 - pop(*args: str) K¶
- Remove and return an element from the set. - Parameters:
- *argsstr, optional
- Name of the element to remove and return. Must be passed positionally. If not provided, an arbitrary element is removed and returned. 
 
- *args
- Raises:
- KeyError
- Raised if - nameis provided but- defaultis not, and no matching element exists.