Skip to content

Commit

Permalink
Remove qiskit.quantum_info.synthesis for Qiskit 1.0 release (#11592)
Browse files Browse the repository at this point in the history
* remove deprecated code in clifford_decompose and cnotdihedral_decompose

* move tests from test/python/quantum_info to test/python/synthesis

* move the Quaternion class from quantum_info/synthesis to quantum_info

* deprecate cnot_rxx_decompose, and move to an internal code in the equivalence_library

* deprecate cnot_rxx_decompose

* move qsd from qiskit/quantum_info/synthesis to qiskit/synthesis/unitary

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle cyclic imports in qsd

* minor

* update qsd docs

* move one_qubit_decompose from qiskit/quantum_info/synthesis to qiskit/synthesis/one_qubit

* move xx_decompose from qiskit/quantum_info/synthesis to qiskit/synthesis/two_qubits

* handle cyclic imports

* move two-qubit synthesis code from qiskit/quantum_info/synthesis to qiskit/synthesis/two_qubits

* update qsd docs

* minor

* add release notes

* updates following review

* add disable cyclic import to rv.py

* add deprecation warning in qiskit/quantum_info/__init__.py

* fix links

* improve qsd docs following review

* remove qiskit.quantum_info.synthesis

* add release notes

* update qsd docs

* update release notes

* update release notes
  • Loading branch information
ShellyGarion committed Jan 29, 2024
1 parent bc26434 commit 5358110
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 156 deletions.
23 changes: 0 additions & 23 deletions qiskit/quantum_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,3 @@
negativity,
)
from .quaternion import Quaternion

_DEPRECATED_NAMES = {
"OneQubitEulerDecomposer": "qiskit.synthesis",
"TwoQubitBasisDecomposer": "qiskit.synthesis",
"XXDecomposer": "qiskit.synthesis",
"two_qubit_cnot_decompose": "qiskit.synthesis",
}


def __getattr__(name):
if name in _DEPRECATED_NAMES:
import importlib
import warnings

module_name = _DEPRECATED_NAMES[name]
warnings.warn(
f"Accessing '{name}' from '{__name__}' is deprecated since Qiskit 0.46"
f" and will be removed in 1.0. Import from '{module_name}' instead.",
DeprecationWarning,
stacklevel=2,
)
return getattr(importlib.import_module(module_name), name)
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
30 changes: 0 additions & 30 deletions qiskit/quantum_info/synthesis/__init__.py

This file was deleted.

57 changes: 0 additions & 57 deletions qiskit/quantum_info/synthesis/ion_decompose.py

This file was deleted.

13 changes: 13 additions & 0 deletions releasenotes/notes/remove_qinfo_synthesis-1917c7ccfcc62180.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
upgrade:
- |
Removed the ``qiskit.quantum_info.synthesis`` module, which has been deprecated since the 0.46 release.
The following objects have been moved to :mod:`qiskit.synthesis`:
* :class:`~.OneQubitEulerDecomposer` has been moved to :mod:`qiskit.synthesis.one_qubit`
* :class:`~.TwoQubitBasisDecomposer` has been moved to :mod:`qiskit.synthesis.two_qubits`
* :class:`~.XXDecomposer` has been moved to :mod:`qiskit.synthesis.two_qubits`
* :func:`~.two_qubit_cnot_decompose` has been moved to :mod:`qiskit.synthesis.two_qubits`
This function was removed, since it has already been deprecated in the 0.46 release:
* ``cnot_rxx_decompose``
38 changes: 0 additions & 38 deletions test/python/synthesis/test_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@

from qiskit.synthesis.unitary import qsd
from qiskit.test import QiskitTestCase
from qiskit.quantum_info.synthesis.ion_decompose import cnot_rxx_decompose


def make_oneq_cliffords():
Expand Down Expand Up @@ -630,14 +629,6 @@ def test_float_input_angles(self):
self.assertAlmostEqual(phi, expected_phi)
self.assertAlmostEqual(lam, expected_lam)

def test_deprecation(self):
"""Assert that importing this class from quantum_info raises a deprecation warning."""
# pylint: disable = no-name-in-module
with self.assertWarns(DeprecationWarning):
from qiskit.quantum_info import OneQubitEulerDecomposer as old_OneQubitEulerDecomposer

_ = old_OneQubitEulerDecomposer(basis="PSX")


# FIXME: streamline the set of test cases
class TestTwoQubitWeylDecomposition(CheckDecompositions):
Expand Down Expand Up @@ -988,21 +979,6 @@ def test_weyl_specialize_general(self, aaa=0.456, bbb=0.345, ccc=0.123):
class TestTwoQubitDecompose(CheckDecompositions):
"""Test TwoQubitBasisDecomposer() for exact/approx decompositions"""

def test_cnot_rxx_decompose(self):
"""Verify CNOT decomposition into RXX gate is correct"""
cnot = Operator(CXGate())
# Assert that this class raises a deprecation warning
with self.assertWarns(DeprecationWarning):
decomps = [
cnot_rxx_decompose(),
cnot_rxx_decompose(plus_ry=True, plus_rxx=True),
cnot_rxx_decompose(plus_ry=True, plus_rxx=False),
cnot_rxx_decompose(plus_ry=False, plus_rxx=True),
cnot_rxx_decompose(plus_ry=False, plus_rxx=False),
]
for decomp in decomps:
self.assertTrue(cnot.equiv(decomp))

@combine(seed=range(10), name="test_exact_two_qubit_cnot_decompose_random_{seed}")
def test_exact_two_qubit_cnot_decompose_random(self, seed):
"""Verify exact CNOT decomposition for random Haar 4x4 unitary (seed={seed})."""
Expand Down Expand Up @@ -1253,20 +1229,6 @@ def test_euler_basis_selection(self, euler_bases, kak_gates, seed):
requested_basis = set(oneq_gates + [kak_gate_name])
self.assertTrue(decomposition_basis.issubset(requested_basis))

def test_deprecation(self):
"""Assert that importing these classes from quantum_info raises a deprecation warning."""
# pylint: disable = no-name-in-module
with self.assertWarns(DeprecationWarning):
unitary = random_unitary(4, seed=1234)
from qiskit.quantum_info import TwoQubitBasisDecomposer as old_TwoQubitBasisDecomposer

_ = old_TwoQubitBasisDecomposer(unitary)

with self.assertWarns(DeprecationWarning):
from qiskit.quantum_info import two_qubit_cnot_decompose as old_two_qubit_cnot_decompose

_ = old_two_qubit_cnot_decompose(unitary)


@ddt
class TestPulseOptimalDecompose(CheckDecompositions):
Expand Down
8 changes: 0 additions & 8 deletions test/python/synthesis/xx_decompose/test_decomposer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,3 @@ def test_no_error_on_empty_basis_fidelity_trivial_target(self):
mat = Operator(qc).to_matrix()
dqc = decomposer(mat)
self.assertTrue(np.allclose(mat, Operator(dqc).to_matrix()))

def test_deprecation(self):
"""Assert that importing this class from quantum_info raises a deprecation warning."""
# pylint: disable = no-name-in-module
with self.assertWarns(DeprecationWarning):
from qiskit.quantum_info import XXDecomposer as old_XXDecomposer

_ = old_XXDecomposer(euler_basis="PSX")

0 comments on commit 5358110

Please sign in to comment.