original_docstring: 
          Compute the weighted frobenius norm of the difference between this calc object and `other_calc`.
  
          Differences in each corresponding gate matrix and spam vector element are squared,
          weighted (using `item_weights` as applicable), then summed.  The value returned is
          the square root of this sum, or the square root of this sum divided by the number
          of summands if normalize == True.
  
          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.
  
          item_weights : dict, optional
              Dictionary of weighting factors for individual gates and spam
              operators. Weights are applied multiplicatively to the squared
              differences, i.e., (*before* the final square root is taken).  Keys
              can be gate, state preparation, POVM effect, or spam labels, as well
              as the two special labels `"gates"` and `"spam"` which apply to all
              of the gate or SPAM elements, respectively (but are overridden by
              specific element values).  Values are floating point numbers.
              By default, all weights are 1.0.
  
          normalize : bool, optional
              if True (the default), the sum of weighted squared-differences
              is divided by the weighted number of differences before the
              final square root is taken.  If False, the division is not performed.
  
          Returns
          -------
          float
          
docstring: Compute the weighted frobenius norm of the difference between this calc object and `other_calc`.
  Differences in each corresponding gate matrix and spam vector element are squared,
  weighted (using `item_weights` as applicable), then summed.  The value returned is
  the square root of this sum, or the square root of this sum divided by the number
  of summands if normalize == True.
  
  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.
  
  item_weights : dict, optional
  Dictionary of weighting factors for individual gates and spam
  operators. Weights are applied multiplicatively to the squared
  differences, i.e., (*before* the final square root is taken).  Keys
  can be gate, state preparation, POVM effect, or spam labels, as well
  as the two special labels `"gates"` and `"spam"` which apply to all
  of the gate or SPAM elements, respectively (but are overridden by
  specific element values).  Values are floating point numbers.
  By default, all weights are 1.0.
  
  normalize : bool, optional
  if True (the default), the sum of weighted squared-differences
  is divided by the weighted number of differences before the
  final square root is taken.  If False, the division is not performed.
  
  Returns
  
  float
docstring_tokens: Compute the weighted frobenius norm of the difference between this calc object and ` other_calc ` . Differences in each corresponding gate matrix and spam vector element are squared weighted ( using ` item_weights ` as applicable ) then summed . The value returned is the square root of this sum or the square root of this sum divided by the number of summands if normalize == True . 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 . item_weights : dict optional Dictionary of weighting factors for individual gates and spam operators . Weights are applied multiplicatively to the squared differences i . e . ( * before * the final square root is taken ) . Keys can be gate state preparation POVM effect or spam labels as well as the two special labels ` " gates " ` and ` " spam " ` which apply to all of the gate or SPAM elements respectively ( but are overridden by specific element values ) . Values are floating point numbers . By default all weights are 1 . 0 . normalize : bool optional if True ( the default ) the sum of weighted squared - differences is divided by the weighted number of differences before the final square root is taken . If False the division is not performed . Returns float
code: def frobeniusdist(self, other_calc, transform_mx=None,
                        item_weights=None, normalize=True):
          """
          Compute the weighted frobenius norm of the difference between this calc object and `other_calc`.
  
          Differences in each corresponding gate matrix and spam vector element are squared,
          weighted (using `item_weights` as applicable), then summed.  The value returned is
          the square root of this sum, or the square root of this sum divided by the number
          of summands if normalize == True.
  
          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.
  
          item_weights : dict, optional
              Dictionary of weighting factors for individual gates and spam
              operators. Weights are applied multiplicatively to the squared
              differences, i.e., (*before* the final square root is taken).  Keys
              can be gate, state preparation, POVM effect, or spam labels, as well
              as the two special labels `"gates"` and `"spam"` which apply to all
              of the gate or SPAM elements, respectively (but are overridden by
              specific element values).  Values are floating point numbers.
              By default, all weights are 1.0.
  
          normalize : bool, optional
              if True (the default), the sum of weighted squared-differences
              is divided by the weighted number of differences before the
              final square root is taken.  If False, the division is not performed.
  
          Returns
          -------
          float
          """
          d = 0; T = transform_mx
          nSummands = 0.0
          if item_weights is None: item_weights = {}
          opWeight = item_weights.get('gates', 1.0)
          spamWeight = item_weights.get('spam', 1.0)
  
          if T is not None:
              Ti = _np.linalg.inv(T)  # TODO: generalize inverse op (call T.inverse() if T were a "transform" object?)
              for opLabel, gate in self.operations.items():
                  wt = item_weights.get(opLabel, opWeight)
                  d += wt * gate.frobeniusdist_squared(
                      other_calc.operations[opLabel], T, Ti)
                  nSummands += wt * (gate.dim)**2
  
              for lbl, rhoV in self.preps.items():
                  wt = item_weights.get(lbl, spamWeight)
                  d += wt * rhoV.frobeniusdist_squared(other_calc.preps[lbl], T, Ti)
                  nSummands += wt * rhoV.dim
  
              for lbl, Evec in self.effects.items():
                  wt = item_weights.get(lbl, spamWeight)
                  d += wt * Evec.frobeniusdist_squared(other_calc.effects[lbl], T, Ti)
                  nSummands += wt * Evec.dim
  
          else:
              for opLabel, gate in self.operations.items():
                  wt = item_weights.get(opLabel, opWeight)
                  d += wt * gate.frobeniusdist_squared(other_calc.operations[opLabel])
                  nSummands += wt * (gate.dim)**2
  
              for lbl, rhoV in self.preps.items():
                  wt = item_weights.get(lbl, spamWeight)
                  d += wt * rhoV.frobeniusdist_squared(other_calc.preps[lbl])
                  nSummands += wt * rhoV.dim
  
              for lbl, Evec in self.effects.items():
                  wt = item_weights.get(lbl, spamWeight)
                  d += wt * Evec.frobeniusdist_squared(other_calc.effects[lbl])
                  nSummands += wt * Evec.dim
  
          #Temporary: check that this function can be computed by
          # calling residuals - replace with this later.
          resids, chk_nSummands = self.residuals(other_calc, transform_mx, item_weights)
          assert(_np.isclose(_np.sum(resids**2), d))
          assert(_np.isclose(chk_nSummands, nSummands))
  
          if normalize and nSummands > 0:
              return _np.sqrt(d / nSummands)
          else:
              return _np.sqrt(d)
