convert_observable(qubit_observable, wires=None)[source]

Converts an OpenFermion QubitOperator operator to a Pennylane VQE observable

  • qubit_observable (QubitOperator) – Observable represented as an OpenFermion QubitOperator

  • wires (Wires, list, tuple, dict) – Custom wire mapping used to convert the qubit operator to an observable terms measurable in a PennyLane ansatz. For types Wires/list/tuple, each item in the iterable represents a wire label corresponding to the qubit number equal to its index. For type dict, only int-keyed dict (for qubit-to-wire conversion) is accepted. If None, will use identity map (e.g. 0->0, 1->1, …).


Pennylane VQE observable. PennyLane Hamiltonian represents any operator expressed as linear combinations of observables, e.g., \(\sum_{k=0}^{N-1} c_k O_k\).

Return type



>>> h_of = decompose('./pyscf/sto-3g/h2')
>>> h_pl = convert_observable(h_of)
>>> print(h_pl.coeffs)
[-0.04207898  0.17771287  0.17771287 -0.24274281 -0.24274281  0.17059738
  0.04475014 -0.04475014 -0.04475014  0.04475014  0.12293305  0.16768319
  0.16768319  0.12293305  0.17627641]