class_docstr: Immutable dictionary used to represent a Fermi sentence, a linear combination of Fermi words, with the keys
  as FermiWord instances and the values correspond to coefficients.
  
  >>> w1 = FermiWord({(0, 0) : '+', (1, 1) : '-'})
  >>> w2 = FermiWord({(0, 1) : '+', (1, 2) : '-'})
  >>> s = FermiSentence({w1 : 1.2, w2: 3.1})
  >>> s
  1.2 * a⁺(0) a(1)
  + 3.1 * a⁺(1) a(2)
class_docstr_tok: ["Immutable","dictionary","used","to","represent","a","Fermi","sentence",",","a","linear","combination","of","Fermi","words",",","with","the","keys","as","FermiWord","instances","and","the","values","correspond","to","coefficients",".",">",">",">","w1","=","FermiWord","(","{","(","0",",","0",")",":","'+","'",",","(","1",",","1",")",":","'-","'","}",")",">",">",">","w2","=","FermiWord","(","{","(","0",",","1",")",":","'+","'",",","(","1",",","2",")",":","'-","'","}",")",">",">",">","s","=","FermiSentence","(","{","w1",":","1.2",",","w2",":","3.1","}",")",">",">",">","s","1.2","*","a\u207a","(","0",")","a","(","1",")","+","3.1","*","a\u207a","(","1",")","a","(","2",")"]
docstr: Add a FermiSentence, FermiWord or constant to a FermiSentence by iterating over the
  smaller one and adding its terms to the larger one.
docstr_tok: ["Add","a","FermiSentence",",","FermiWord","or","constant","to","a","FermiSentence","by","iterating","over","the","smaller","one","and","adding","its","terms","to","the","larger","one","."]
code: def __add__(self, other):
      r"""Add a FermiSentence, FermiWord or constant to a FermiSentence by iterating over the
      smaller one and adding its terms to the larger one."""
  
      # ensure other is FermiSentence
      if isinstance(other, FermiWord):
          other = FermiSentence({other: 1})
      if isinstance(other, Number):
          other = FermiSentence({FermiWord({}): other})
      if isinstance(other, ndarray):
          if qml.math.size(other) > 1:
              raise ValueError(
                  f"Arithmetic Fermi operations can only accept an array of length 1, "
                  f"but received {other} of length {len(other)}"
              )
          other = FermiSentence({FermiWord({}): other})
  
      if isinstance(other, FermiSentence):
          smaller_fs, larger_fs = (
              (self, copy(other))
              if len(self) < len(other)
              else (other, copy(self))
          )
          for key in smaller_fs:
              larger_fs[key] += smaller_fs[key]
  
          return larger_fs
  
      raise TypeError(f"Cannot add {type(other)} to a FermiSentence.")
  
imports: import re
  from copy import copy
  from numbers import Number
  from numpy import ndarray
  import pennylane
label_desc: Use image node_id 6 for calling the FermiSentence obj's underlying member method code with example usage: obj.__add__(other) and returns: larger_fs