Interpolation
Provides interpolation algorithms across tabular data for vivarium
simulations.
- class vivarium.framework.lookup.interpolation.Interpolation(data, categorical_parameters, continuous_parameters, value_columns, order, extrapolate, validate)[source]
A callable that returns the result of an interpolation function over input data.
- Parameters:
- data
The data from which to build the interpolation. Contains categorical_parameters and continuous_parameters.
- categorical_parameters
Column names to be used as categorical parameters in Interpolation to select between interpolation functions.
- continuous_parameters
Column names to be used as continuous parameters in Interpolation. If bin edges, should be of the form (column name used in call, column name for left bin edge, column name for right bin edge).
- order
Order of interpolation.
- vivarium.framework.lookup.interpolation.validate_parameters(data, categorical_parameters, continuous_parameters, value_columns)[source]
- vivarium.framework.lookup.interpolation.validate_call_data(data, categorical_parameters, continuous_parameters)[source]
- vivarium.framework.lookup.interpolation.check_data_complete(data, continuous_parameters)[source]
Check that data is complete for interpolation.
For any parameters specified with edges, make sure edges don’t overlap and don’t have any gaps. Assumes that edges are specified with ends and starts overlapping (but one exclusive and the other inclusive) so can check that end of previous == start of current.
If multiple parameters, make sure all combinations of parameters are present in data.
Requires that bins of each parameter be standard across all values of other parameters, i.e., all bins for one parameter when de-duplicated should cover a continuous range of that parameter with no overlaps or gaps and the range covered should be the same for all combinations of other parameter values.
- Return type:
- Raises:
ValueError – If there are missing values for every combinations of continuous parameters.
ValueError – If the parameter data contains overlaps.
NotImplementedError – If a parameter contains non-continuous bins.
- class vivarium.framework.lookup.interpolation.Order0Interp(data, continuous_parameters, value_columns, extrapolate, validate)[source]
A callable that returns the result of order 0 interpolation over input data.
- Parameters:
- data
The data from which to build the interpolation.
- value_columns
Columns to be interpolated.
- extrapolate
Whether or not to extrapolate beyond the edge of supplied bins.
- parameter_bins
A dictionary where they keys are a tuple of the form (column name used in call, column name for left bin edge, column name for right bin edge) and the values are dictionaries of the form {“bins”: [ordered left edges of bins], “max”: max right edge (used when extrapolation not allowed)}.