docs: def _convert_local_operator_to_qutip(expr, full_space, mapping):
      """Convert a LocalOperator instance to qutip"""
      n = full_space.dimension
      if full_space != expr.space:
          all_spaces = full_space.local_factors
          own_space_index = all_spaces.index(expr.space)
          return qutip.tensor(
              *([qutip.qeye(s.dimension)
                 for s in all_spaces[:own_space_index]] +
                [convert_to_qutip(expr, expr.space, mapping=mapping), ] +
                [qutip.qeye(s.dimension)
                 for s in all_spaces[own_space_index + 1:]])
          )
      if isinstance(expr, Create):
          return qutip.create(n)
      elif isinstance(expr, Jz):
          return qutip.jmat((expr.space.dimension-1)/2., "z")
      elif isinstance(expr, Jplus):
          return qutip.jmat((expr.space.dimension-1)/2., "+")
      elif isinstance(expr, Jminus):
          return qutip.jmat((expr.space.dimension-1)/2., "-")
      elif isinstance(expr, Destroy):
          return qutip.destroy(n)
      elif isinstance(expr, Phase):
          arg = complex(expr.operands[1]) * arange(n)
          d = np_cos(arg) + 1j * np_sin(arg)
          return qutip.Qobj(np_diag(d))
      elif isinstance(expr, Displace):
          alpha = expr.operands[1]
          return qutip.displace(n, alpha)
      elif isinstance(expr, Squeeze):
          eta = expr.operands[1]
          return qutip.displace(n, eta)
      elif isinstance(expr, LocalSigma):
          j = expr.j
          k = expr.k
          if isinstance(j, str):
              j = expr.space.basis_labels.index(j)
          if isinstance(k, str):
              k = expr.space.basis_labels.index(k)
          ket = qutip.basis(n, j)
          bra = qutip.basis(n, k).dag()
          return ket * bra
      else:
          raise ValueError("Cannot convert '%s' of type %s"
                           % (str(expr), type(expr)))