PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.34k stars 602 forks source link

`qml.qchem.convert_observable` converts complex coefficients in openfermion `QubitOperator` to real without warning or error #1266

Closed aemccoy closed 3 years ago

aemccoy commented 3 years ago

[bug]

Issue description

Source code and tracebacks

import pennylane as qml
from openfermion.ops import QubitOperator

test_qop1=qml.qchem.convert_observable(QubitOperator("Y0 Y1", 1))
print(test_qop1)

returns

  (1) [Y0 Y1]

while

test_qop2=qml.qchem.convert_observable(QubitOperator("Y0 Y1", 1j))
print(test_qop2)

returns

  (0.0) [Y0 Y1]
josh146 commented 3 years ago

Thanks @aemccoy! Just to confirm -- for your current workflow, would you prefer that attempting to convert a Hamiltonian with complex coefficients raises an error? Or, alternatively, would you like a way to represent a (potentially) non-Hermitian linear combination of Pauli terms?

aemccoy commented 3 years ago

The ability to represent a potentially non-Hermitian linear combination of Pauli terms would be ideal. Thanks!