API Reference¶
- exhaust.space(fn, verbose=False)¶
Return an iterable that generates values from
fn
fully exhausting the state space.During iteration, the function
fn
is called repeatedly with aState
instance as only argument.
- class exhaust.State(verbose=False)¶
An instance of this class is passed as argument to the function passed to
space()
.- choice(seq)¶
Return an element from the non-empty sequence
seq
.This is the equivalent of
random.choice()
.- Parameters
seq (
Iterable
[~T]) – The sequence from which to choose from.- Raises
IndexError – if
seq
is empty.- Return type
~T
- choices(population, *, k=1)¶
Return a
k
sized list of elements chosen from thepopulation
with replacement.This is the equivalent of
random.choices()
, minus theweights
andcum_weights
arguments.- Parameters
- Raises
IndexError – if
population
is empty.- Return type
List
[~T]
- randint(a, b)¶
Return an integer
N
such thata <= N <= b
. Alias forrandrange(a, b+1)
.This is the equivalent of
random.randint()
.- Parameters
- Raises
ValueError – if the range is empty.
- Return type
- randrange(stop: int) int ¶
- randrange(start: int, stop: int, step: Optional[int] = None) int
Return an element from
range(start, stop, step)
.This is the equivalent of
random.randrange()
.- Parameters
start – The start of the range.
stop – The end of the range (exclusive).
step – The step size.
- Raises
ValueError – if the range is empty.
- Return type
- sample(population, k, *, counts=None)¶
Return a
k
sized list of unique elements chosen from thepopulation
.This is the equivalent of
random.sample()
.