# Multi-model functions¶

The module myokit.lib.multi contains functions for working with multiple Myokit models.

myokit.lib.multi.binding(model, binding)

Returns the variable bound to binding from the given myokit.Model model.

The method will raise a myokit.IncompatibleModelError if no such variable is found.

myokit.lib.multi.iterdir(path, guarantee_model_names=True)

Iterates over a directory yielding tuples (model, protocol) where model is a myokit.Model and protocol is a myokit.Protocol.

Depending on the contents of the found files, some entries might not have a protocol. Files without a model are skipped.

The results will be yielded ordered by filename. The method does not descend into child directories.

If guarantee_model_names is True (default), models that do not specify a name meta-attribute will be given their filename as name. This ensures every model read by this method has a name meta-property.

myokit.lib.multi.label(model, label)

Returns the variable labelled label from the given myokit.Model model.

The method will raise a myokit.IncompatibleModelError if no such variable is found.

myokit.lib.multi.scandir(path)

Scans a directory using iterdir() and returns a list of myokit.Model objects and a list of myokit.Protocol objects. The models (and corresponding protocols) will be ordered by model name.

myokit.lib.multi.time(model)

Returns the time variable from the given myokit.Model model.

The method will raise a myokit.IncompatibleModelError if no time variable is found.

myokit.lib.multi.unit(variable, unit)

Checks if the given variable’s unit can be converted into units unit and, if so, returns the appropriate conversion factor. If not, a myokit.IncompatibleModelError is raised.

Example:

>>> import myokit
>>> import myokit.lib.multi as multi