Lookup Tables
Simulations tend to require a large quantity of data to run. vivarium
provides the LookupTable abstraction to ensure that accurate data can
be retrieved when it’s needed. It’s a callable object that takes in a
population index and returns data specific to the individuals represented by
that index. See the lookup concept note for more.
- class vivarium.framework.lookup.table.LookupTable(component, data, name, value_columns, manager, population_view)[source]
A callable to produces values for a population index.
In
vivariumsimulations, the index is synonymous with the simulated population. The lookup system allows the user to provide different kinds of data and strategies for using that data. When the simulation is running, then, components can lookup parameter values based solely on the population index.Notes
These should not be created directly. Use the
lookupattribute on theBuilderclass during setup.- Parameters:
component (Component)
data (LookupTableData)
name (str)
manager (LookupTableManager)
population_view (PopulationView)
- RESOURCE_TYPE = 'lookup_table'
The type of the resource.
- property value_columns: list[str]
The name(s) of the column(s) in the data that will be returned by this lookup table.
- population_view: PopulationView
PopulationView to use to get attributes for interpolation or categorization.
- return_type: type[T]
The type of data returned by the lookup table (pd.Series or pd.DataFrame).
- data: LookupTableData
The data this table will use to produce values.
- key_columns: list[str]
Column names to be used as categorical parameters in Interpolation to select between interpolation functions.
- parameter_columns: list[str]
Column names to be used as continuous parameters in Interpolation.
- interpolation: Interpolation | None
Interpolation object to use when data is a DataFrame. Will be None if data is a scalar or list of scalars.
- set_data(data)[source]
Set the data and associated attributes for the lookup table.
This method is called during initialization and when updating the data of the lookup table. It is responsible for validating and setting the data. If the data is a DataFrame, it also sets the key_columns and parameter_columns attributes and initializes the Interpolation object.
- Return type:
- Parameters:
data (SupportsFloat | Timedelta | timedelta | Timestamp | datetime | DataFrame | list[SupportsFloat | Timedelta | timedelta | Timestamp | datetime] | tuple[SupportsFloat | Timedelta | timedelta | Timestamp | datetime, ...] | Mapping[str, list[SupportsFloat | Timedelta | timedelta | Timestamp | datetime] | list[str]]) – The data this table will use to produce values. Can be a scalar, list of scalars, or a pandas DataFrame.