:py:mod:`pygsti.models.memberdict` ================================== .. py:module:: pygsti.models.memberdict .. autoapi-nested-parse:: Defines OrderedDict-derived classes used to store specific pyGSTi objects Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.models.memberdict.OrderedMemberDict .. py:class:: OrderedMemberDict(parent, default_param, prefix, flags, items=None) Bases: :py:obj:`_PrefixOrderedDict`, :py:obj:`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. :class:`State`- or :class:`LinearOperator`-derived object) by converting any values into that type upon assignment and raising an error if this is not possible. Parameters ---------- parent : Model 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. prefix : str The required prefix of all keys (which must be strings). flags : dict 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`). items : list, optional Used by pickle and other serializations to initialize elements. Creates a new OrderedMemberDict. Parameters ---------- parent : Model 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. prefix : str The required prefix of all keys (which must be strings). flags : dict 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`). items : list, optional Used by pickle and other serializations to initialize elements. .. py:attribute:: parent :value: 'None' Gets the parent of this object. Returns ------- Model .. py:attribute:: default_param .. py:attribute:: flags .. py:method:: cast_to_model_member(value) Cast `value` to an object with the default parameterization if it's not a :class:`ModelMember`. Creates an object from `value` with a type given by the default parameterization if `value` isn't a :class:`ModelMember`. Parameters ---------- value : object The object to act on. Returns ------- object .. py:method:: copy(parent=None, memo=None) Returns a copy of this OrderedMemberDict. Parameters ---------- parent : Model The new parent Model, if one exists. Typically, when copying an OrderedMemberDict you want to reset the parent. Returns ------- OrderedMemberDict