Skip to content

testsuite.compare

Comparison of a simulation with the expected results of a case.

The SBML test suite accepts a value when |value - expected| <= absolute + relative * |expected| at every time point, with the tolerances of the case; the special values inf, -inf and nan match only themselves. Species are expected either as amounts or as concentrations (the amount and concentration lists of the settings); a converted model carries every species in one quantity, so the columns are converted with the compartment before the comparison.

VariableComparison dataclass

VariableComparison(variable, max_error, max_excess, passed)

Result of one variable.

Comparison dataclass

Comparison(variables, passed, message)

Result of a case: every variable and the verdict.

max_excess property

max_excess

Largest excess over the tolerance, negative when everything passes.

nan for a structural failure without variables.

CompareError

Bases: ValueError

A result cannot be brought into the requested quantity.

compare

compare(result, expected, settings)

Compare a simulation with the expected results.

Parameters:

Name Type Description Default
result DataFrame

timecourse with a time column and the settings variables.

required
expected DataFrame

expected timecourse of the case.

required
settings Settings

settings of the case (variables and tolerances).

required

Returns:

Type Description
Comparison

The comparison; passed when every variable is within the tolerance

Comparison

at every time point.

is_informative

is_informative(expected, settings)

Whether the expected results move more than the tolerance band.

A case whose expected frame is (numerically) constant for every variable passes the comparison trivially no matter what the converters do; this flags that so it can be told apart from a genuine check.

Parameters:

Name Type Description Default
expected DataFrame

the expected frame, i.e. the case's expected results or, when there are none, the roadrunner simulation of the original model.

required
settings Settings

settings of the case (variables and tolerances).

required

Returns:

Type Description
bool

True when at least one settings variable present in expected moves,

bool

between the minimum and maximum of its finite values, by more than

bool

absolute + relative * max(|value|).

species_quantities

species_quantities(model)

Quantity of the species variables of a converted model.

Parameters:

Name Type Description Default
model Model

the original SBML model.

required

Returns:

Type Description
dict[str, tuple[bool, str]]

Species id to (has only substance units, compartment id): the

dict[str, tuple[bool, str]]

converted variable is an amount when the flag is set, else a

dict[str, tuple[bool, str]]

concentration.

requested_frame

requested_frame(df, quantities, settings)

The settings variables in the quantity the case expects.

Parameters:

Name Type Description Default
df DataFrame

timecourse of a converted model (every variable a column, including the compartments).

required
quantities dict[str, tuple[bool, str]]

result of species_quantities.

required
settings Settings

settings of the case.

required

Returns:

Type Description
DataFrame

time and the settings variables, species converted between amount

DataFrame

and concentration with their compartment column when needed. A

DataFrame

variable missing in df is left out (the comparison reports it).

Raises:

Type Description
CompareError

df has no time column or duplicate column names (e.g. a parameter with the id time next to roadrunner's time), or a variable needs converting between amount and concentration and its compartment column is missing from df.

strip_brackets

strip_brackets(df)

Rename roadrunner's [S] concentration columns to S.