misc¶
Submodules¶
permuta.misc.algorithm_x module¶
-
class
permuta.misc.algorithm_x.
AlgorithmX
(rows, cols, solution_callback)¶ Bases:
object
-
search
(k=0, at_most=None)¶
-
set_value
(row, col, val=True)¶
-
setup
()¶
-
-
permuta.misc.algorithm_x.
cover
(c)¶
-
permuta.misc.algorithm_x.
uncover
(c)¶
permuta.misc.checking module¶
-
permuta.misc.checking.
index
(obj, maximum=None)¶ Check if an object is an index and raise exceptions if it isn’t.
Parameters: - obj – <object> The object to be checked.
- maximum – <numbers.Integral> The number the object is not to exceed if it is a number.
Raises: TypeError
– Object is not an integral number.ValueError
– Object is an integral number, but not a valid index.
Examples
>>> index(4) >>> index(0) >>> index(-3) Traceback (most recent call last): ... ValueError: -3 is not a valid index >>> index(21, 30) >>> index(0.3) Traceback (most recent call last): ... TypeError: '0.3' object is not a valid index >>> index(333, 30) Traceback (most recent call last): ... ValueError: 333 is not a valid index
permuta.misc.counting module¶
-
permuta.misc.counting.
binomial
(n, k)¶
-
permuta.misc.counting.
catalan
(n)¶
-
permuta.misc.counting.
factorial
(n)¶
permuta.misc.dancing_links module¶
permuta.misc.exact_cover module¶
-
permuta.misc.exact_cover.
exact_cover
(bss, validcnt, max_cnt, ignore_first, allow_overlap_in_first)¶
-
permuta.misc.exact_cover.
exact_cover_smallest
(bss, validcnt, max_cnt, ignore_first, allow_overlap_in_first)¶
permuta.misc.iterable_floor_and_ceiling module¶
-
class
permuta.misc.iterable_floor_and_ceiling.
FloorAndCeiling
(floor, ceiling)¶ Bases:
tuple
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
static
__new__
(_cls, floor, ceiling)¶ Create new instance of FloorAndCeiling(floor, ceiling)
-
__repr__
()¶ Return a nicely formatted representation string
-
ceiling
¶ Alias for field number 1
-
floor
¶ Alias for field number 0
-
-
permuta.misc.iterable_floor_and_ceiling.
left_floor_and_ceiling
(iterable, default_floor=None, default_ceiling=None)¶ Find the left floor and ceiling indices of iterable.
Define left_floor of an element in a sequence to be the index of the greatest smaller element to the left of said element, or default_floor if there is none. Similarly define default_ceiling. This function yields a tuple (left_floor, left_ceiling) for each element of iterable.
Parameters: - iterable – <iterable> An iterable of totally ordered unique elements.
- default_floor – <object>
- default_ceiling – <object>
- Yields: (int, int)
- The i-th yielded tuple is the left floor and ceiling indices of the i-th element of the iterable. The tuples are named tuples with floor and ceiling attributes.
-
permuta.misc.iterable_floor_and_ceiling.
right_floor_and_ceiling
(iterable, default_floor=None, default_ceiling=None)¶ The right counterpart of left_floor_and_ceiling.
permuta.misc.misc module¶
-
permuta.misc.misc.
binary_search
(a, x)¶
-
permuta.misc.misc.
choose
(l, k)¶
-
permuta.misc.misc.
flatten
(lst)¶
-
permuta.misc.misc.
subsets
(elems)¶
permuta.misc.ordered_set_partitions module¶
-
permuta.misc.ordered_set_partitions.
helper
(lst, parts)¶
-
permuta.misc.ordered_set_partitions.
ordered_set_partitions
(lst, parts, CACHE={})¶
permuta.misc.progressbar module¶
permuta.misc.ranges module¶
-
permuta.misc.ranges.
cyclic_range
(start, end, restart)¶ Yields start,...,end-1,restart,...,start-1.
-
permuta.misc.ranges.
modulo_range
(start, modulo)¶ Yields start,...,modulo-1,0,...,start-1.
permuta.misc.triemap module¶
permuta.misc.union_find module¶
-
class
permuta.misc.union_find.
UnionFind
(n=0)¶ Bases:
object
A collection of distjoint sets.
-
__init__
(n=0)¶ Creates a collection of n disjoint unit sets.
-
add
()¶ Add a unit set containing a new element to the collection, and return the identifier of the new element.
-
find
(x)¶ Return the identifier of a representative element for the set containing the element with identifier x.
-
size
(x)¶ Return the number of elements in the set containing the element with identifier x.
-
unite
(x, y)¶ Unite the two sets containing the elements with identifiers x and y, respectively.
-