emulsim.elements.base module

Module defining the abstract base class of elements.

ArrayElementBase

Element storing data in a numpy array.

ArrayCollectionElementBase

Element storing data in multiple numpy array.

ObjectElementBase

Element storing data in a python object.

DictElementBase

Element storing data in a dictionary of states.

The inheritance diagram reads

digraph inheritancecbb2bfb902 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ArrayCollectionElementBase" [URL="#emulsim.elements.base.ArrayCollectionElementBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Element storing data in multiple numpy array."]; "_ElementBase" -> "ArrayCollectionElementBase" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ArrayElementBase" [URL="#emulsim.elements.base.ArrayElementBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Element storing data in a numpy array."]; "_ElementBase" -> "ArrayElementBase" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ObjectElementBase" [URL="#emulsim.elements.base.ObjectElementBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Element storing data in a python object."]; "_ElementBase" -> "ObjectElementBase" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Parameterized" [URL="https://py-modelrunner.readthedocs.io/en/latest/packages/modelrunner.model.parameters.html#modelrunner.model.parameters.Parameterized",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A mixin that manages the parameters of a class."]; "_ElementBase" [URL="#emulsim.elements.base._ElementBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="(private) base class for representing simulation element."]; "Parameterized" -> "_ElementBase" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class _ElementBase(data: Any, parameters: dict[str, Any] | None = None)[source]

(private) base class for representing simulation element.

Elements are generally characterized by a data attribute, which contains information about all degrees of freedom, and parameters, which contain additional information in form of a python dictionary. While the parameters are managed by the mixin Parameterized, the form of the data depends on the element and must thus be defined by concrete classes. These classes need to define at least to access points into the data: An attribute data, which is the main access point for normal python code, and an attribute _data_numba, which is used by numba to access and alter the underlying data. In many cases, these two attributes can point to the same object, e.g., a ndarray.

Parameters Dictionary:
  • plot_args: Extra arguments for plotting this element (default={})

Initialize the parameters of the object.

Parameters:
  • parameters (dict) – A dictionary of parameters to change the defaults. The allowed parameters can be obtained from get_parameters() or displayed by calling show_parameters().

  • strict (bool) – Flag indicating whether parameters are strictly interpreted. If True, only parameters listed in parameters_default can be set and their type will be enforced.

Parameters of _ElementBase:

plot_args

Extra arguments for plotting this element (Default value: {})

class ArrayCollectionElementBase(data: tuple[ndarray, ...] | None = None, parameters: dict[str, Any] | None = None)[source]

Bases: _ElementBase

Element storing data in multiple numpy array.

Parameters Dictionary:
  • plot_args: Extra arguments for plotting this element (default={})

Parameters:
  • data – The data describing the state

  • parameters – Additional parameters that affect the element

Parameters of ArrayCollectionElementBase:

plot_args

Extra arguments for plotting this element (Default value: {})

property degrees_of_freedom: int

the number of degrees of freedom for this element

Type:

int

class ArrayElementBase(data: ndarray | None = None, parameters: dict[str, Any] | None = None)[source]

Bases: _ElementBase

Element storing data in a numpy array.

Parameters Dictionary:
  • plot_args: Extra arguments for plotting this element (default={})

Parameters:
  • data – The data describing the state

  • parameters – Additional parameters that affect the element

Parameters of ArrayElementBase:

plot_args

Extra arguments for plotting this element (Default value: {})

property degrees_of_freedom: int

the number of degrees of freedom for this element

Type:

int

class DictElementBase(data: dict[str, _ElementBase] | None = None, parameters: dict[str, Any] | None = None)[source]

Bases: _ElementBase

Element storing data in a dictionary of states.

Parameters Dictionary:
  • plot_args: Extra arguments for plotting this element (default={})

Parameters:
  • data – The data describing the state

  • parameters – Additional parameters that affect the element

Parameters of DictElementBase:

plot_args

Extra arguments for plotting this element (Default value: {})

property degrees_of_freedom: int

the number of degrees of freedom for this element

Type:

int

class NoData[source]

Bases: object

Helper class that marks data omission.

class ObjectElementBase(data: Any, parameters: dict[str, Any] | None = None)[source]

Bases: _ElementBase

Element storing data in a python object.

Parameters Dictionary:
  • plot_args: Extra arguments for plotting this element (default={})

Initialize the parameters of the object.

Parameters:
  • parameters (dict) – A dictionary of parameters to change the defaults. The allowed parameters can be obtained from get_parameters() or displayed by calling show_parameters().

  • strict (bool) – Flag indicating whether parameters are strictly interpreted. If True, only parameters listed in parameters_default can be set and their type will be enforced.

Parameters of ObjectElementBase:

plot_args

Extra arguments for plotting this element (Default value: {})

property degrees_of_freedom: int

the number of degrees of freedom for this element

Type:

int