opynsim.solvers#

Classes

ModelWarper(*args, **kwargs)

A solver that can warp a source opynsim.ModelSpecification.

class opynsim.solvers.ModelWarper(*args, **kwargs)#

Bases: object

A solver that can warp a source opynsim.ModelSpecification.

Instances of this class are usually constructed from data files (scaling documents) via from_xml().

__init__(self) None#

Constructs a blank ModelWarper that performs no warping operations (i.e. an identity warp).

from_xml(source: str | os.PathLike) solvers.ModelWarper#

Returns a ModelWarper parsed from an XML file (source).

Parameters:

source – Filesystem path to a <ModelWarperV3Document> XML file (e.g. from OpenSim Creator’s model warper).

Returns:

A ModelWarper, initialized with the scaling steps and parameters defined in source.

Raises:

RuntimeError – If source cannot be found, read, or is invalid.

warp(
self,
model_specification: ModelSpecification,
) ModelSpecification#

Returns a warped copy of model_specification.

Parameters:

model_specification – An opynsim.ModelSpecification that will be copied and warped by the model warper. Must be compatible with the model warping pipeline that the model warper executes.

Returns:

An opynsim.ModelSpecification with all warping (scaling) steps applied to it. For performance reasons, the warper may produce resources that are stored in-memory. Use opynsim.ModelSpecification.flush_in_memory_resources_to() to flush those resources to disk, if you need to save those resources.

Raises:

RuntimeError – If model_specification cannot be warped by this model warper’s warping pipeline.