Vivarium Testing Utilities
Utility functions and classes to make testing vivarium
components easier.
- class vivarium.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.
- property columns_created: List[str]
Provides names of columns created by the component.
- Returns:
Names of the columns created by this component, or an empty list if
none.
- 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.
- on_initialize_simulants(pop_data)[source]
Method that vivarium will run during simulant initialization.
This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the simulant initialization phase.
- Return type:
- Parameters:
pop_data (SimulantData) – The data associated with the simulants being initialized.
- Return type:
None
- class vivarium.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.
- on_initialize_simulants(pop_data)[source]
Method that vivarium will run during simulant initialization.
This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the simulant initialization phase.
- Return type:
- Parameters:
pop_data (SimulantData) – The data associated with the simulants being initialized.
- Return type:
None
- vivarium.testing_utilities.build_table(value, parameter_columns={'age': (0, 125), 'year': (1990, 2020)}, key_columns={'sex': ('Female', 'Male')}, value_columns=['value'])[source]
- Return type:
- Parameters:
value (Any) – Value(s) to put in the value columns of a lookup table.
parameter_columns (Dict) – 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) – 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) – 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.