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.engine simulations, 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 lookup attribute on the Builder class during setup.

Parameters:
RESOURCE_TYPE = 'lookup_table'

The type of the resource.

property key_columns: list[str]
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 return_type: type[T]

The type 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:

None

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 data would change the return type or value columns of this lookup table.

static get_name(component_name, table_name)[source]

Get the fully qualified name for a lookup table.

Return type:

str

Parameters:
  • component_name (str) – Name of the component the lookup table belongs to.

  • table_name (str) – Name of the lookup table.

Returns:

Fully qualified name for the lookup table.