parasweep.namers module¶
Namers for generating simulation IDs.
-
class
parasweep.namers.
Namer
[source]¶ Bases:
abc.ABC
Abstract class for assigning simulation IDs to simulation.
Only the
next
method has to be implemented.
-
class
parasweep.namers.
SequentialNamer
(zfill=None, start_at=0)[source]¶ Bases:
parasweep.namers.Namer
Name simulations with consecutive numbers and leading zeros.
Parameters: - zfill (None or int, optional) – If provided, sets the width to which the name string is to be padded with zeros.
- start_at (int, optional) – Sets the integer to start at in the sequential naming.
Examples
>>> counter = SequentialNamer() >>> counter.start(length=11) >>> counter.generate_id({'key1': 'value1'}, '') '00' >>> counter.generate_id({'key2': 'value2'}, '') '01' >>> counter.start(length=2) >>> counter.generate_id({'key1': 'value1'}, 'sweep_id') 'sweep_id_0'
-
class
parasweep.namers.
HashNamer
(hash_length=8)[source]¶ Bases:
parasweep.namers.Namer
Name simulations using hashing.
Parameters: hash_length (int, optional) – How many hexadecimal numbers to truncate the hash to. 6 by default. Examples
>>> namer = HashNamer() >>> namer.generate_id({'key1': 'value1'}, '') '31fc462e' >>> namer.generate_id({'key2': 'value2'}, '') '9970c8f5'
-
class
parasweep.namers.
SetNamer
(names)[source]¶ Bases:
parasweep.namers.Namer
Name simulations consecutively with a provided iterable.
Parameters: names (Iterable[str]) – The sequence of names to assign to consecutive simulations. Examples
>>> namer = SetNamer(['name1', 'name2']) >>> namer.generate_id({'key1': 'value1'}, '') 'name1' >>> namer.generate_id({'key2': 'value2'}, '') 'name2'