Equations¶
While the internal storage of equations may differ, when they are returned
equations are usually in the form of an Equation
object.
- class myokit.Equation(lhs, rhs)¶
Defines an equation: a statement that a left-hand side (LHS) is equal to a right-hand side (RHS) expression.
The sides of an equation are stored in the properties
lhs
andrhs
. Equations are immutable: once created, their LHS and RHS cannot be changed.Note: This is not a
myokit.Expression
, for that, seemyokit.Equal
.- clone(subst=None, expand=False, retain=None)¶
Clones this equation.
See
myokit.Expression.clone()
for details of the arguments.
- code()¶
Returns an
.mmt
representation of this equation.
- property lhs¶
This equations left-hand side expression.
- property rhs¶
This equations right-hand side expression.
Equation lists¶
When returning a list of equations, the EquationList
type is used. This
extends the python list
type with a number of specialized iterators.
- class myokit.EquationList(iterable=(), /)¶
An ordered list of
Equation
objects- append(object, /)¶
Append object to the end of the list.
- clear()¶
Remove all items from list.
- copy()¶
Return a shallow copy of the list.
- count(value, /)¶
Return number of occurrences of value.
- count_equations(const=None, inter=None, state=None, bound=None, deep=False)¶
Returns the number of equations matching the given criteria. See
equations()
for an explanation of the arguments.
- count_variables(const=None, inter=None, state=None, bound=None, deep=False)¶
Returns the number of variables matching the given criteria. See
variables()
for an explanation of the arguments.
- equations(const=None, inter=None, state=None, bound=None, deep=False)¶
Creates and returns a filtered iterator over the equations of this object’s variables.
The returned values can be filtered using the following arguments:
const=True|False|None
Set to
True
to return only constants’ equations.False
to exclude all constants and any other value to ignore this check.For a definition of “constant variable” see
variables()
.inter=True|False|None
Set to
True
to return only intermediary variables’ equations,False
to exclude all intermediary variables and any other value to ignore this check.For a definition of “intermediary variable” see
variables()
.state=True|False|None
Set to
True
to return only state variables’ equations,False
to exclude all state variables and any other value to ignore this check.bound=True|False|None
Set to
True
to return only bound variables’ equations,False
to exclude all bound variables and any other value to ignore this check.deep=True|False
(by default it’sFalse
)Set to
True
to include the equations of nested variables meeting all other criteria.
- extend(iterable, /)¶
Extend list by appending elements from the iterable.
- has_equations(const=None, inter=None, state=None, bound=None, deep=False)¶
Returns True if there are any equations that can be returned by calling :meth:
equations
with the same arguments.
- has_variable(name)¶
Returns True if the given name corresponds to a variable in this object. Accepts both single names
x
and qualified namesx.y
as input.This function performs the same search as
variable
, so in most cases it will be more efficient to callvariable()
in a try-catch block rather than checking for existence explicitly.
- has_variables(const=None, inter=None, state=None, bound=None, deep=False)¶
Returns True if there are any variables that can be returned by calling :meth:
variables
with the same arguments.
- index(value, start=0, stop=9223372036854775807, /)¶
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)¶
Insert object before index.
- pop(index=-1, /)¶
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)¶
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()¶
Reverse IN PLACE.
- sort(*, key=None, reverse=False)¶
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- var(name)¶
Searches for the given variable and returns it if found. Accepts both single names
x
and qualified namesx.y
as input.
- variables(const=None, inter=None, state=None, bound=None, deep=False, sort=False)¶
Creates and returns a filtered iterator over the contained variables.
The returned values can be filtered using the following arguments:
const=True|False|None
Constants are defined as variables that do not depend on state variables or derivatives. In other words, any variable whose value can be determined before starting an ODE solving routine.
Set to
True
to return only constants,False
to exclude all constants and any other value to ignore this check.inter=True|False|None
Intermediary variables are those variables that are not constant but are not part of the state. In other words, intermediary variables are the variables that need to be calculated at every step of an ODE solving routine before calculating the ODE derivatives and updating the state.
Set to
True
to return only intermediary variables,False
to exclude all intermediary variables and any other value to ignore this check.state=True|False|None
Set to True to return only state variables, False to exclude all state variables and any other value to ignore this check.
bound=True|False|None
Set to True to return only variables bound to an external value, False to exclude all bound variables and any other value to forgo this check.
deep=True|False
(by default it’sFalse
)Set to True to return nested variables meeting all other criteria.
sort=True|False
(by default it’sFalse
)Set to True to return the variables in a consistent order. (Note that this does _not_ mean alphabetical sorting of all variables, just that the order is consistent between calls!)