Remove deprecations from mpl circuit drawer (#10020)

* Remove deprecated args from mpl drawer

* Reno mod
This commit is contained in:
Edwin Navarro 2023-04-27 08:24:12 -07:00 committed by GitHub
parent 4df6f3d088
commit 21caf38cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 73 deletions

View File

@ -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)

View File

@ -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 = {}

View File

@ -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.