code_tokens: def frobeniusdist ( self , other_calc , transform_mx = None , item_weights = None , normalize = True ) : d = 0 ; T = transform_mx nSummands = 0.0 if item_weights is None : item_weights = { } opWeight = item_weights . get ( 'gates' , 1.0 ) spamWeight = item_weights . get ( 'spam' , 1.0 ) if T is not None : Ti = _np . linalg . inv ( T ) for opLabel , gate in self . operations . items ( ) : wt = item_weights . get ( opLabel , opWeight ) d += wt * gate . frobeniusdist_squared ( other_calc . operations [ opLabel ] , T , Ti ) nSummands += wt * ( gate . dim ) ** 2 for lbl , rhoV in self . preps . items ( ) : wt = item_weights . get ( lbl , spamWeight ) d += wt * rhoV . frobeniusdist_squared ( other_calc . preps [ lbl ] , T , Ti ) nSummands += wt * rhoV . dim for lbl , Evec in self . effects . items ( ) : wt = item_weights . get ( lbl , spamWeight ) d += wt * Evec . frobeniusdist_squared ( other_calc . effects [ lbl ] , T , Ti ) nSummands += wt * Evec . dim else : for opLabel , gate in self . operations . items ( ) : wt = item_weights . get ( opLabel , opWeight ) d += wt * gate . frobeniusdist_squared ( other_calc . operations [ opLabel ] ) nSummands += wt * ( gate . dim ) ** 2 for lbl , rhoV in self . preps . items ( ) : wt = item_weights . get ( lbl , spamWeight ) d += wt * rhoV . frobeniusdist_squared ( other_calc . preps [ lbl ] ) nSummands += wt * rhoV . dim for lbl , Evec in self . effects . items ( ) : wt = item_weights . get ( lbl , spamWeight ) d += wt * Evec . frobeniusdist_squared ( other_calc . effects [ lbl ] ) nSummands += wt * Evec . dim resids , chk_nSummands = self . residuals ( other_calc , transform_mx , item_weights ) assert ( _np . isclose ( _np . sum ( resids ** 2 ) , d ) ) assert ( _np . isclose ( chk_nSummands , nSummands ) ) if normalize and nSummands > 0 : return _np . sqrt ( d / nSummands ) else : return _np . sqrt ( d )
short_docstring: Compute the weighted frobenius norm of the difference between this calc object and `other_calc`.
short_docstring_tokens: Compute the weighted frobenius norm of the difference between this calc object and ` other_calc ` .
comment: """
          Compute the weighted frobenius norm of the difference between this calc object and `other_calc`.
  
          Differences in each corresponding gate matrix and spam vector element are squared,
          weighted (using `item_weights` as applicable), then summed.  The value returned is
          the square root of this sum, or the square root of this sum divided by the number
          of summands if normalize == True.
  
          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.
  
          item_weights : dict, optional
              Dictionary of weighting factors for individual gates and spam
              operators. Weights are applied multiplicatively to the squared
              differences, i.e., (*before* the final square root is taken).  Keys
              can be gate, state preparation, POVM effect, or spam labels, as well
              as the two special labels `"gates"` and `"spam"` which apply to all
              of the gate or SPAM elements, respectively (but are overridden by
              specific element values).  Values are floating point numbers.
              By default, all weights are 1.0.
  
          normalize : bool, optional
              if True (the default), the sum of weighted squared-differences
              is divided by the weighted number of differences before the
              final square root is taken.  If False, the division is not performed.
  
          Returns
          -------
          float
          """$SEP$# TODO: generalize inverse op (call T.inverse() if T were a "transform" object?)$SEP$#Temporary: check that this function can be computed by$SEP$# calling residuals - replace with this later.