original_docstring: Recognize all TimeEvolution gates with >1 terms that don't all commute.
  
      This is a filter function for use with ProjectQ that flags terms as
          non-commuting so they may be handled by a different factorization
          routine.
  
      Args:
          cmd(projectq.command): A command from ProjectQ
  
      Returns:
          (bool) Depending on whether the terms are determined to commute or not
      
docstring: Recognize all TimeEvolution gates with >1 terms that don't all commute.
  This is a filter function for use with ProjectQ that flags terms as
  non-commuting so they may be handled by a different factorization
  routine.
docstring_tokens: Recognize all TimeEvolution gates with > 1 terms that don ' t all commute . This is a filter function for use with ProjectQ that flags terms as non - commuting so they may be handled by a different factorization routine .
code: def _identify_non_commuting(cmd):
      """Recognize all TimeEvolution gates with >1 terms that don't all commute.
  
      This is a filter function for use with ProjectQ that flags terms as
          non-commuting so they may be handled by a different factorization
          routine.
  
      Args:
          cmd(projectq.command): A command from ProjectQ
  
      Returns:
          (bool) Depending on whether the terms are determined to commute or not
      """
      hamiltonian = cmd.gate.hamiltonian
      if len(hamiltonian.terms) == 1:
          return False
      else:
          id_op = projectq.ops.QubitOperator((), 0.0)
          for term in hamiltonian.terms:
              test_op = projectq.ops.QubitOperator(term, hamiltonian.terms[term])
              for other in hamiltonian.terms:
                  other_op = projectq.\
                      ops.QubitOperator(other, hamiltonian.terms[other])
                  commutator = test_op * other_op - other_op * test_op
                  if not commutator.isclose(id_op,
                                            rel_tol=1e-9,
                                            abs_tol=1e-9):
                      return True
      return False
code_tokens: def _identify_non_commuting ( cmd ) : hamiltonian = cmd . gate . hamiltonian if len ( hamiltonian . terms ) == 1 : return False else : id_op = projectq . ops . QubitOperator ( ( ) , 0.0 ) for term in hamiltonian . terms : test_op = projectq . ops . QubitOperator ( term , hamiltonian . terms [ term ] ) for other in hamiltonian . terms : other_op = projectq . ops . QubitOperator ( other , hamiltonian . terms [ other ] ) commutator = test_op * other_op - other_op * test_op if not commutator . isclose ( id_op , rel_tol = 1e-9 , abs_tol = 1e-9 ) : return True return False
short_docstring: Recognize all TimeEvolution gates with >1 terms that don't all commute.
short_docstring_tokens: Recognize all TimeEvolution gates with > 1 terms that don ' t all commute .
comment: """Recognize all TimeEvolution gates with >1 terms that don't all commute.
  
      This is a filter function for use with ProjectQ that flags terms as
          non-commuting so they may be handled by a different factorization
          routine.
  
      Args:
          cmd(projectq.command): A command from ProjectQ
  
      Returns:
          (bool) Depending on whether the terms are determined to commute or not
      """