sbmlsim.units

Manage units and units conversions.

Used for model and data unit conversions.

Module Contents

Classes

UnitsInformation

Storage of units information.

Units

Units class.

Attributes

logger

UdictType

ureg

sbmlsim.units.logger[source]
sbmlsim.units.UdictType[source]
class sbmlsim.units.UnitsInformation(udict, ureg, *args, **kwargs)[source]

Bases: collections.abc.MutableMapping

Storage of units information.

Used for models or datasets.

Parameters
  • udict (UdictType) –

  • ureg (pint.UnitRegistry) –

sbml_uids = ['ampere', 'farad', 'joule', 'lux', 'radian', 'volt', 'avogadro', 'gram', 'katal', 'metre',...[source]
__getitem__(self, key)[source]

Get item.

Parameters

key (str) –

Return type

str

__setitem__(self, key, value)[source]

Set item.

Parameters
  • key (str) –

  • value (str) –

Return type

None

__delitem__(self, key)[source]

Delete item.

Return type

None

__iter__(self)[source]

Iterate over keys.

Return type

Iterator[str]

__len__(self)[source]

Get length.

Return type

int

_keytransform(self, key)[source]

Transform key.

Parameters

key (str) –

Return type

str

__str__(self)[source]

Get string.

Return type

str

property Q_(self)[source]

Get quantity for generating quantities.

static from_sbml_path(model_path, ureg=None)[source]

Get pint UnitsInformation for model.

Parameters
  • model_path (pathlib.Path) –

  • ureg (Optional[pint.UnitRegistry]) –

Return type

UnitsInformation

static model_uid_dict(model, ureg)[source]

Populate the model uid dict for lookup.

Parameters
  • model (libsbml.Model) –

  • ureg (pint.UnitRegistry) –

Return type

Dict[str, str]

static from_sbml_doc(doc, ureg=None)[source]

Get pint UnitsInformation for model in document.

Parameters
  • doc (libsbml.SBMLDocument) –

  • ureg (Optional[pint.UnitRegistry]) –

Return type

UnitsInformation

static _default_ureg()[source]

Get default unit registry.

Return type

pint.UnitRegistry

static normalize_changes(changes, uinfo)[source]

Normalize all changes to units in given units dictionary.

This is a major helper function allowing to convert changes to the requested units.

Parameters
Return type

Dict[str, pint.Quantity]

class sbmlsim.units.Units[source]

Units class.

Container for unit related functionality. Allows to read the unit information from SBML models and provides helpers for the unit conversion.

_units_abbreviation[source]
classmethod udef_to_str(cls, udef)[source]

Format SBML unitDefinition as string.

Units have the general format

(multiplier * 10^scale *ukind)^exponent (m * 10^s *k)^e

Returns the string “None” in case no UnitDefinition was provided.

Parameters

udef (libsbml.UnitDefinition) –

Return type

str

sbmlsim.units.ureg[source]