:py:mod:`pygsti.baseobjs.outcomelabeldict` ========================================== .. py:module:: pygsti.baseobjs.outcomelabeldict .. autoapi-nested-parse:: Defines the OutcomeLabelDict class Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.baseobjs.outcomelabeldict.OutcomeLabelDict .. py:class:: OutcomeLabelDict(items=None) Bases: :py:obj:`collections.OrderedDict` An ordered dictionary of outcome labels, whose keys are tuple-valued outcome labels. This class extends an ordinary OrderedDict by implements mapping string-values single-outcome labels to 1-tuples containing that label (and vice versa), allowing the use of strings as outcomes labels from the user's perspective. Parameters ---------- items : list or dict, optional Initial values. Should only be used as part of de-serialization. Attributes ---------- _strict : bool Whether mapping from strings to 1-tuples is performed. Creates a new OutcomeLabelDict. Parameters ---------- items : list, optional Used by pickle and other serializations to initialize elements. .. py:method:: to_outcome(val) :classmethod: Converts string outcomes like "0" to proper outcome tuples, like ("0",). (also converts non-tuples to tuples, e.g. `["0","1"]` to `("0","1")` ) Parameters ---------- val : str or tuple The value to convert into an outcome label (i.e. a tuple) Returns ------- tuple .. py:method:: get(key, default) Return the value for key if key is in the dictionary, else default. .. py:method:: getitem_unsafe(key, defaultval) Gets an item without checking that `key` is a properly formatted outcome tuple. Only use this method when you're sure `key` is an outcome tuple and not, e.g., just a string. Parameters ---------- key : object The key to retrieve defaultval : object The default value to use (if the key is absent). Returns ------- object .. py:method:: setitem_unsafe(key, val) Sets item without checking that the key is a properly formatted outcome tuple. Only use this method when you're sure `key` is an outcome tuple and not, e.g., just a string. Parameters ---------- key : object The key to retrieve. val : object the value to set. Returns ------- None .. py:method:: contains_unsafe(key) Checks for `key` without ensuring that it is a properly formatted outcome tuple. Only use this method when you're sure `key` is an outcome tuple and not, e.g., just a string. Parameters ---------- key : object The key to retrieve. Returns ------- bool .. py:method:: copy() Return a copy of this OutcomeLabelDict. Returns ------- OutcomeLabelDict