NamedValueMutableSet¶
- class lsst.daf.butler.NamedValueMutableSet¶
Bases:
NamedValueAbstractSet
[K
],MutableSet
[K
]Mutable variant of
NamedValueAbstractSet
.Methods that can add new elements to the set are unchanged from their
MutableSet
definitions, while those that only remove them can generally accept names or element instances.pop
can be used in either itsMutableSet
form (no arguments; an arbitrary element is returned) or itsMutableMapping
form (one or two arguments for the name and optional default value, respectively). AMutableMapping
-like__delitem__
interface is also included, which takes only names (likeNamedValueAbstractSet.__getitem__
).Attributes Summary
Return set of names associated with the keys, in the same order.
Methods Summary
add
(value)Add an element.
Return a mapping view with names as keys.
clear
()This is slow (creates N new iterators!) but effective.
discard
(element)Remove an element from the set if it exists.
get
(key[, default])Return the element with the given name.
isdisjoint
(other)Return True if two sets have a null intersection.
pop
(*args)Remove and return an element from the set.
remove
(element)Remove an element from the set.
Attributes Documentation
Methods Documentation
- abstract add(value)¶
Add an element.
- abstract asMapping() Mapping[str, K_co] ¶
Return a mapping view with names as keys.
- Returns:
- dict
Mapping
A dictionary-like view with
values() == self
.
- dict
- clear()¶
This is slow (creates N new iterators!) but effective.
- abstract discard(element: str | K) Any ¶
Remove an element from the set if it exists.
Does nothing if no matching element is present.
- get(key: Any, default: Any = None) Any ¶
Return the element with the given name.
- Parameters:
- key
typing.Any
The name of the element to be requested.
- default
typing.Any
, optional The value returned if no such element is present.
- key
- Returns:
- result
typing.Any
The value of the element.
- result
- isdisjoint(other)¶
Return True if two sets have a null intersection.
- abstract pop(*args: str) K ¶
Remove and return an element from the set.
- Parameters:
- *args
str
, 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
name
is provided butdefault
is not, and no matching element exists.