idmtools.utils.collections module¶
utilities for collections.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- idmtools.utils.collections.cut_iterable_to(obj: Iterable, to: int) Tuple[Union[List, Mapping], int] ¶
Cut an iterable to a certain length.
- Parameters:
obj – The iterable to cut.
to – The number of elements to return.
- Returns:
A list or dictionary (depending on the type of object) of elements and the remaining elements in the original list or dictionary.
- class idmtools.utils.collections.ExperimentParentIterator(lst, parent: IEntity)¶
Bases:
Iterator
[Simulation
]Wraps a list of simulations with iterator that always provides parent experiment.
- __init__(lst, parent: IEntity)¶
Initializes the ExperimentParentIterator.
- Parameters:
lst – List of items(simulations) to iterator over
parent – Parent of items(Experiment)
- append(item: Simulation)¶
Adds a simulation to an object.
- Parameters:
item – Item to add
- Returns:
None
- Raises:
ValueError when we cannot append because the item is not a simulation or our underlying object doesn't support appending –
- extend(item: Union[List[Simulation], TemplatedSimulations])¶
Extends object.
- Parameters:
item – Item to extend
- Returns:
None
- Raises:
ValueError when the underlying data object doesn't supporting adding additional item –
- class idmtools.utils.collections.ResetGenerator(generator_init)¶
Bases:
Iterator
Iterator that counts upward forever.
- __init__(generator_init)¶
Initialize the ResetGenerator from generator_init.
Creates a copy of the generator using tee.
- Parameters:
generator_init – Initialize iterator/generator to copy
- next_gen()¶
The original generator/iterator.
- Returns:
original generator/iterator.