Lookup Tables

Simulations tend to require a large quantity of data to run. vivarium provides the Lookup Table 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.manager.LookupTableManager[source]

Manages complex data in the simulation.

Notes

Client code should never access this class directly. Use lookup on the builder during setup to get references to LookupTable objects.

CONFIGURATION_DEFAULTS: Dict[str, Any] = {'interpolation': {'extrapolate': True, 'order': 0, 'validate': True}}

A dictionary containing the defaults for any configurations managed by this manager. An empty dictionary indicates no managed configurations.

property name: str
setup(builder)[source]
Parameters:

builder (Builder) –

Return type:

None

build_table(data, key_columns, parameter_columns, value_columns)[source]

Construct a lookup table from input data.

Parameters:
Return type:

LookupTable

class vivarium.framework.lookup.manager.LookupTableInterface(manager)[source]

The lookup table management system.

Simulations tend to require a large quantity of data to run. vivarium provides the Lookup Table abstraction to ensure that accurate data can be retrieved when it’s needed.

For more information, see here.

Parameters:

manager (LookupTableManager) –

build_table(data, key_columns=(), parameter_columns=(), value_columns=())[source]

Construct a LookupTable from input data.

If data is a pandas.DataFrame, an interpolation function of the order specified in the simulation configuration will be calculated for each permutation of the set of key_columns. The columns in parameter_columns will be used as parameters for the interpolation functions which will estimate all remaining columns in the table.

If data is a number, time, list, or tuple, a scalar table will be constructed with the values in data as the values in each column of the table, named according to value_columns.

Parameters:
  • data (Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]) – The source data which will be used to build the resulting Lookup Table.

  • key_columns (List[str] | Tuple[str, ...]) – Columns used to select between interpolation functions. These should be the non-continuous variables in the data. For example ‘sex’ in data about a population.

  • parameter_columns (List[str] | Tuple[str, ...]) – The columns which contain the parameters to the interpolation functions. These should be the continuous variables. For example ‘age’ in data about a population.

  • value_columns (List[str] | Tuple[str, ...]) – The data columns that will be in the resulting LookupTable. Columns to be interpolated over if interpolation or the names of the columns in the scalar table.

Return type:

LookupTable

vivarium.framework.lookup.manager.validate_build_table_parameters(data, key_columns, parameter_columns, value_columns)[source]

Makes sure the data format agrees with the provided column layout.

Parameters:
Return type:

None