Exceptions

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

Base classes

class myokit.MyokitError(message)

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.

Extends: Exception

class myokit.IntegrityError(message, token=None)

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().

Extends: myokit.MyokitError

token()

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

Inheriting classes

class myokit.CompilationError(message)

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

Extends: myokit.MyokitError

class myokit.CyclicalDependencyError(cycle)

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.

Extends: myokit.IntegrityError

class myokit.DataBlockReadError(message)

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

Extends: myokit.MyokitError.

class myokit.DataLogReadError(message)

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

Extends: myokit.MyokitError.

class myokit.DuplicateName(message)

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

Extends: myokit.MyokitError.

class myokit.DuplicateFunctionName(message)

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.

Extends: myokit.MyokitError.

class myokit.DuplicateFunctionArgument(message)

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

Extends: myokit.MyokitError.

class myokit.ExportError(message)

Raised when an export to another format fails.

Extends: myokit.MyokitError.

class myokit.FindNanError(message)

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

Extends: myokit.MyokitError

class myokit.GenerationError(message)

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

Extends: myokit.MyokitError

class myokit.IllegalAliasError(message)

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

Extends: myokit.MyokitError

class myokit.IllegalReferenceError(reference, owner)

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

Extends: myokit.IntegrityError

class myokit.ImportError(message)

Raised when an import from another format fails.

Extends: myokit.MyokitError.

class myokit.IncompatibleModelError(name, message)

Raised if a model is not compatible with some requirement.

Extends: myokit.MyokitError.

class myokit.IncompatibleUnitError(message)

Raised when a unit incompatibility is detected.

Extends: myokit.MyokitError.

class myokit.InvalidBindingError(message, token=None)

Raised when an invalid binding is made.

Extends: myokit.IntegrityError

class myokit.InvalidDataLogError(message)

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

Extends: myokit.MyokitError.

class myokit.InvalidFunction(message)

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

Extends: myokit.MyokitError.

class myokit.InvalidLabelError(message, token=None)

Raised when an invalid label is set.

Extends: myokit.IntegrityError

class myokit.InvalidMetaDataNameError(message)

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.

Extends: myokit.MyokitError

class myokit.InvalidNameError(message)

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

Extends: myokit.MyokitError

class myokit.MissingRhsError(var)

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

The first argument var should be the invalid variable.

Extends: myokit.IntegrityError

class myokit.MissingTimeVariableError

Raised when no variable was bound to time.

Extends: myokit.IntegrityError

class myokit.NonLiteralValueError(message, token=None)

Raised when a literal value is required but not given.

Extends: myokit.IntegrityError

class myokit.NumericalError(message)

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

Extends: myokit.MyokitError

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

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.
cause
Another exception that triggered this exception (or None).

Extends: myokit.MyokitError

class myokit.ProtocolEventError(message)

Raised when a ProtocolEvent is created with invalid parameters.

Extends: myokit.MyokitError

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

Raised when protocol parsing fails.

Extends: ParseError

class myokit.SectionNotFoundError(message)

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

Extends: myokit.MyokitError

class myokit.SimulationError(message)

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

Extends: myokit.MyokitError

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

Raised when a user terminates a simulation.

Extends: myokit.MyokitError

class myokit.SimultaneousProtocolEventError(message)

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

Extends: myokit.MyokitError

class myokit.UnresolvedReferenceError(reference, extra_message=None)

Raised when a reference to a variable cannot be resolved.

Extends: myokit.IntegrityError

class myokit.UnusedVariableError(var)

Raised when an unused variable is found.

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

Extends: myokit.IntegrityError