Vivarium Testing Utilities
Utility functions and classes to make testing vivarium components easier.
- class vivarium.engine.testing_utilities.NonCRNTestPopulation[source]
- CONFIGURATION_DEFAULTS: dict[str, Any] = {'population': {'initialization_age_max': 100, 'initialization_age_min': 0, 'untracking_age': None}}
A dictionary containing the defaults for any configurations managed by this component. An empty dictionary indicates no managed configurations. Components will look for a
data_sourcesblock in this dictionary to build lookup tables automatically.
- setup(builder)[source]
Defines custom actions this component needs to run during the setup lifecycle phase.
This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the component. By default, it does nothing.
- initialize_population(pop_data)[source]
- Return type:
- Parameters:
pop_data (SimulantData)
- class vivarium.engine.testing_utilities.TestPopulation[source]
- setup(builder)[source]
Defines custom actions this component needs to run during the setup lifecycle phase.
This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the component. By default, it does nothing.
- initialize_population(pop_data)[source]
- Return type:
- Parameters:
pop_data (SimulantData)
- vivarium.engine.testing_utilities.build_table(value, parameter_columns={'age': (0, 125), 'year': (1990, 2020)}, key_columns={'sex': ('Female', 'Male')}, value_columns=['value'])[source]
- Return type:
DataFrame- Parameters:
value (Any) – Value(s) to put in the value columns of a lookup table.
parameter_columns (dict[str, Sequence[int]]) – A dictionary where the keys are parameter (continuous) columns of a lookup table and the values are tuple of the range (inclusive) for that column.
key_columns (dict[str, Sequence[Any]]) – A dictionary where the keys are key (categorical) columns of a lookup table and the values are a tuple of the categories for that column
value_columns (list[str]) – A list of value columns that will appear in the returned lookup table
- Returns:
A pandas dataframe that has the cartesian product of the range of all parameter columns and the values of the key columns.