Repository: Qiskit/qiskit

Issue:
Remove code deprecated in 0.22 (released on October 13, 2022) [visualization]
There is code released 9 month ago that needs to be removed.
 - `qiskit/visualization/counts_visualization.py:60`
 - `qiskit/visualization/circuit/_utils.py:200`
 - `qiskit/visualization/circuit/_utils.py:288`
  
This includes:
- [ ] Remove deprecated code and tests (if they only check the deprecation raise)
- [ ] tag the PR as [`Changelog: Removal`](https://github.com/Qiskit/qiskit/labels/Changelog%3A%20Removal)
- [ ] create a release note in the category `upgrade:`. If you can include an example with an alternative for user to migrate to the new code, as this change might break users code.

Related:
* https://github.com/Qiskit/qiskit/issues/10813
* https://github.com/Qiskit/qiskit/issues/10811
* https://github.com/Qiskit/qiskit/issues/10810


Discussion:
Hello @1ucian0 please assign me here. Separate PRs for removing code & removing tests (if needed)?
Assigned. Better doing those in the same PR
![Screenshot 2023-09-16 1 56 17 PM](https://github.com/Qiskit/qiskit/assets/115199204/a3b89729-65e1-42bb-bc8d-77005b95f468)
@1ucian0 I located code as seen in screenshot for 'line 200' example. When you say 'remove deprecated code', do you literally mean erase lines 200 thru 219, or do I need to implement changes to 'def get_bit_reg_index()' function according to the commented section? Once completed, what is the best way to search for tests checking related deprecation raises which need to be removed?

Thanks for your patience and help on this.
In this context, "remove deprecated code" means remove the decorator (that deprecates the argument `reverse_bits`), the argument (line 201), the documentation line (line 208) and its "usage" (line 215).
Thanks for the input I'm going to revisit ASAP when I get a moment.
Sorry to delay - new CS teaching job & family keeping me very busy but working on this now, hope to send PR before end of weekend.
```
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

    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
    """
    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)
    return register, bit_index, reg_index
```
Lining up my solutions here before PR if I did something wrong please let me know
```
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

    Returns:
        str: label to display for the condition
        list(str): list of 1's and 0's indicating values of condition
    """
    cond_is_bit = bool(isinstance(condition[0], Clbit))
    cond_val = int(condition[1])

    # if condition on a register, return list of 1's and 0's indicating
    # closed or open, else only one element is returned
    if isinstance(condition[0], ClassicalRegister) and not cregbundle:
        val_bits = list(f"{cond_val:0{condition[0].size}b}")[::-1]
    else:
        val_bits = list(str(cond_val))

    label = ""
    if cond_is_bit and cregbundle:
        register, _, reg_index = get_bit_reg_index(circuit, condition[0])
        if register is not None:
            label = f"{register.name}_{reg_index}={hex(cond_val)}"
    elif not cond_is_bit:
        label = hex(cond_val)

    return label, val_bits
```
```
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

    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
    """
    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)
    return register, bit_index, reg_index
```
I located the deprecated code to be removed, removed the deprecated code, and now I need to remove deprecated tests if they only check the deprecation raise. I believe this happens in 'qiskit / test / python / visualization / test_utils.py' (lines 65-84) or 'visualization.py' (none). Is this correct? Are these the only locations to search for deprecated tests with regard to 'utils.py' 'visualization.py' and 'reverse_bits'?
It's hard to track suggestions as comments. Would you like to try with a PR?
Yes setting up now and doing this issue today/tomorrow send PR. I want to do it via Linux Terminal so going over some stuff for that now. I used nano to run a Qiskit program to generate a Bell Pair for the first time directly in Terminal that was fun. Lastly, I'll work out testing and send thx.

Resolving patch:
diff --git a/qiskit/visualization/circuit/_utils.py b/qiskit/visualization/circuit/_utils.py
--- a/qiskit/visualization/circuit/_utils.py
+++ b/qiskit/visualization/circuit/_utils.py
@@ -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
 
@@ -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)
@@ -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])
 
diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py
--- a/qiskit/visualization/counts_visualization.py
+++ b/qiskit/visualization/counts_visualization.py
@@ -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
@@ -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,
-    pending=True,
-    package_name="qiskit-terra",
-)
 def plot_histogram(
     data,
     figsize=(7, 5),
@@ -87,6 +74,7 @@ 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}``)
+
         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


Test patch: