Set¶
- class odl.set.sets.Set[source]¶
Bases:
objectAn abstract set.
Abstract Methods
Each subclass of
Setmust implement two methods: one to check if an object is contained in the set and one to test if two sets are equal.Membership test:
__contains__(self, other)Test if
otheris a member of this set. This function provides the operator overload forin.- Parameters:
- other :
Object to be tested for membership
- Returns:
- containsbool
Trueifotheris a member of this set,Falseotherwise.
Equality test:
__eq__(self, other)Test if
otheris the same set as this set, i.e. both sets are of the same type and contain the same elements. This function provides the operator overload for==.- Parameters:
- other :
Object to be tested for equality.
- Returns:
- equalsbool
Trueif both sets are of the same type and contain the same elements,Falseotherwise.
A default implementation of the operator overload for
!=via__ne__(self, other)is provided asnot self.__eq__(other).Element creation (optional):
element(self, inp=None)Create an element of this set, either from scratch or from an input parameter.
- Parameters:
- inpoptional
Object from which to create the new element
- Returns:
- elementmember of this set
If
inpis None, return an arbitrary element. Otherwise, return the element created frominp.
- Attributes:
examplesGenerator creating name-value pairs of set elements.
Methods
contains_all(other)Test if all elements in
otherare contained in this set.contains_set(other)Test if
otheris a subset of this set.element([inp])Return an element from
inpor from scratch.- __init__(*args, **kwargs)¶