pygsti.modelmembers.modelmembergraph.ModelMemberGraph#
- class ModelMemberGraph(mm_dicts)#
Bases:
objectA 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
Methods
__init__(mm_dicts)Generate a directed acyclic graph of ModelMember dependencies for an OpModel.
Serialize the ModelMemberGraph object.
is_equivalent(other[, rtol, atol])Comparator between two ModelMemberGraph objects for structure and values.
is_similar(other[, rtol, atol])Comparator between two ModelMemberGraph objects for structure only.
Create a nested dictionary of model members from a previously serialized graph.
print_graph([indent])- 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 – Flat dict of the ModelMemberGraph for serialization. Keys are serialize_ids, values are dereferenced dicts for each individual ModelMember.
- Return type:
dict
- 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 (float) – Relative and absolute tolerances used to check if parameter values are “equal”.
atol (float) – Relative and absolute tolerances used to check if parameter values are “equal”.
- Returns:
True if similar_to AND parameter vectors match
- Return type:
bool
- 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 (float) – Relative and absolute tolerances used to check if floating point values are “equal”.
atol (float) – Relative and absolute tolerances used to check if floating point values are “equal”.
- Returns:
True if both ModelMemberGraphs have identical modelmember structure/parameterization
- Return type:
bool
- static 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().- Return type:
dict