Package tulip :: Package transys :: Module mathset :: Class SubSet
[frames] | no frames]

Class SubSet


Subset of selected MathSet, or other Iterable.

Prior to adding new elements, it checks that they are in its superset.

Example

>>> superset = [1, 2]
>>> s = SubSet(superset)
>>> s |= [1, 2]
>>> print(s)
SubSet([[1, 2]])
>>> s.add(3)
raises exception because 3 \notin [1,2]

See Also

MathSet, PowerSet

Instance Methods
 
__init__(self, superset, iterable=None)
Define the superset of this set.
 
__repr__(self)
repr(x)
 
add(self, new_element)
Add state to subset.
 
add_from(self, new_elements)
Add multiple new elements to subset.

Inherited from MathSet: __contains__, __eq__, __ior__, __isub__, __iter__, __len__, __mul__, __or__, __sub__, intersection, intersects, pop, remove

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  superset

Inherited from object: __class__

Method Details

__init__(self, superset, iterable=None)
(Constructor)

 

Define the superset of this set.

Parameters:
  • superset (Iterable) - This SubSet checked vs superset
  • iterable (Iterable) - elements to add to subset
Overrides: object.__init__

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

add(self, new_element)

 

Add state to subset.

Extends MathSet.add with subset relation checking.

Example

new_initial_state should already be a state. First use states.add to include it in set of states, then states.add_initial.

See Also

MathSet.add

Parameters:
  • item - the new set element
Overrides: MathSet.add

add_from(self, new_elements)

 

Add multiple new elements to subset.

Extends MathSet.add_from with subset relation checking.

Note

It would be sufficient to extend only .add provided MathSet.add_from called .add iteratively. However MathSet.add_from filters states, which is arguably more efficient. So both .add and .add_from need to be extended here.

See Also

add, __ior__

Parameters:
  • iterable - new MathSet elements
Overrides: MathSet.add_from

Property Details

superset

Get Method:
unreachable.superset(self)