napari.utils.events.EventedSet#
- class napari.utils.events.EventedSet(data: Iterable[_T] = ())[source]#
Bases:
MutableSet
[_T
]An unordered collection of unique elements.
- Parameters:
data (iterable, optional) – Elements to initialize the set with.
- Events:
changed (added (Set[_T], removed: Set[_T])) – Emitted when the set changes, includes item(s) that have been added and/or removed from the set.
Methods
add
(value)Add an element to the set, if not already present.
clear
()This is slow (creates N new iterators!) but effective.
copy
()Return a shallow copy of this set.
difference
([others])Return set of all elements that are in this set but not other.
difference_update
([others])Remove all elements of another set from this set.
discard
(value)Remove an element from a set if it is a member.
intersection
([others])Return all elements that are in both sets as a new set.
intersection_update
([others])Remove all elements of in this set that are not present in other.
isdisjoint
(other)Return True if two sets have a null intersection.
issubset
(others)Returns whether another set contains this set or not
issuperset
(others)Returns whether this set contains another set or not
pop
()Return the popped value.
remove
(value)Remove an element.
symmetric_difference
(others)Returns set of elements that are in exactly one of the sets
symmetric_difference_update
(others)Update set to the symmetric difference of itself and another.
union
([others])Return a set containing the union of sets
update
([others])Update this set with the union of this set and others
validate
(v, field)Pydantic validator.
Attributes
Details
- copy() EventedSet[_T] [source]#
Return a shallow copy of this set.
- difference(others: Iterable[_T] = ()) EventedSet[_T] [source]#
Return set of all elements that are in this set but not other.
- difference_update(others: Iterable[_T] = ()) None [source]#
Remove all elements of another set from this set.
- discard(value: _T) None [source]#
Remove an element from a set if it is a member.
If the element is not a member, do nothing.
- intersection(others: Iterable[_T] = ()) EventedSet[_T] [source]#
Return all elements that are in both sets as a new set.
- intersection_update(others: Iterable[_T] = ()) None [source]#
Remove all elements of in this set that are not present in other.
- isdisjoint(other)#
Return True if two sets have a null intersection.
- issuperset(others: Iterable[_T]) bool [source]#
Returns whether this set contains another set or not
- pop()#
Return the popped value. Raise KeyError if empty.
- remove(value)#
Remove an element. If not a member, raise a KeyError.
- symmetric_difference(others: Iterable[_T]) EventedSet[_T] [source]#
Returns set of elements that are in exactly one of the sets
- symmetric_difference_update(others: Iterable[_T]) None [source]#
Update set to the symmetric difference of itself and another.
This will remove any items in this set that are also in other, and add any items in others that are not present in this set.
- union(others: Iterable[_T] = ()) EventedSet[_T] [source]#
Return a set containing the union of sets