pygsti.models.memberdict

Defines OrderedDict-derived classes used to store specific pyGSTi objects

Module Contents

Classes

OrderedMemberDict

An ordered dictionary whose keys must begin with a given prefix.

class pygsti.models.memberdict.OrderedMemberDict(parent, default_param, prefix, flags, items=None)

Bases: _PrefixOrderedDict, pygsti.modelmembers.modelmember.ModelChild

An ordered dictionary whose keys must begin with a given prefix.

This class also ensure that every value is an object of the appropriate Model member type (e.g. State- or LinearOperator-derived object) by converting any values into that type upon assignment and raising an error if this is not possible.

Parameters

parentModel

The parent model, needed to obtain the dimension and handle updates to parameters.

default_param{“TP”,”full”,…}

The default parameterization used when creating an object from a key assignment.

prefixstr

The required prefix of all keys (which must be strings).

flagsdict

A dictionary of flags adjusting the behavior of the created object. Allowed keys are:

  • ‘cast_to_type’: {“operation”,`”state”,`None} – whether (or not) to automatically convert assigned values to a particular type of ModelMember object. (default is None)

  • ‘auto_embed’ : bool – whether or not to automatically embed objects with a lower dimension than this OrderedMemberDict’s parent model. (default is False).

  • ‘match_parent_statespace’ : bool – whether or not to require that all contained objects match the parent Model’s state space (perhaps after embedding). (default is False)

  • ‘match_parent_evotype’ : bool – whether or not to require that all contained objects match the parent Model’s evolution type. (default is False).

itemslist, optional

Used by pickle and other serializations to initialize elements.

Creates a new OrderedMemberDict.

Parameters

parentModel

The parent model, needed to obtain the dimension and handle updates to parameters.

default_param{“TP”,”full”,…}

The default parameterization used when creating an object from a key assignment.

prefixstr

The required prefix of all keys (which must be strings).

flagsdict

A dictionary of flags adjusting the behavior of the created object. Allowed keys are:

  • ‘cast_to_type’: {“operation”,`”state”,`None} – whether (or not) to automatically convert assigned values to a particular type of ModelMember object. (default is None)

  • ‘auto_embed’ : bool – whether or not to automatically embed objects with a lower dimension than this OrderedMemberDict’s parent model. (default is False).

  • ‘match_parent_statespace’ : bool – whether or not to require that all contained objects match the parent Model’s state space (perhaps after embedding). (default is False)

  • ‘match_parent_evotype’ : bool – whether or not to require that all contained objects match the parent Model’s evolution type. (default is False).

itemslist, optional

Used by pickle and other serializations to initialize elements.

cast_to_model_member(value)

Cast value to an object with the default parameterization if it’s not a ModelMember.

Creates an object from value with a type given by the default parameterization if value isn’t a ModelMember.

Parameters
valueobject

The object to act on.

Returns

object

copy(parent=None, memo=None)

Returns a copy of this OrderedMemberDict.

Parameters
parentModel

The new parent Model, if one exists. Typically, when copying an OrderedMemberDict you want to reset the parent.

Returns

OrderedMemberDict