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

Class PowerSet


Efficiently store power set of a mathematical set.

Set here isn't necessarily a Python set, i.e., it may comprise of unhashable elements.

Example

Specify the mathematical set S underlying the PowerSet.

>>> S = [[1, 2], '3', {'a':1}, 1]
>>> p = PowerSet(S)
>>> q = PowerSet()
>>> q.math_set = S

Add new element to underlying set S.

>>> p.math_set.add({3: 'a'} )

Add multiple new elements to underlying set S.

>>> p.math_set.add_from({3, 'a'} )
>>> p.math_set |= [1,2]

Remove existing element from set S.

>>> p.remove(1)

See Also

MathSet, SubSet, is_subset

Instance Methods
 
__init__(self, iterable=None)
Create new PowerSet over elements contained in S = iterable.
 
__get__(self, instance, value)
 
__repr__(self)
repr(x)
 
__contains__(self, item)
Is item \in 2^iterable = this powerset(iterable).
 
__iter__(self)
 
__len__(self)
 
__add__(self, other)
 
__eq__(self, other)
 
__setattr__(self, name, value)
x.__setattr__('name', value) <==> x.name = value

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

Properties

Inherited from object: __class__

Method Details

__init__(self, iterable=None)
(Constructor)

 

Create new PowerSet over elements contained in S = iterable.

This powerset is 2^S.

Parameters:
  • iterable (iterable of elements which can be hashable or not.) - contains elements of set S underlying the PowerSet.
  • iterable (iterable of elements which can be hashable or not.) - mathematical set S of elements, on which this 2^S defined.
Overrides: object.__init__

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__setattr__(self, name, value)

 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)