Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.11k stars 2.34k forks source link

Matplotlib plots of Grover broken locally and on IBM Q Experience #7503

Open jwoehr opened 2 years ago

jwoehr commented 2 years ago

Environment

_On local machine__

What is happening?

Matplotlib drawing of Grover oracle in Qiskit example draws incorrectly.

How can we reproduce the issue?

from qiskit import QuantumCircuit
from qiskit.algorithms import AmplificationProblem

# the state we desire to find is '11'
good_state = ['11']

# specify the oracle that marks the state '11' as a good solution
oracle = QuantumCircuit(2)
oracle.cz(0, 1)

# define Grover's algorithm
problem = AmplificationProblem(oracle, is_good_state=good_state)

# now we can have a look at the Grover operator that is used in running the algorithm
problem.grover_operator.draw(output='mpl')

What should happen?

Drawing of entire oracle circuit. What you get instead is just a drawing of the first two qubit states

Any suggestions?

Reported on Qiskit Slack https://qiskit.slack.com/archives/C88B13092/p1641501466002000

enavarro51 commented 2 years ago

I believe this is the result of #6634. You can get the detail back by doing

problem.grover_operator.decompose().draw(output='mpl')
jwoehr commented 2 years ago

Thanks @enavarro51 ... I think IBM Q Experience does not have a public repo? So I wonder how to file an issue or PR to fix the slightly misleading tutorial.

jwoehr commented 2 years ago

@enavarro51 found the tutorials. Sumbitted this PR, thanks for your help.

hu-milize commented 2 years ago

thank you both very much!