qml.qchem.convert_observable

convert_observable(qubit_observable)[source]

Converts an OpenFermion QubitOperator operator to a Pennylane VQE observable

Example usage

>>> h_of = decompose_hamiltonian('h2', './pyscf/sto-3g/')
>>> h_pl = convert_observable(h_of)
>>> h_pl.coeffs
[-0.04207898+0.j  0.17771287+0.j  0.17771287+0.j -0.2427428 +0.j -0.2427428 +0.j  0.17059738+0.j
0.04475014+0.j  0.04475014+0.j  0.04475014+0.j  0.04475014+0.j  0.12293305+0.j  0.16768319+0.j
0.16768319+0.j  0.12293305+0.j  0.17627641+0.j]
Parameters

qubit_observable (QubitOperator) – Observable represented as an OpenFermion QubitOperator

Returns

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

(pennylane.Hamiltonian)