pygsti.modelmembers.modelmembergraph
Modelmember dependency graph related utility functions
Module Contents
Classes
A directed acyclic graph of dependencies of ModelMembers |
|
A basic graph node object for ModelMembers |
- class pygsti.modelmembers.modelmembergraph.ModelMemberGraph(mm_dicts)
Bases:
object
A directed acyclic graph of dependencies of ModelMembers
Generate a directed acyclic graph of ModelMember dependencies for an OpModel.
All ModelMembers are copied, so a new ModelMemberGraph must be constructed after any changes to the model to accurately reflect parameterization type and values.
Parameters
- mm_dicts: dict of OrderedMemberDicts
Dictionary where keys are attribute names and values are OrderedMemberDicts from an OpModel, e.g. {‘preps’: self.preps, etc.} from an ExplicitOpModel
- mm_memo
- mm_nodes
- classmethod load_modelmembers_from_serialization_dict(sdict, parent_model)
Create a nested dictionary of model members from a previously serialized graph.
Parameters
- sdict: dict
Flat dict of the ModelMemberGraph that was serialized by a prior call to
ModelMemberGraph.create_serialization_dict()
.
Returns
dict
- is_similar(other, rtol=1e-05, atol=1e-08)
Comparator between two ModelMemberGraph objects for structure only.
Parameters
- other: ModelMemberGraph
Dependency graph to compare to
- rtol, atol: float
Relative and absolute tolerances used to check if floating point values are “equal”.
Returns
- bool
True if both ModelMemberGraphs have identical modelmember structure/parameterization
- is_equivalent(other, rtol=1e-05, atol=1e-08)
Comparator between two ModelMemberGraph objects for structure and values.
Parameters
- other: ModelMemberGraph
Dependency graph to compare to
- rtol, atol: float
Relative and absolute tolerances used to check if parameter values are “equal”.
Returns
- bool
True if similar_to AND parameter vectors match
- create_serialization_dict()
Serialize the ModelMemberGraph object.
Calls underlying to_memoized_dict on each ModelMember, as well as adding necessary metadata for the collection of ModelMembers - e.g., OrderedMemberDict keys for root nodes.
Returns
- sdict: dict
Flat dict of the ModelMemberGraph for serialization. Keys are serialize_ids, values are derefernced dicts for each individual ModelMember.
- print_graph(indent=2)
- class pygsti.modelmembers.modelmembergraph.MMGNode(mm: pygsti.modelmembers.modelmember.ModelMember, mm_memo)
Bases:
object
A basic graph node object for ModelMembers
- children = '[]'
- serialize_id
- mm