domains¶
The domain of a quantity of a model, from distrib.
A domain is the interval of values a model accepts for one of its quantities: a
fraction lies in [0, 1], a volume or a rate in [0, inf). A model states it
as an uncertainty of the SBML package distrib named DOMAIN whose single
UncertSpan is of the type range, on the parameter, compartment or species it
constrains; the factory of a model writes it (the PBPK library of pkpdsim writes
one for every constant, compartment and species of its models), domain_of and
domains read it back.
A domain also states which values of its interval the model accepts (Values):
every real number, the integers of the interval (an index, a count or a class)
or the two truth values of a flag. An integer or boolean domain states it with a
further child of the uncertainty, an externalParameter whose definitionURL is
the XSD datatype of the value set; a continuous domain states none, so a document
written before the value sets keeps its meaning.
The domain of a quantity is not the uncertainty of a value: the confidence
interval of a literature value and the distribution of a fitted parameter
(sbmlsim.distrib, sbmlsim.simulation.sampling.parameter_distributions) are
statements of their own, in their own uncertainty elements, which sit next to the
domain on the same element. The reader finds the domain by its name and the type
of its span and ignores every other uncertainty.
A model which states no domain says nothing about its quantities: domain_of
gives None, domains leaves the quantity out, and there is no default. What
reads a domain is the sampler, which keeps the values of a design inside it
(sbmlsim.simulation.sampling.local clamps the steps of a local design).
VALUE_SET_URL
module-attribute
¶
VALUE_SET_URL = {
Values.INTEGER: "http://www.w3.org/2001/XMLSchema#integer",
Values.BOOLEAN: "http://www.w3.org/2001/XMLSchema#boolean",
}
The definitionURL which states a value set, the XSD datatype of the values;
CONTINUOUS has none, a continuous domain states no such child.
Values
¶
Bases: StrEnum
The values inside the interval of a domain which a model accepts.
A flag is kept apart from an integer domain of the same interval on purpose: a tool which offers a flag as a checkbox and a class as a spinner has to know which of the two it has.
CONTINUOUS
class-attribute
instance-attribute
¶
Every real number of the interval, the default.
INTEGER
class-attribute
instance-attribute
¶
The integers of the interval: an index, a count, a stage or a class.
BOOLEAN
class-attribute
instance-attribute
¶
The integers 0 and 1 as the truth values: a flag which is off or on.
Domain
dataclass
¶
Domain(lower, upper, values=CONTINUOUS)
The closed interval of the accepted values of a quantity, a bound may be infinite.
Attributes:
| Name | Type | Description |
|---|---|---|
lower |
float
|
the lower bound. |
upper |
float
|
the upper bound. |
values |
Values
|
which values of the interval are accepted. |
clip
¶
Move a value or an interval which lies outside the domain onto it.
An interval has each of its bounds limited to the interval of the
domain, each on its own side, so an interval whose bounds are reversed
is returned as it is; a caller may rely on that
(sampling.set_relative_bounds builds an inverted pair for a negative
value on purpose and sampling.distributions refuses it by name
later). An interval of an integer or boolean domain which is not
reversed has each finite bound widened onto a value the domain
contains, the lower one down and the upper one up, which is logged: a
fractional span of a switch or of a count is a modelling error, not a
rounding one. A single value is limited to the interval and, for an
integer or boolean domain, rounded to the nearest integer the domain
contains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower
|
float
|
the value, or the lower bound of an interval. |
required |
upper
|
float | None
|
the upper bound of the interval, |
None
|
Returns:
| Type | Description |
|---|---|
tuple[float, float] | float
|
The interval with each bound limited to the domain, or the value |
tuple[float, float] | float
|
limited to it. An infinite value is returned at the infinite bound |
tuple[float, float] | float
|
of a domain which has one, so the result lies inside the interval |
tuple[float, float] | float
|
but is not necessarily a value |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a single value is not a number. |
contains
¶
Get whether a value is one the domain accepts, the bounds included.
An integer or boolean domain accepts only an integral value. No domain
accepts a value which is not finite: an infinite bound is open
([0, inf)), so inf is no value of it, and nan is no number at all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
the value. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the domain accepts it. |
domain_of
¶
Read the domain of an element of a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbase
|
SBase
|
a parameter, compartment or species. |
required |
Returns:
| Type | Description |
|---|---|
Domain | None
|
The domain, or |
Domain | None
|
set reads as the infinity on its side. |
domains
¶
Read the domains of the parameters, compartments and species of a model.
Only the top-level model is read, the elements of a submodel of a
hierarchical document are not in the result; the flat SBML of a model, which
a simulation runs (sbmlsim.model.model_sbml.SBMLModel.sbml), has them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml
|
str | Path
|
the SBML of the model itself or the path of its file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Domain]
|
The domain of every element which states one, by its id; empty for a |
dict[str, Domain]
|
model which states none, and the silence about an element is no |
dict[str, Domain]
|
statement that it has no domain. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
for a path which is no file. |
ValueError
|
for an SBML which is no model. |