NamedValueMutableSet

class lsst.daf.butler.NamedValueMutableSet

Bases: lsst.daf.butler.NamedValueAbstractSet, collections.abc.MutableSet, typing.Generic

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 its MutableSet form (no arguments; an arbitrary element is returned) or its MutableMapping form (one or two arguments for the name and optional default value, respectively). A MutableMapping-like __delitem__ interface is also included, which takes only names (like NamedValueAbstractSet.__getitem__).

Attributes Summary

names Return set of names associated with the keys, in the same order.

Methods Summary

add(value) Add an element.
asMapping() Return a mapping view with names as keys.
clear() This is slow (creates N new iterators!) but effective.
discard(element, K]) Remove an element from the set if it exists.
get(key, K_co], default, None] = None) 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, K]) Remove an element from the set.

Attributes Documentation

names

Return set of names associated with the keys, in the same order.

(AbstractSet [ str ]).

Methods Documentation

add(value)

Add an element.

asMapping() → Mapping[str, K_co]

Return a mapping view with names as keys.

Returns:
dict : Mapping

A dictionary-like view with values() == self.

clear()

This is slow (creates N new iterators!) but effective.

discard(element: Union[str, K]) → Any

Remove an element from the set if it exists.

Does nothing if no matching element is present.

Parameters:
element : object or str

Element to remove or the string name thereof. Assumed to be an element if it has a .name attribute.

get(key: Union[str, K_co], default: Optional[Any, None] = None) → Any

Return the element with the given name.

Returns default if no such element is present.

isdisjoint(other)

Return True if two sets have a null intersection.

pop(*args) → K

Remove and return an element from the set.

Parameters:
name : str, optional

Name of the element to remove and return. Must be passed positionally. If not provided, an arbitrary element is removed and returned.

Raises:
KeyError

Raised if name is provided but default is not, and no matching element exists.

remove(element: Union[str, K]) → Any

Remove an element from the set.

Parameters:
element : object or str

Element to remove or the string name thereof. Assumed to be an element if it has a .name attribute.

Raises:
KeyError

Raised if an element with the given name does not exist.