Represents iterable unordered elements.
| Parameters: |
|
|---|---|
| Raises: | Exception |
Spawns a new SetCell of the same domain
| Returns: | SetIntersectionCell |
|---|
>>> a = SetIntersectionCell([1,2,3])
>>> b = a.stem()
>>> b
{1,2,3}
Ensures that a value is a SetCell
| Parameters: | value – A Cell or value in self‘s domain |
|---|---|
| Returns: | SetIntersectionCell |
| Raises: | CellConstructionFailure |
>>> a = SetIntersectionCell([1,2,3])
>>> b = a.coerce([1,2])
>>> b
{1,2}
>>> c = a.coerce(1)
>>> c
{1}
Cheap pointer comparison or symmetric difference operation to ensure domains are the same
| Parameters: | other (SetCell) – SetCell to be compared |
|---|---|
| Returns: | bool |
>>> a = SetIntersectionCell([1,2,3])
>>> b = SetIntersectionCell([2,3,1])
>>> c = SetIntersectionCell([1,2])
>>> a.same_domain(b)
True
>>> a.same_domain(c)
False
True iff all members are the same
| Parameters: | other (SetCell) – SetCell to be compared |
|---|---|
| Returns: | bool |
| Raises: | CellConstructionFailure |
>>> a = SetIntersectionCell(range(10))
>>> b = SetIntersectionCell(range(10),[1,3,5])
>>> c = SetIntersectionCell([1,3,5])
>>> a.is_equal(b)
False
>>> b.is_equal(c)
True
What does it mean for one set to contradict another? Two sets are contradictory when they are disjoint.
| Parameters: | other (SetCell) – A SetCell to be compared |
|---|---|
| Returns: | bool |
| Raises: | CellConstructionFailure |
>>> a = SetIntersectionCell(['a','b','c'])
>>> b = SetIntersectionCell(['d','e','f'])
>>> c = SetIntersectionCell(['c','d'])
>>> a.is_contradictory(b)
True
>>> a.is_contradictory(c)
False
>>> b.is_contradictory(c)
False
Fewer members = more information (exception is empty set, which means all members of the domain)
If the two SetCells do not have the same domain, this method returns False.
If the two SetCells have the same domain, then self is entailed by other if self.values is a subset of other.values, or if other.values is empty (None).
param other: A SetCell to be tested type other: SetCell returns: bool
>>> a = SetIntersectionCell(range(10),[1,2,3])
>>> b = SetIntersectionCell(range(5),[1,2,3])
>>> c = SetIntersectionCell(range(10),[1,2])
>>> a.is_entailed_by(b)
False
>>> a.is_entailed_by(c)
True
>>> c.is_entailed_by(a)
False
Returns True iff value is in the set
| Parameters: | other – A value that may or may not be in the domain of self. |
|---|---|
| Returns: | bool |
>>> a = SetIntersectionCell(['red','blue','green'],['red','blue'])
>>> b = SetIntersectionCell(['red','blue','green'])
>>> a.contains('red')
True
>>> a.contains('green')
False
>>> b.contains('green')
True
Returns the values of the set, or the domain as a set if no values were specified at construction.
| Returns: | set |
|---|
>>> x = SetIntersectionCell(['a','b','c'])
>>> y = SetIntersectionCell(['a','b','c'],['a','b'])
>>> x.get_values()
set(['a', 'c', 'b'])
>>> y.get_values()
set(['a', 'b'])
We can merge unless the merge results in an empty set – a contradiction. This method results in the intersection of the two SetCells.
Note
This method modifies the self argument.
| Parameters: | other (SetCell) – SetCell to merge with |
|---|---|
| Returns: | SetCell |
| Raises: | Contradiction, CellConstructionFailure |
>>> a = SetIntersectionCell(range(10),range(10))
>>> b = SetIntersectionCell(range(10),[1,2,3])
>>> a.merge(b)
{1,2,3}
>>> c = SetIntersectionCell(range(7),[2,3,4])
>>> a.merge(c)
{2,3}
For Graphviz rendering
SetUnionCell inherits from SetIntersectionCell and breaks monotonicity. Initially, its values are equal to its domain, and then after 1 or more updates, its values become the UNION of all of the updates
We can merge unless the two sets are contradictory, i.e. they are disjoint. The resulting merge will be the union of the two sets.
Note
This method will modify the self argument.
| Parameters: | other (SetCell) – SetCell to merge with |
|---|---|
| Returns: | SetCell |
| Raises: | Contradiction, CellConstructionFailure |
>>> a = SetUnionionCell(range(10),range(5))
>>> b = SetUnionionCell(range(10),range(3,8))
>>> a.merge(b)
{0,1,2,3,4,5,6,7,8}