mirror of https://github.com/Qiskit/qiskit.git
Remove deprecations from mpl circuit drawer (#10020)
* Remove deprecated args from mpl drawer * Reno mod
This commit is contained in:
parent
4df6f3d088
commit
21caf38cde
|
@ -649,20 +649,15 @@ def _matplotlib_circuit_drawer(
|
||||||
qubits,
|
qubits,
|
||||||
clbits,
|
clbits,
|
||||||
nodes,
|
nodes,
|
||||||
|
circuit,
|
||||||
scale=scale,
|
scale=scale,
|
||||||
style=style,
|
style=style,
|
||||||
reverse_bits=reverse_bits,
|
reverse_bits=reverse_bits,
|
||||||
plot_barriers=plot_barriers,
|
plot_barriers=plot_barriers,
|
||||||
layout=None,
|
|
||||||
fold=fold,
|
fold=fold,
|
||||||
ax=ax,
|
ax=ax,
|
||||||
initial_state=initial_state,
|
initial_state=initial_state,
|
||||||
cregbundle=cregbundle,
|
cregbundle=cregbundle,
|
||||||
global_phase=None,
|
|
||||||
calibrations=None,
|
|
||||||
qregs=None,
|
|
||||||
cregs=None,
|
|
||||||
with_layout=with_layout,
|
with_layout=with_layout,
|
||||||
circuit=circuit,
|
|
||||||
)
|
)
|
||||||
return qcd.draw(filename)
|
return qcd.draw(filename)
|
||||||
|
|
|
@ -20,8 +20,7 @@ from warnings import warn
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from qiskit.circuit import ControlledGate, Qubit, Clbit, ClassicalRegister
|
from qiskit.circuit import ControlledGate, Qubit, Clbit, ClassicalRegister, Measure
|
||||||
from qiskit.circuit import Measure, QuantumCircuit, QuantumRegister
|
|
||||||
from qiskit.circuit.library.standard_gates import (
|
from qiskit.circuit.library.standard_gates import (
|
||||||
SwapGate,
|
SwapGate,
|
||||||
RZZGate,
|
RZZGate,
|
||||||
|
@ -69,21 +68,16 @@ class MatplotlibDrawer:
|
||||||
qubits,
|
qubits,
|
||||||
clbits,
|
clbits,
|
||||||
nodes,
|
nodes,
|
||||||
|
circuit,
|
||||||
scale=None,
|
scale=None,
|
||||||
style=None,
|
style=None,
|
||||||
reverse_bits=False,
|
reverse_bits=False,
|
||||||
plot_barriers=True,
|
plot_barriers=True,
|
||||||
layout=None,
|
|
||||||
fold=25,
|
fold=25,
|
||||||
ax=None,
|
ax=None,
|
||||||
initial_state=False,
|
initial_state=False,
|
||||||
cregbundle=None,
|
cregbundle=None,
|
||||||
global_phase=None,
|
|
||||||
qregs=None,
|
|
||||||
cregs=None,
|
|
||||||
calibrations=None,
|
|
||||||
with_layout=False,
|
with_layout=False,
|
||||||
circuit=None,
|
|
||||||
):
|
):
|
||||||
from matplotlib import patches
|
from matplotlib import patches
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
@ -91,65 +85,7 @@ class MatplotlibDrawer:
|
||||||
self._patches_mod = patches
|
self._patches_mod = patches
|
||||||
self._plt_mod = plt
|
self._plt_mod = plt
|
||||||
|
|
||||||
if qregs is not None:
|
self._circuit = circuit
|
||||||
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._qubits = qubits
|
self._qubits = qubits
|
||||||
self._clbits = clbits
|
self._clbits = clbits
|
||||||
self._qubits_dict = {}
|
self._qubits_dict = {}
|
||||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue