I am persuing some older code as below

ferOp = FermionicOperator(h1=molecule.one_body_integrals, h2=molecule.two_body_integrals)
qubitOp = ferOp.mapping(map_type='parity', threshold=0.000001)
qubitOp = qubitOp.two_qubit_reduced_operator(num_particles)

but am getting the following error:

AttributeError: 'WeightedPauliOperator' object has no attribute 'two_qubit_reduced_operator'

Any suggestions for how to fix. I am using qiskit version:

qiskit                             0.14.1
qiskit-aer                         0.3.4
qiskit-aqua                        0.6.2
qiskit-ibmq-provider               0.4.5
qiskit-ignis                       0.2.0
qiskit-terra                       0.11.1 

1 Answer 1


The chemistry sample in the README on the qiskit-aqua repo shows how to do this now:

from qiskit.chemistry import FermionicOperator
from qiskit.chemistry.drivers import PySCFDriver, UnitsType
from qiskit.aqua.operators import Z2Symmetries

# Use PySCF, a classical computational chemistry software
# package, to compute the one-body and two-body integrals in
# molecular-orbital basis, necessary to form the Fermionic operator
driver = PySCFDriver(atom='H .0 .0 .0; H .0 .0 0.735',
molecule = driver.run()
num_particles = molecule.num_alpha + molecule.num_beta
num_spin_orbitals = molecule.num_orbitals * 2

# Build the qubit operator, which is the input to the VQE algorithm in Aqua
ferOp = FermionicOperator(h1=molecule.one_body_integrals, h2=molecule.two_body_integrals)
map_type = 'PARITY'
qubitOp = ferOp.mapping(map_type)
qubitOp = Z2Symmetries.two_qubit_reduction(qubitOp, num_particles)
num_qubits = qubitOp.num_qubits


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.