API Reference

bitset

bitsets.bitset(name, members, base=<class 'bitsets.bases.BitSet'>, list=False, tuple=False)

Return a new bitset class with given name and members.

Parameters:
  • name – Name of the class to be created.
  • members – Hashable sequence of allowed bitset members.
  • base – Base class to derive the returned class from.
  • list (bool) – Include a custom class for bitset lists.
  • tuple (bool) – Include a custom class for bitset tuples.

Example

>>> Letters = bitset('Letters', 'abcdef', list=True, tuple=True)
>>> Letters  
<class bitsets.meta.bitset('Letters', 'abcdef', 0x..., BitSet, List, Tuple)>
>>> Letters('deadbeef')
Letters(['a', 'b', 'd', 'e', 'f'])

BitSet

class bitsets.bases.BitSet

Ordered container of unique elements from a predefined domain.

Parameters:members – Iterable of domain members.
Raises:KeyError – if a member is not in the domain of the set.
__contains__(member)

Set membership.

Raises:KeyError – if member is not in the domain of the set.
__iter__()

Iterate over the set members.

__len__()

Return the number of items in the set (cardinality).

all()

Return True iff the set contains all domain items.

any()

Return True iff the set contains at least one item.

atoms(reverse=False)

Yield the singleton for every set member.

bits()

Return the binary string of set membership.

bools()

Return the boolean sequence of set membership.

complement()

Complement set.

copy()

Return the set unchanged (as its is immutable).

count(value=True)

Returns the number of present/absent members.

difference(other)

Set difference.

frombits(bits='0')

Create a set from binary string.

frombools(bools=())

Create a set from an iterable of boolean evaluable items.

inatoms(reverse=False)

Yield the singleton for every non-member.

intersection(other)

Set intersection.

isdisjoint(other)

Set disjointness.

issubset(other)

Inverse set containment.

issuperset(other)

Set containment.

longcolex()

Return sort key for long colexicographical order.

longlex()

Return sort key for long lexicographical order.

members(as_set=False)

Return the set members tuple/frozenset.

powerset(start=None, excludestart=False)

Yield combinations from start to self in short lexicographic order.

shortcolex()

Return sort key for short colexicographical order.

shortlex()

Return sort key for short lexicographical order.

symmetric_difference(other)

Symmetric set difference.

union(other)

Set union.

BitSet.List

class bitsets.series.List(*bits)

Mutable bitset sequence.

Parameters:*bits (str) – Strings with the binary membership representation.
bits()

Return the series as list of binary set membership strings.

bools()

Return the series as list of boolean set membership sequences.

frombits(bits)

Series from binary string arguments.

frombools(bools)

Series from iterable of boolean evaluable iterables.

fromints(ints)

Series from integer rank arguments.

frommembers(members)

Series from iterable of member iterables.

index_sets(as_set=False)

Return the series as list of index set tuples.

ints()

Return the series as list of integers ranks.

members(as_set=False)

Return the series as list of set member tuples/frozensets.

reduce_and()

Return the intersection of all series elements.

reduce_or()

Return the union of all series elements.

BitSet.Tuple

class bitsets.series.Tuple

Immutable bitset sequence.

Parameters:*bits (str) – Strings with the binary membership representation.
bits()

Return the series as list of binary set membership strings.

bools()

Return the series as list of boolean set membership sequences.

frombits(bits)

Series from binary string arguments.

frombools(bools)

Series from iterable of boolean evaluable iterables.

fromints(ints)

Series from integer rank arguments.

frommembers(members)

Series from iterable of member iterables.

index_sets(as_set=False)

Return the series as list of index set tuples.

ints()

Return the series as list of integers ranks.

members(as_set=False)

Return the series as list of set member tuples/frozensets.

reduce_and()

Return the intersection of all series elements.

reduce_or()

Return the union of all series elements.