py_alqorithms.sort_spin_operator

py_alqorithms.sort_spin_operator(input_operator)

Sort a PauliOperator/PauliHamiltonian into a vector of the same type, where each object has all of the qubits involved in its keys (PauliProducts) in the same basis.

For example, the PauliOperator containing: ``` text

  • (0X1Z4Y, 1.0)

  • (0X1Y, 1.5)

  • (4Y6Z, 2.0)

``` would become two PauliOperators:

  • (0X1Z4Y, 1.0)

  • (4Y6Z, 2.0)

and
  • (0X1Y, 1.5)

Parameters:

input_operator (PauliOperator) -- The PauliOperator to be split up into same basis PauliOperators

Returns:

The same basis PauliOperators

Return type:

List[PauliOperator]

Raises:
  • PyTypeError -- Could not convert input_operator to PauliOperator

  • PyValueError -- Issue in the add_operator_product function

  • PyValueError -- Could not create 2.x PauliOperator from 1.x SpinOperator