Export JSON (
Module containing a class for exporting a PySB model to JSON
For information on how to use the model exporters, see the documentation
- class pysb.export.json.JsonExporter(model, docstring=None)[source]¶
A class for returning the JSON for a given PySB model.
pysb.export.Exporter, which implements basic functionality for all exporters.
Generate the corresponding JSON for the PySB model associated with the exporter.
- include_netgen: bool
Include cached network generation data (reactions, species, local function-derived parameters and expressions) if True.
The JSON output for the model.
- class pysb.export.json.PySBJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Encode a PySB model in JSON
This encoder stores the model without caching the reaction network. To also store the reaction network, see
Attributes correspond to their PySB equivalents (monomers, parameters, etc.) and are mostly stored verbatim, with the following exceptions.
MultiStates and the ANY and WILD state values use a special object format
References to other components are stored using the component name
Sympy expressions are encoded as strings using the default encoder
The protocol number specifies semantic compatibility of the JSON output. It should be incremented if new features are added which affect how a model is simulated or prevent the new output from being loaded by
pysb.importers.json.PySBJSONDecoder(). See that code for documentation on the different protocol versions. This encoder only produces JSON using the highest protocol currently defined; If you need to generate output for an older protocol, use an older version of PySB in which the desired protocol number was still current.
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise a
For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class pysb.export.json.PySBJSONWithNetworkEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Encode a PySB model and its reaction network in JSON
This encoder stores the model including the cached reaction network. To encode the model without the reaction network, see
PySBJSONEncoder, which also includes implementation details.