Lookup Tables
Simulations tend to require a large quantity of data to run. vivarium.engine
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 simulants represented by
that index. See the lookup concept note for more.
- class vivarium.engine.framework.lookup.table.LookupTable(component, data, name, value_columns, manager, population_view)[source]
A callable that produces values for a population index.
In
vivarium.enginesimulations, 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, components can look parameter values up 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 parameter_columns: list[str]
The attribute names that are used as continuous parameters in lookup.
- property value_columns: pd.Index[Any]
The column names returned when calling this lookup table.
- property lookup_attributes: list[str]
The attribute pipelines used to lookup/interpolate values for this table.
- population_view: PopulationView
PopulationView to use to get attributes for interpolation or categorization.
- data: LookupTableData
The data this table will use to produce values.
- 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]
Replace the data this lookup table will return.
The new data must produce the same return type and value columns as the data passed at construction time.
- Return type:
- Parameters:
data (SupportsFloat | Timedelta | timedelta | Timestamp | datetime | str | DataFrame | Series | 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.
- Raises:
ValueError – If
datawould change the return type or value columns of this lookup table.