jaxrts.saving.JaXRTSDecoder

class jaxrts.saving.JaXRTSDecoder(ureg, additional_mappings: dict[str, Model | HNCPotential] | None = None, *args, **kwargs)[source]

Warning

In the current implementation, you cannot easily restore custom models. To restore them, you have to provide these in additional_mappings

Initialize the JSON decoder.

Paramters

ureg

The UnitRegistry that is used for decoding. Has to the same instance which was used when setting up the objects that should be decoded.

additional_mappings: dict[str: Model | HNCPotential], optional

Dict containing mappings so that custom models can be decoded, too. See the test in tests/test_saving.py to see this in practice.

Methods

__init__(ureg[, additional_mappings])

Initialize the JSON decoder.

decode(s[, _w])

Return the Python representation of s (a str instance containing a JSON document).

object_hook(obj)

raw_decode(s[, idx])

Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.

Attributes

hnc_potentials

models