original_docstring: 
          Compute the diamond-norm distance between two models/calcs.
  
          This is defined as the maximum of the diamond-norm distances between
          each corresponding gate, including spam gates.
  
          Parameters
          ----------
          other_calc : ForwardSimulator
              the other gate calculator to difference against.
  
          transform_mx : numpy array, optional
              if not None, transform this model by
              G => inv(transform_mx) * G * transform_mx, for each operation matrix G
              (and similar for rho and E vectors) before taking the difference.
              This transformation is applied only for the difference and does
              not alter the values stored in this model.
  
          include_spam : bool, optional
              Whether to add to the max-diamond-distance the frobenius distances
              between corresponding SPAM vectors.
  
          Returns
          -------
          float
          
docstring: Compute the diamond-norm distance between two models/calcs.
  This is defined as the maximum of the diamond-norm distances between
  each corresponding gate, including spam gates.
  
  Parameters
  
  other_calc : ForwardSimulator
  the other gate calculator to difference against.
  
  transform_mx : numpy array, optional
  if not None, transform this model by
  G => inv(transform_mx) * G * transform_mx, for each operation matrix G
  (and similar for rho and E vectors) before taking the difference.
  This transformation is applied only for the difference and does
  not alter the values stored in this model.
  
  include_spam : bool, optional
  Whether to add to the max-diamond-distance the frobenius distances
  between corresponding SPAM vectors.
  
  Returns
  
  float
docstring_tokens: Compute the diamond - norm distance between two models / calcs . This is defined as the maximum of the diamond - norm distances between each corresponding gate including spam gates . Parameters other_calc : ForwardSimulator the other gate calculator to difference against . transform_mx : numpy array optional if not None transform this model by G = > inv ( transform_mx ) * G * transform_mx for each operation matrix G ( and similar for rho and E vectors ) before taking the difference . This transformation is applied only for the difference and does not alter the values stored in this model . include_spam : bool optional Whether to add to the max - diamond - distance the frobenius distances between corresponding SPAM vectors . Returns float
code: def diamonddist(self, other_calc, transform_mx=None, include_spam=True):
          """
          Compute the diamond-norm distance between two models/calcs.
  
          This is defined as the maximum of the diamond-norm distances between
          each corresponding gate, including spam gates.
  
          Parameters
          ----------
          other_calc : ForwardSimulator
              the other gate calculator to difference against.
  
          transform_mx : numpy array, optional
              if not None, transform this model by
              G => inv(transform_mx) * G * transform_mx, for each operation matrix G
              (and similar for rho and E vectors) before taking the difference.
              This transformation is applied only for the difference and does
              not alter the values stored in this model.
  
          include_spam : bool, optional
              Whether to add to the max-diamond-distance the frobenius distances
              between corresponding SPAM vectors.
  
          Returns
          -------
          float
          """
          T = transform_mx
          d = 0  # spam difference
          nSummands = 0  # for spam terms
  
          if T is not None:
              Ti = _np.linalg.inv(T)
              dists = [gate.diamonddist(other_calc.operations[lbl], T, Ti)
                       for lbl, gate in self.operations.items()]
  
              #Just use frobenius distance between spam vecs, since jtracedist
              # doesn't really make sense
              if include_spam:
                  for lbl, rhoV in self.preps.items():
                      d += rhoV.frobeniusdist_squared(other_calc.preps[lbl], T, Ti)
                      nSummands += rhoV.dim
  
                  for lbl, Evec in self.effects.items():
                      d += Evec.frobeniusdist_squared(other_calc.effects[lbl], T, Ti)
                      nSummands += Evec.dim
  
          else:
              dists = [gate.diamonddist(other_calc.operations[lbl])
                       for lbl, gate in self.operations.items()]
  
              #Just use frobenius distance between spam vecs, since jtracedist
              # doesn't really make sense
              if include_spam:
                  for lbl, rhoV in self.preps.items():
                      d += rhoV.frobeniusdist_squared(other_calc.preps[lbl])
                      nSummands += rhoV.dim
  
                  for lbl, Evec in self.effects.items():
                      d += Evec.frobeniusdist_squared(other_calc.effects[lbl])
                      nSummands += Evec.dim
  
          spamVal = _np.sqrt(d / nSummands) if (nSummands > 0) else 0
          return max(dists) + spamVal
code_tokens: def diamonddist ( self , other_calc , transform_mx = None , include_spam = True ) : T = transform_mx d = 0 nSummands = 0 if T is not None : Ti = _np . linalg . inv ( T ) dists = [ gate . diamonddist ( other_calc . operations [ lbl ] , T , Ti ) for lbl , gate in self . operations . items ( ) ] if include_spam : for lbl , rhoV in self . preps . items ( ) : d += rhoV . frobeniusdist_squared ( other_calc . preps [ lbl ] , T , Ti ) nSummands += rhoV . dim for lbl , Evec in self . effects . items ( ) : d += Evec . frobeniusdist_squared ( other_calc . effects [ lbl ] , T , Ti ) nSummands += Evec . dim else : dists = [ gate . diamonddist ( other_calc . operations [ lbl ] ) for lbl , gate in self . operations . items ( ) ] if include_spam : for lbl , rhoV in self . preps . items ( ) : d += rhoV . frobeniusdist_squared ( other_calc . preps [ lbl ] ) nSummands += rhoV . dim for lbl , Evec in self . effects . items ( ) : d += Evec . frobeniusdist_squared ( other_calc . effects [ lbl ] ) nSummands += Evec . dim spamVal = _np . sqrt ( d / nSummands ) if ( nSummands > 0 ) else 0 return max ( dists ) + spamVal
short_docstring: Compute the diamond-norm distance between two models/calcs.
short_docstring_tokens: Compute the diamond - norm distance between two models / calcs .
comment: """
          Compute the diamond-norm distance between two models/calcs.
  
          This is defined as the maximum of the diamond-norm distances between
          each corresponding gate, including spam gates.
  
          Parameters
          ----------
          other_calc : ForwardSimulator
              the other gate calculator to difference against.
  
          transform_mx : numpy array, optional
              if not None, transform this model by
              G => inv(transform_mx) * G * transform_mx, for each operation matrix G
              (and similar for rho and E vectors) before taking the difference.
              This transformation is applied only for the difference and does
              not alter the values stored in this model.
  
          include_spam : bool, optional
              Whether to add to the max-diamond-distance the frobenius distances
              between corresponding SPAM vectors.
  
          Returns
          -------
          float
          """$SEP$# spam difference$SEP$# for spam terms$SEP$#Just use frobenius distance between spam vecs, since jtracedist$SEP$# doesn't really make sense$SEP$#Just use frobenius distance between spam vecs, since jtracedist$SEP$# doesn't really make sense