Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations from mpl circuit drawer #10020

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions qiskit/visualization/circuit/circuit_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,20 +649,15 @@ def _matplotlib_circuit_drawer(
qubits,
clbits,
nodes,
circuit,
scale=scale,
style=style,
reverse_bits=reverse_bits,
plot_barriers=plot_barriers,
layout=None,
fold=fold,
ax=ax,
initial_state=initial_state,
cregbundle=cregbundle,
global_phase=None,
calibrations=None,
qregs=None,
cregs=None,
with_layout=with_layout,
circuit=circuit,
)
return qcd.draw(filename)
70 changes: 3 additions & 67 deletions qiskit/visualization/circuit/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

import numpy as np

from qiskit.circuit import ControlledGate, Qubit, Clbit, ClassicalRegister
from qiskit.circuit import Measure, QuantumCircuit, QuantumRegister
from qiskit.circuit import ControlledGate, Qubit, Clbit, ClassicalRegister, Measure
from qiskit.circuit.library.standard_gates import (
SwapGate,
RZZGate,
Expand Down Expand Up @@ -69,87 +68,24 @@ def __init__(
qubits,
clbits,
nodes,
circuit,
scale=None,
style=None,
reverse_bits=False,
plot_barriers=True,
layout=None,
fold=25,
ax=None,
initial_state=False,
cregbundle=None,
global_phase=None,
qregs=None,
cregs=None,
calibrations=None,
with_layout=False,
circuit=None,
):
from matplotlib import patches
from matplotlib import pyplot as plt

self._patches_mod = patches
self._plt_mod = plt

if qregs is not None:
warn(
"The 'qregs' kwarg to the MatplotlibDrawer class is deprecated "
"as of 0.20.0 and will be removed no earlier than 3 months "
"after the release date.",
DeprecationWarning,
2,
)
if cregs is not None:
warn(
"The 'cregs' kwarg to the MatplotlibDrawer class is deprecated "
"as of 0.20.0 and will be removed no earlier than 3 months "
"after the release date.",
DeprecationWarning,
2,
)
if global_phase is not None:
warn(
"The 'global_phase' kwarg to the MatplotlibDrawer class is deprecated "
"as of 0.20.0 and will be removed no earlier than 3 months "
"after the release date.",
DeprecationWarning,
2,
)
if layout is not None:
warn(
"The 'layout' kwarg to the MatplotlibDrawer class is deprecated "
"as of 0.20.0 and will be removed no earlier than 3 months "
"after the release date.",
DeprecationWarning,
2,
)
if calibrations is not None:
warn(
"The 'calibrations' kwarg to the MatplotlibDrawer class is deprecated "
"as of 0.20.0 and will be removed no earlier than 3 months "
"after the release date.",
DeprecationWarning,
2,
)
# This check should be removed when the 5 deprecations above are removed
if circuit is None:
warn(
"The 'circuit' kwarg to the MaptlotlibDrawer class must be a valid "
"QuantumCircuit and not None. A new circuit is being created using "
"the qubits and clbits for rendering the drawing.",
DeprecationWarning,
2,
)
circ = QuantumCircuit(qubits, clbits)
for reg in qregs:
bits = [qubits[circ._qubit_indices[q].index] for q in reg]
circ.add_register(QuantumRegister(None, reg.name, list(bits)))
for reg in cregs:
bits = [clbits[circ._clbit_indices[q].index] for q in reg]
circ.add_register(ClassicalRegister(None, reg.name, list(bits)))
self._circuit = circ
else:
self._circuit = circuit
self._circuit = circuit
self._qubits = qubits
self._clbits = clbits
self._qubits_dict = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
upgrade:
- |
In the internal ``qiskit.visualization.circuit.matplotlib.MatplotlibDrawer`` object, the arguments
``layout``, ``global_phase``, ``qregs`` and ``cregs`` have been removed. They were originally
deprecated in Qiskit Terra 0.20. These objects are simply inferred from the given ``circuit``
now.

This is an internal worker class of the visualization routines. It is unlikely you will
need to change any of your code.