From a84b2ecff5d27610ba582e6b1ec21e8f20403156 Mon Sep 17 00:00:00 2001 From: Jason Ricciardi <115199204+ThirDecade2020@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:14:56 -0400 Subject: [PATCH 01/11] Update _utils.py Remove deprecated code: qiskit/visualization/circuit/_utils.py:200 qiskit/visualization/circuit/_utils.py:288 --- qiskit/visualization/circuit/_utils.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/qiskit/visualization/circuit/_utils.py b/qiskit/visualization/circuit/_utils.py index 3d8d5dc79edb..666386200aae 100644 --- a/qiskit/visualization/circuit/_utils.py +++ b/qiskit/visualization/circuit/_utils.py @@ -197,22 +197,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") -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) @@ -285,21 +282,18 @@ def get_wire_label(drawer, register, index, layout=None, cregbundle=True): return wire_label -@deprecate_arg("reverse_bits", since="0.22.0") -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]) From b472cfeb95cd8fcb05ee6d0d20c2880b298db317 Mon Sep 17 00:00:00 2001 From: Jason Ricciardi <115199204+ThirDecade2020@users.noreply.github.com> Date: Sat, 7 Oct 2023 16:32:38 -0400 Subject: [PATCH 02/11] Update counts_visualization.py There is code released 9 months ago that needs to be removed. qiskit/visualization/counts_visualization.py:60 Include an example with an alternative for user to migrate to the new code, as this change might break users code. --- qiskit/visualization/counts_visualization.py | 31 +++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index fb7ddba13185..6d1165364d55 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -57,17 +57,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, -) def plot_histogram( data, figsize=(7, 5), @@ -86,6 +75,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: + ---------------- + If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary + with `plot_histogram`, you should now use `plot_distribution()`. + + 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. + 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 From 11c00b056dee38c716edc35a12c2dad69674c853 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 10 Oct 2023 09:15:04 +0200 Subject: [PATCH 03/11] black --- qiskit/visualization/counts_visualization.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index 6d1165364d55..e85b78d6041e 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -75,18 +75,18 @@ 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 + Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. Migration Guide: ---------------- - If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary + If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary with `plot_histogram`, you should now use `plot_distribution()`. Example: ```python # Old way using plot_histogram with a hypothetical QuasiDistribution - quasi_data = QuasiDistribution(...) + quasi_data = QuasiDistribution(...) plot_histogram(quasi_data) # New recommended way @@ -94,7 +94,7 @@ def plot_histogram( ``` For other data types, continue using `plot_histogram` as usual. - + 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 From eec39ce502af2ffc19d195e49cf55b30e032c20b Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:17:43 -0500 Subject: [PATCH 04/11] Run tox --- qiskit/visualization/circuit/_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qiskit/visualization/circuit/_utils.py b/qiskit/visualization/circuit/_utils.py index 31bd2ecf3eb8..c14bb3d46c29 100644 --- a/qiskit/visualization/circuit/_utils.py +++ b/qiskit/visualization/circuit/_utils.py @@ -211,6 +211,7 @@ def get_bit_register(circuit, bit): bit_loc = circuit.find_bit(bit) return bit_loc.registers[0][0] if bit_loc.registers else 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. @@ -295,6 +296,7 @@ def get_wire_label(drawer, register, index, layout=None, cregbundle=True): return wire_label + def get_condition_label_val(condition, circuit, cregbundle): """Get the label and value list to display a condition From 3b41854e4199807cc79863510df2b82d1ef523e9 Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:53:57 -0500 Subject: [PATCH 05/11] Update qiskit/visualization/counts_visualization.py Co-authored-by: Matthew Treinish --- qiskit/visualization/counts_visualization.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index fcce8223bb64..f1cc1f775dec 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -77,8 +77,6 @@ def plot_histogram( Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. - Migration Guide: - ---------------- If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary with `plot_histogram`, you should now use `plot_distribution()`. From 646c533ca47301ee7a0697a96b504225e619131c Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:54:03 -0500 Subject: [PATCH 06/11] Update qiskit/visualization/counts_visualization.py Co-authored-by: Matthew Treinish --- qiskit/visualization/counts_visualization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index f1cc1f775dec..31c319b1f4e3 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -77,8 +77,8 @@ def plot_histogram( Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. - If you used `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary - with `plot_histogram`, you should now use `plot_distribution()`. + If you would like to plot a histogram from a `QuasiDistribution`, `ProbDistribution`, or a distribution + dictionary you should be using the :func:`.plot_distribution` function. Example: ```python From bdcb97c8653ac5d84848c2a818753a81bded0103 Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:54:11 -0500 Subject: [PATCH 07/11] Update qiskit/visualization/counts_visualization.py Co-authored-by: Matthew Treinish --- qiskit/visualization/counts_visualization.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index 31c319b1f4e3..d0b7c499a0a5 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -80,17 +80,6 @@ def plot_histogram( If you would like to plot a histogram from a `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary you should be using the :func:`.plot_distribution` function. - 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. figsize (tuple): Figure size in inches. color (list or str): String or list of strings for histogram bar colors. From 126f05a6fde478059be85bd9d195faea0da89243 Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:59:31 -0500 Subject: [PATCH 08/11] Cut down line length for lint --- qiskit/visualization/counts_visualization.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index d0b7c499a0a5..ed9d267a0618 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -77,8 +77,9 @@ def plot_histogram( Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. - If you would like to plot a histogram from a `QuasiDistribution`, `ProbDistribution`, or a distribution - dictionary you should be using the :func:`.plot_distribution` function. + If you would like to plot a histogram from a `QuasiDistribution`, + `ProbDistribution`, or a distribution dictionary you should be using the + :func:`.plot_distribution` function. figsize (tuple): Figure size in inches. From dde4aaf5248e18acfd55a9d772af3765b53cfa7c Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Thu, 18 Jan 2024 17:17:07 -0500 Subject: [PATCH 09/11] Run tox --- qiskit/visualization/counts_visualization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index ed9d267a0618..4c938fbd2dab 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -77,8 +77,8 @@ def plot_histogram( Note: Passing `QuasiDistribution`, `ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. - If you would like to plot a histogram from a `QuasiDistribution`, - `ProbDistribution`, or a distribution dictionary you should be using the + If you would like to plot a histogram from a `QuasiDistribution`, + `ProbDistribution`, or a distribution dictionary you should be using the :func:`.plot_distribution` function. From f0671baa07f89d0dae121d38e1145ef4f4872b5d Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:32:34 -0500 Subject: [PATCH 10/11] Add release notes --- qiskit/visualization/counts_visualization.py | 7 ------- ...ode-deprecated-in-0.22-7bc99235f5912424.yaml | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml diff --git a/qiskit/visualization/counts_visualization.py b/qiskit/visualization/counts_visualization.py index 4c938fbd2dab..546a027b5b79 100644 --- a/qiskit/visualization/counts_visualization.py +++ b/qiskit/visualization/counts_visualization.py @@ -74,13 +74,6 @@ 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. - - If you would like to plot a histogram from a `QuasiDistribution`, - `ProbDistribution`, or a distribution dictionary you should be using the - :func:`.plot_distribution` function. - figsize (tuple): Figure size in inches. color (list or str): String or list of strings for histogram bar colors. diff --git a/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml b/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml new file mode 100644 index 000000000000..d8b7d9626ac6 --- /dev/null +++ b/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml @@ -0,0 +1,17 @@ +deprecations: + - | + Removing deprecated visualization code (deprecated in 0.22). + + For plot_histogram visualization: Passing `QuasiDistribution`, `ProbDistribution`, + or a distribution dictionary to the `data` argument is deprecated. + If you would like to plot a histogram from a `QuasiDistribution`, + `ProbDistribution`, or a distribution dictionary you should be using the + :func:`.plot_distribution` function. + + Also removed reverse-bits argument deprecation from + -- `get_bit_get_index` + -- `get_condition_label_val` + -- + + + From db3325a663fbfaaf4f543213642458d1cc0678e3 Mon Sep 17 00:00:00 2001 From: Hunter Kemeny <43501602+hunterkemeny@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:26:54 -0500 Subject: [PATCH 11/11] Update releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml Co-authored-by: Julien Gacon --- ...on-code-deprecated-in-0.22-7bc99235f5912424.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml b/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml index d8b7d9626ac6..a2d5e7cbbc71 100644 --- a/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml +++ b/releasenotes/notes/remove-visualization-code-deprecated-in-0.22-7bc99235f5912424.yaml @@ -2,16 +2,15 @@ deprecations: - | Removing deprecated visualization code (deprecated in 0.22). - For plot_histogram visualization: Passing `QuasiDistribution`, `ProbDistribution`, - or a distribution dictionary to the `data` argument is deprecated. - If you would like to plot a histogram from a `QuasiDistribution`, - `ProbDistribution`, or a distribution dictionary you should be using the + For :func:`.plot_histogram` visualization: Passing :class:`.QuasiDistribution`, + :class:`.ProbDistribution`, or a distribution dictionary to the `data` argument is deprecated. + If you would like to plot a histogram from a :class:`.QuasiDistribution`, + :class:`.ProbDistribution`, or a distribution dictionary you should be using the :func:`.plot_distribution` function. Also removed reverse-bits argument deprecation from - -- `get_bit_get_index` - -- `get_condition_label_val` - -- + -- :func:`.get_bit_get_index` + -- :func:`.get_condition_label_val`