Skip to content

Commit

Permalink
Remove deprecations from mpl circuit drawer (#10020)
Browse files Browse the repository at this point in the history
* Remove deprecated args from mpl drawer

* Reno mod
  • Loading branch information
enavarro51 authored Apr 27, 2023
1 parent 4df6f3d commit 21caf38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 73 deletions.
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.

0 comments on commit 21caf38

Please sign in to comment.