qiskit-metapackage icon indicating copy to clipboard operation
qiskit-metapackage copied to clipboard

QuantumCircuit doesn't have set_density_matrix()

Open aleksey-uvarov opened this issue 1 year ago • 1 comments

Informations

  • Qiskit version: 0.37
  • Python version: 3.8.0
  • Operating system: Ubuntu 18.04

What is the current behavior?

Calling the set_density_matrix() method on a QuantumCircuit object returns an error, saying that there is no such attribute. The documentation, on the other hand, does list this function: https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.set_density_matrix.html

Steps to reproduce the problem

Run the following commands in a python console:

>>> from qiskit import QuantumCircuit >>> circ = QuantumCircuit(2) >>> 'set_density_matrix' in dir(circ)

The last line outputs False.

What is the expected behavior?

QuantumCircuit does possess a function set_density_matrix()

aleksey-uvarov avatar Jul 28 '22 11:07 aleksey-uvarov

Thanks for reporting this issue. the method set_density_matrix is added after Qiskit Aer is imported. Please see related discussions in https://github.com/Qiskit/qiskit-terra/issues/6346

HuangJunye avatar Aug 16 '22 08:08 HuangJunye

This is expected behaviour; Aer monkey-patches this method onto QuantumCircuit. People can fix this by doing import qiskit_aer. I'll close this now as not a bug, and would be the domain of Aer anyway.

jakelishman avatar Aug 04 '23 17:08 jakelishman