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[List | Mapping, int] [source]#
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)[source]#
Bases:
Iterator
[Simulation
]Wraps a list of simulations with iterator that always provides parent experiment.
- __init__(lst, parent: IEntity)[source]#
Initializes the ExperimentParentIterator.
- Parameters:
lst – List of items(simulations) to iterator over
parent – Parent of items(Experiment)
- append(item: Simulation)[source]#
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: List[Simulation] | TemplatedSimulations)[source]#
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)[source]#
Bases:
Iterator
Iterator that counts upward forever.