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 visualization code deprecated in 0.22 (released on October 13, 2022) #10989

Merged
merged 14 commits into from
Jan 29, 2024
Merged
11 changes: 2 additions & 9 deletions qiskit/visualization/circuit/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from qiskit.circuit.tools import pi_check
from qiskit.converters import circuit_to_dag
from qiskit.utils import optionals as _optionals
from qiskit.utils.deprecation import deprecate_arg

from ..exceptions import VisualizationError

Expand Down Expand Up @@ -213,22 +212,19 @@ def get_bit_register(circuit, bit):
return bit_loc.registers[0][0] if bit_loc.registers else None


@deprecate_arg("reverse_bits", since="0.22.0", package_name="qiskit-terra")
def get_bit_reg_index(circuit, bit, reverse_bits=None):
def get_bit_reg_index(circuit, bit):
"""Get the register for a bit if there is one, and the index of the bit
from the top of the circuit, or the index of the bit within a register.

Args:
circuit (QuantumCircuit): the circuit being drawn
bit (Qubit, Clbit): the bit to use to find the register and indexes
reverse_bits (bool): deprecated option to reverse order of the bits

Returns:
(ClassicalRegister, None): register associated with the bit
int: index of the bit from the top of the circuit
int: index of the bit within the register, if there is a register
"""
del reverse_bits
bit_loc = circuit.find_bit(bit)
bit_index = bit_loc.index
register, reg_index = bit_loc.registers[0] if bit_loc.registers else (None, None)
Expand Down Expand Up @@ -301,21 +297,18 @@ def get_wire_label(drawer, register, index, layout=None, cregbundle=True):
return wire_label


@deprecate_arg("reverse_bits", since="0.22.0", package_name="qiskit-terra")
def get_condition_label_val(condition, circuit, cregbundle, reverse_bits=None):
def get_condition_label_val(condition, circuit, cregbundle):
"""Get the label and value list to display a condition

Args:
condition (Union[Clbit, ClassicalRegister], int): classical condition
circuit (QuantumCircuit): the circuit that is being drawn
cregbundle (bool): if set True bundle classical registers
reverse_bits (bool): deprecated option to reverse order of the bits

Returns:
str: label to display for the condition
list(str): list of 1's and 0's indicating values of condition
"""
del reverse_bits
cond_is_bit = bool(isinstance(condition[0], Clbit))
cond_val = int(condition[1])

Expand Down
33 changes: 20 additions & 13 deletions qiskit/visualization/counts_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import numpy as np

from qiskit.utils import optionals as _optionals
from qiskit.utils.deprecation import deprecate_arg
from qiskit.result import QuasiDistribution, ProbDistribution
from .exceptions import VisualizationError
from .utils import matplotlib_close_if_inline
Expand Down Expand Up @@ -57,18 +56,6 @@ def _is_deprecated_data_format(data) -> bool:
return False


@deprecate_arg(
"data",
deprecation_description=(
"Using plot_histogram() ``data`` argument with QuasiDistribution, ProbDistribution, or a "
"distribution dictionary"
),
since="0.22.0",
additional_msg="Instead, use ``plot_distribution()``.",
predicate=_is_deprecated_data_format,
hunterkemeny marked this conversation as resolved.
Show resolved Hide resolved
pending=True,
hunterkemeny marked this conversation as resolved.
Show resolved Hide resolved
package_name="qiskit-terra",
)
def plot_histogram(
data,
figsize=(7, 5),
Expand All @@ -87,6 +74,26 @@ def plot_histogram(
Args:
data (list or dict): This is either a list of dictionaries or a single
dict containing the values to represent (ex ``{'001': 130}``)
Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary
to the `data` argument is deprecated.

Migration Guide:
----------------
hunterkemeny marked this conversation as resolved.
Show resolved Hide resolved
If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary
with `plot_histogram`, you should now use `plot_distribution()`.
hunterkemeny marked this conversation as resolved.
Show resolved Hide resolved

Example:
```python
# Old way using plot_histogram with a hypothetical QuasiDistribution
quasi_data = QuasiDistribution(...)
plot_histogram(quasi_data)

# New recommended way
plot_distribution(quasi_data)
```

For other data types, continue using `plot_histogram` as usual.
hunterkemeny marked this conversation as resolved.
Show resolved Hide resolved

figsize (tuple): Figure size in inches.
color (list or str): String or list of strings for histogram bar colors.
number_to_keep (int): The number of terms to plot per dataset. The rest is made into a
Expand Down
Loading