observables
The observables of a run, compiled against its models and evaluated.
compile_observables orders the observables of a run by what they read,
checks every symbol against the model, derives the kind (a timecourse or a
value per simulation) and the unit of every observable and gives an
ObservableGraph: frozen, picklable and free of pint, so the chunks of a scan
carry it into the workers. A run without observables has the graph of the
selections of its model, each a timecourse of its own name (identity_graph).
ObservableGraph.evaluate computes the observables on the native solutions
of the points of a chunk, stacked into arrays (n_points, n_rows) padded
with NaN: a timecourse is such an array, a value per simulation an array
(n_points, 1) while the graph is evaluated and (n_points,) in its result.
The observables are evaluated before any interpolation onto a grid, so the
reductions and the analysis of a PK observable are as exact as the output of
the simulation. An observable which no kept observable needs is not
evaluated, and the selections only it reads are not selected.
FormulaNode
dataclass
¶
A Formula observable compiled against the models of a run.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the id of the observable. |
formula |
str
|
the formula. |
kind |
ObservableKind
|
a timecourse or a value per simulation. |
factor |
float
|
the factor from the derived unit of the formula into its
declared unit, |
CustomNode
dataclass
¶
A Custom observable compiled against the models of a run.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the id of the observable. |
function |
Callable[[ndarray, dict[str, Any]], Any]
|
the function of a module. |
kind |
ObservableKind
|
a timecourse or a value per simulation. |
symbols |
tuple[str, ...]
|
what it reads. |
ObservableError
¶
Bases: RuntimeError
An observable failed on the points of a chunk.
Attributes:
| Name | Type | Description |
|---|---|---|
row |
the row of the point which failed in the arrays of the chunk,
|
|
message |
the error. |
Create the error, the arguments pickle.
ObservableGraph
dataclass
¶
The observables of a run, see the module.
Attributes:
| Name | Type | Description |
|---|---|---|
nodes |
tuple[Node, ...]
|
the observables the kept ones need, in the order of what they read. |
selections |
tuple[str, ...]
|
the selections of roadrunner the nodes read, without
|
kinds |
dict[str, ObservableKind]
|
the kind of every symbol and output: |
units |
dict[str, str]
|
the unit of every symbol and output, for a formula the declared
unit if it has one (the values of |
keep |
tuple[str, ...]
|
the outputs of the result, in order. |
outputs |
tuple[str, ...]
|
every output: the ids of the formulas and customs and the parameters of the PK observables; the selections without observables. |
doses |
tuple[str, ...]
|
the dose targets of the PK observables the run evaluates, whose units the models of a run share. |
evaluate
¶
Evaluate the observables on the points of a chunk, see the module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
ndarray
|
the time points |
required |
columns
|
Mapping[str, ndarray]
|
the selections, arrays of the shape of |
required |
plans
|
Sequence[Plan]
|
the plan of every point, with its values, which gives the
doses of the PK observables and the resolution of the time
which |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
The kept outputs: a timecourse |
dict[str, ndarray]
|
simulation |
Raises:
| Type | Description |
|---|---|
ObservableError
|
if an observable fails for a point or for all. |
identity_graph
¶
Get the graph of a run without observables.
Every selection is a timecourse of its own name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selections
|
Sequence[str]
|
the selections, without |
required |
units
|
Mapping[str, str] | None
|
the unit of the time and of every selection, |
None
|
keep
|
Sequence[str] | None
|
the selections of the result, every one by default. |
None
|
Returns:
| Type | Description |
|---|---|
ObservableGraph
|
The graph. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if |
compile_observables
¶
Compile the observables of a run against its first model, see the module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observables
|
Sequence[Observable] | None
|
the observables; |
required |
model
|
RoadrunnerSBMLModel
|
the loaded model, whose selections and units they read. |
required |
keep
|
Sequence[str] | None
|
the outputs of the result, every output by default; the id of a PK observable keeps all its parameters, a selection of the model is kept as a timecourse of its own name next to the observables. |
None
|
plans
|
Sequence[Plan]
|
the plans of the run, each with the values of a point, whose dosing decides the parameters of the PK observables. |
()
|
Returns:
| Type | Description |
|---|---|
ObservableGraph
|
The graph. |
Raises:
| Type | Description |
|---|---|
TypeError
|
if the observables are no sequence of observables or |
ValueError
|
for two observables of one id; an id which is a selection
of the model; a symbol which is neither an observable nor a
selection; a cycle; a time of |
A declared unit is the unit of the observable: the values are converted when the formula is evaluated and the observables which read it see them in that unit. A formula which adds units of one dimension at different scales is refused, but a comparison or a piecewise, which pint cannot evaluate, is not checked for mixed scales.