Exceptions

Myokit tries to raise errors in a sensible manner. The following classes are used.

Base classes

class myokit.MyokitError(message)

Extends: Exception

Base class for all exceptions specific to Myokit.

Note that myokit classes and functions may raise any type of exception, for example a :class:KeyError or a ValueError. Only new classes of exception defined by Myokit will extend this base class.

class myokit.IntegrityError(message, token=None)

Extends: myokit.MyokitError

Raised if an integrity error is found in a model.

The error message is stored in the property message. An optional parser token may be obtained with token().

token()

Returns a parser token associated with this error, or None if no such token was given.

Inheriting classes

class myokit.CompilationError(message)

Extends: myokit.MyokitError

Raised if an auto-compiling class fails to compile. Catching one of these is usually a good excuses to email the developers ;-)

class myokit.CyclicalDependencyError(cycle)

Extends: myokit.IntegrityError

Raised when an variables depend on each other in a cyclical manner.

The first argument cycle must be a sequence containing the Variable objects in the cycle.

class myokit.DataBlockReadError(message)

Extends: myokit.MyokitError.

Raised when an error is encountered while reading a myokit.DataBlock1d or myokit.DataBlock2d.

class myokit.DataLogReadError(message)

Extends: myokit.MyokitError.

Raised when an error is encountered while reading a myokit.DataLog.

class myokit.DuplicateName(message)

Extends: myokit.MyokitError

Raised when an attempt is made to add a component or variable with a name that is already in use within the relevant scope.

class myokit.DuplicateFunctionName(message)

Extends: myokit.MyokitError

Raised when an attempt is made to add a user function to a model when a function with the same name and number of arguments already exists.

class myokit.DuplicateFunctionArgument(message)

Extends: myokit.MyokitError

Raised when an attempt is made to define a user function with duplicate argument names.

class myokit.ExportError(message, exporter)

Extends: myokit.MyokitError.

Raised when an export to another format fails.

Arguments:

message
A helpful error message
exporter
A myokit.formats.Exporter object that can be used to generate log output.
log()

Returns logged exporter output.

class myokit.FindNanError(message)

Extends: myokit.MyokitError

Raised by some simulations when a search for the origins of a numerical error has failed.

class myokit.GenerationError(message)

Extends: myokit.MyokitError

Raised by simulation engines and other auto-compiled classes if code generation fails.

class myokit.IllegalAliasError(message)

Extends: myokit.MyokitError

Raised when an attempt is made to add an alias in an invalid manner.

class myokit.IllegalReferenceError(reference, owner, extra_message=None, token=None)

Extends: myokit.IntegrityError

Raised when a reference is found to a variable reference that isn’t accessible from the owning variable owner‘s scope.

class myokit.ImportError(message)

Extends: myokit.MyokitError.

Raised when an import from another format fails.

class myokit.IncompatibleModelError(name, message)

Raised if a model is not compatible with some requirement.

class myokit.IncompatibleUnitError(message)

Extends: myokit.MyokitError

Raised when a unit incompatibility is detected.

class myokit.InvalidBindingError(message, token=None)

Extends: myokit.IntegrityError

Raised when an invalid binding is made.

class myokit.InvalidDataLogError(message)

Extends: myokit.MyokitError.

Raised during validation of a myokit.DataLog if a violation is found.

class myokit.InvalidFunction(message)

Extends: myokit.MyokitError

Raised when a function is declared with invalid arguments or an invalid expression.

class myokit.InvalidLabelError(message, token=None)

Extends: myokit.IntegrityError

Raised when an invalid label is set.

class myokit.InvalidMetaDataNameError(message)

Extends: myokit.MyokitError

Raised when an attempt is made to add a meta data property with a name that violates that the myokit naming rules for meta data properties.

class myokit.InvalidNameError(message)

Extends: myokit.MyokitError

Raised when an attempt is made to add a component or variable with a name that violates the myokit naming rules.

class myokit.MissingRhsError(var)

Extends: myokit.IntegrityError

Raised when a variable was declared without a defining right-hand side equation.

The first argument var should be the invalid variable.

class myokit.MissingTimeVariableError

Extends: myokit.IntegrityError

Raised when no variable was bound to time.

class myokit.NonLiteralValueError(message, token=None)

Extends: myokit.IntegrityError

Raised when a literal value is required but not given.

class myokit.NumericalError(message)

Extends: myokit.MyokitError

Raised when a numerical error occurs during the evaluation of a myokit Expression.

class myokit.ParseError(name, line, char, desc=None, cause=None)

Extends: myokit.MyokitError

Raised if an error is encountered during a parsing operation.

A ParseError has five attributes:

name
A short name describing the error
line
The line the error occurred on (integer, first line is one)
char
The character the error ocurred on (integer, first char is zero)
desc
A more detailed description of the error (optional)
cause
Another exception that triggered this exception (or None).
class myokit.ProtocolEventError(message)

Extends: myokit.MyokitError

Raised when a ProtocolEvent is created with invalid parameters.

class myokit.ProtocolParseError(name, line, char, desc=None, cause=None)

Extends: ParseError

Raised when protocol parsing fails.

class myokit.SectionNotFoundError(message)

Extends: myokit.MyokitError

Raised if a section should be present in a file but is not.

class myokit.SimulationError(message)

Extends: myokit.MyokitError

Raised when a numerical error occurred during a simulation. Contains a detailed error message.

class myokit.SimulationCancelledError(message='Operation cancelled by user.')

Extends: MyokitError

Raised when a user terminates a simulation.

class myokit.SimultaneousProtocolEventError(message)

Extends: MyokitError

Raised if two events in a protocol happen at the same time. Raised when creating a protocol or when running one.

class myokit.UnresolvedReferenceError(reference, extra_message=None, token=None)

Extends: myokit.IntegrityError

Raised when a reference to a variable cannot be resolved.

class myokit.UnusedVariableError(var)

Extends: myokit.IntegrityError

Raised when an unused variable is found.

The unused variable must be passed in as the first argument var.