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.

asdict(instance: object) dict[source]
asdot(instance: object, *, render_node: bool = False, 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) str[source]

Convert a object to a DOT language str.

Only works for objects that can be represented as a graph, particularly a StateTransitionGraph or a list of StateTransitionGraph instances.

Parameters
  • instance – the input object that is to be rendered as DOT (graphviz) language.

  • strip_spin – Normally, each StateTransitionGraph has a Particle with a spin projection on its edges. This option hides the projections, leaving only Particle names 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 a StateTransitionGraph). 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 InteractionProperties for 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.

fromdict(definition: dict) object[source]
load(filename: str) object[source]
write(instance: object, filename: str) None[source]