diff --git a/qiskit/visualization/circuit/circuit_visualization.py b/qiskit/visualization/circuit/circuit_visualization.py index f8cc4bc839..a2b5e25674 100644 --- a/qiskit/visualization/circuit/circuit_visualization.py +++ b/qiskit/visualization/circuit/circuit_visualization.py @@ -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) diff --git a/qiskit/visualization/circuit/matplotlib.py b/qiskit/visualization/circuit/matplotlib.py index 155afff437..b1b04ca660 100644 --- a/qiskit/visualization/circuit/matplotlib.py +++ b/qiskit/visualization/circuit/matplotlib.py @@ -20,8 +20,7 @@ from warnings import warn 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, @@ -69,21 +68,16 @@ class MatplotlibDrawer: 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 @@ -91,65 +85,7 @@ class MatplotlibDrawer: 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 = {} diff --git a/releasenotes/notes/remove-deprecated-mpl-drawer-9d6eaa40d5a86777.yaml b/releasenotes/notes/remove-deprecated-mpl-drawer-9d6eaa40d5a86777.yaml new file mode 100644 index 0000000000..59d8cef6d5 --- /dev/null +++ b/releasenotes/notes/remove-deprecated-mpl-drawer-9d6eaa40d5a86777.yaml @@ -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.