io#
import qrules.io
Serialization module for the qrules.
The io module provides tools to export or import objects from qrules to and from
disk, so that they can be used by external packages, or just to store (cache) the state
of the system.
- asdot(instance: object, /, *, render_node: bool | None = None, render_final_state_id: bool = True, render_resonance_id: bool = False, render_initial_state_id: bool = False, strip_spin: bool = False, collapse_graphs: bool = False, edge_style: dict[str, Any] | None = None, node_style: dict[str, Any] | None = None, **figure_style: Any) str[source]#
Convert a
objectto a DOT languagestr.Only works for objects that can be represented as a graph, particularly a
MutableTransitionor alistofMutableTransitioninstances.- Parameters:
instance – the input
objectthat is to be rendered as DOT (graphviz) language.strip_spin – Normally, each
MutableTransitionhas aParticlewith a spin projection on its edges. This option hides the projections, leaving onlyParticlenames on edges.collapse_graphs – Group all transitions by equivalent kinematic topology and combine all allowed particles on each edge.
render_node –
Whether or not to render node ID (in the case of a
Topology) and/or node properties (in the case of aMutableTransition). Meaning of the labels:\(P\): parity prefactor
\(s\): tuple of coupled spin magnitude and its projection
\(l\): tuple of angular momentum and its projection
See
InteractionPropertiesfor more info.render_final_state_id – Add edge IDs for the final state edges.
render_resonance_id – Add edge IDs for the intermediate state edges.
render_initial_state_id – Add edge IDs for the initial state edges.
edge_style – Styling of a Graphviz edge.
node_style – Styling of a Graphviz node.
figure_style – Styling of the whole figure.
See also
See Graphviz attributes for the available styling arguments.
See also
- asmermaid(instance: object, /, *, render_node: bool | None = None, render_final_state_id: bool = True, render_resonance_id: bool = False, render_initial_state_id: bool = False, strip_spin: bool = False, collapse_graphs: bool = False, figure_style: dict[str, Any] | None = None, edge_style: dict[str, Any] | None = None, node_style: dict[str, Any] | None = None, latex: bool = True, markdown: bool = False) str[source]#
Convert a
objectto a Mermaid flowchart sourcestr.Only works for objects that can be represented as a graph, particularly a
MutableTransitionor alistofMutableTransitioninstances.- Parameters:
instance – the input
objectthat is to be rendered as Mermaid flowchart source.strip_spin – Normally, each
MutableTransitionhas aParticlewith a spin projection on its edges. This option hides the projections, leaving onlyParticlenames on edges.collapse_graphs – Group all transitions by equivalent kinematic topology and combine all allowed particles on each edge. With LaTeX rendering, particle lists longer than six entries are arranged in columns of at most six rows.
render_node –
Whether or not to render node ID (in the case of a
Topology) and/or node properties (in the case of aMutableTransition). Meaning of the labels:\(P\): parity prefactor
\(S\): coupled spin magnitude and projection
\(L\): angular momentum and projection
See
InteractionPropertiesfor more info.render_final_state_id – Add edge IDs for the final state edges.
render_resonance_id – Add edge IDs for the intermediate state edges.
render_initial_state_id – Add edge IDs for the initial state edges.
edge_style – Styling of Mermaid edges.
node_style – Styling of Mermaid nodes.
figure_style – Styling of the whole Mermaid diagram.
latex – Render edge and node labels as LaTeX math expressions. Particle labels use
Particle.latexwhen available.markdown – Wrap the Mermaid source in a Markdown code fence.
See also
See the Mermaid flowchart syntax for available diagram constructs and style directives.
See also
- class JSONSetEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#
Bases:
JSONEncoderJSONEncoderthat supportssetandfrozenset.>>> import json >>> instance = {"val1": {1, 2, 3}, "val2": frozenset({2, 3, 4, 5})} >>> json.dumps(instance, cls=JSONSetEncoder) '{"val1": [1, 2, 3], "val2": [2, 3, 4, 5]}'