modelrunner.run.compatibility.version1 module

Contains code necessary for loading results from format version 1

class ArrayCollectionState[source]

Bases: StateBase

class ArrayState[source]

Bases: StateBase

class DictState[source]

Bases: StateBase

class NoData[source]

Bases: object

helper class that marks data omission

class ObjectState[source]

Bases: StateBase

class StateBase[source]

Bases: object

Base class for specifying the state of a simulation

A state contains values of all degrees of freedom of a physical system (called the data) and some additional information (called attributes). The data is mutable and often a numpy array or a collection of numpy arrays. Conversely, the attributes are stroed in a dictionary with immutable values. To allow flexible storage, we define the properties _state_data and _state_attributes, which by default return attributes and data directly, but may be overwritten to process the data before storage (e.g., by additional serialization).

classmethod from_data(attributes, data=<class 'modelrunner.run.compatibility.version1.NoData'>)[source]

create instance of any state class from attributes and data

Parameters:
  • attributes (dict) – Additional (unserialized) attributes

  • data – The data of the degerees of freedom of the physical system

Returns:

The object containing the given attributes and data

Return type:

TState

result_from_file_v1(store, *, label='data', **kwargs)[source]

load object from a file using format version 1

Parameters:
  • store (Path) – Path of file to read

  • fmt (str) – Explicit file format. Determined from store if omitted.

  • label (str) – Name of the node in which the data was stored. This applies to some hierarchical storage formats.

Return type:

Result