From b410e5838e79b0deaf0ca4cc8d0481c9eaa6d542 Mon Sep 17 00:00:00 2001 From: Shelly Garion Date: Sun, 31 Dec 2023 10:03:18 +0000 Subject: [PATCH] move one_qubit_decompose from qiskit/quantum_info/synthesis to qiskit/synthesis/one_qubit --- qiskit/circuit/library/generalized_gates/rv.py | 4 ++-- qiskit/circuit/library/generalized_gates/uc.py | 2 +- .../circuit/library/generalized_gates/unitary.py | 2 +- qiskit/quantum_info/__init__.py | 2 -- qiskit/quantum_info/synthesis/__init__.py | 10 +++++++++- .../quantum_info/synthesis/two_qubit_decompose.py | 2 +- .../synthesis/xx_decompose/decomposer.py | 2 +- qiskit/synthesis/__init__.py | 12 ++++++++++++ qiskit/synthesis/one_qubit/__init__.py | 15 +++++++++++++++ .../one_qubit}/one_qubit_decompose.py | 0 qiskit/synthesis/unitary/qsd.py | 3 ++- .../optimization/optimize_1q_decomposition.py | 2 +- .../passes/scheduling/dynamical_decoupling.py | 2 +- .../scheduling/padding/dynamical_decoupling.py | 2 +- .../passes/synthesis/unitary_synthesis.py | 2 +- test/python/synthesis/test_synthesis.py | 2 +- 16 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 qiskit/synthesis/one_qubit/__init__.py rename qiskit/{quantum_info/synthesis => synthesis/one_qubit}/one_qubit_decompose.py (100%) diff --git a/qiskit/circuit/library/generalized_gates/rv.py b/qiskit/circuit/library/generalized_gates/rv.py index 04c065152fdc..7b137dde74c6 100644 --- a/qiskit/circuit/library/generalized_gates/rv.py +++ b/qiskit/circuit/library/generalized_gates/rv.py @@ -55,10 +55,10 @@ def __init__(self, v_x, v_y, v_z, basis="U"): v_y (float): y-component v_z (float): z-component basis (str, optional): basis (see - :class:`~qiskit.quantum_info.synthesis.one_qubit_decompose.OneQubitEulerDecomposer`) + :class:`~qiskit.synthesis.one_qubit.one_qubit_decompose.OneQubitEulerDecomposer`) """ # pylint: disable=cyclic-import - from qiskit.quantum_info.synthesis.one_qubit_decompose import OneQubitEulerDecomposer + from qiskit.synthesis.one_qubit.one_qubit_decompose import OneQubitEulerDecomposer super().__init__("rv", 1, [v_x, v_y, v_z]) self._decomposer = OneQubitEulerDecomposer(basis=basis) diff --git a/qiskit/circuit/library/generalized_gates/uc.py b/qiskit/circuit/library/generalized_gates/uc.py index 276480496c50..16077ca8af5f 100644 --- a/qiskit/circuit/library/generalized_gates/uc.py +++ b/qiskit/circuit/library/generalized_gates/uc.py @@ -35,7 +35,7 @@ from qiskit.exceptions import QiskitError # pylint: disable=cyclic-import -from qiskit.quantum_info.synthesis.one_qubit_decompose import OneQubitEulerDecomposer +from qiskit.synthesis.one_qubit.one_qubit_decompose import OneQubitEulerDecomposer from .diagonal import Diagonal diff --git a/qiskit/circuit/library/generalized_gates/unitary.py b/qiskit/circuit/library/generalized_gates/unitary.py index 6d0cdf0f949f..f6e07490c6cd 100644 --- a/qiskit/circuit/library/generalized_gates/unitary.py +++ b/qiskit/circuit/library/generalized_gates/unitary.py @@ -28,7 +28,7 @@ from qiskit.quantum_info.operators.predicates import is_unitary_matrix # pylint: disable=cyclic-import -from qiskit.quantum_info.synthesis.one_qubit_decompose import OneQubitEulerDecomposer +from qiskit.synthesis.one_qubit.one_qubit_decompose import OneQubitEulerDecomposer from qiskit.quantum_info.synthesis.two_qubit_decompose import two_qubit_cnot_decompose from .isometry import Isometry diff --git a/qiskit/quantum_info/__init__.py b/qiskit/quantum_info/__init__.py index 8f3cba468207..ec9a102eab6f 100644 --- a/qiskit/quantum_info/__init__.py +++ b/qiskit/quantum_info/__init__.py @@ -116,7 +116,6 @@ .. autosummary:: :toctree: ../stubs/ - OneQubitEulerDecomposer TwoQubitBasisDecomposer XXDecomposer @@ -167,7 +166,6 @@ negativity, ) from .synthesis import ( - OneQubitEulerDecomposer, TwoQubitBasisDecomposer, XXDecomposer, two_qubit_cnot_decompose, diff --git a/qiskit/quantum_info/synthesis/__init__.py b/qiskit/quantum_info/synthesis/__init__.py index b682ca400079..216c4a6823cb 100644 --- a/qiskit/quantum_info/synthesis/__init__.py +++ b/qiskit/quantum_info/synthesis/__init__.py @@ -13,6 +13,14 @@ """State and Unitary synthesis methods.""" from __future__ import annotations +import warnings +from qiskit.synthesis.one_qubit import OneQubitEulerDecomposer from .two_qubit_decompose import TwoQubitBasisDecomposer, two_qubit_cnot_decompose -from .one_qubit_decompose import OneQubitEulerDecomposer from .xx_decompose.decomposer import XXDecomposer + +warnings.warn( + "The qiskit.quantum_info.synthesis module is pending deprecation since Qiskit 0.46.0." + "It will be deprecated in a following release, no sooner than 3 months after the 0.46.0 release.", + stacklevel=2, + category=PendingDeprecationWarning, +) diff --git a/qiskit/quantum_info/synthesis/two_qubit_decompose.py b/qiskit/quantum_info/synthesis/two_qubit_decompose.py index ba5e99d3064f..636830ac1e99 100644 --- a/qiskit/quantum_info/synthesis/two_qubit_decompose.py +++ b/qiskit/quantum_info/synthesis/two_qubit_decompose.py @@ -40,7 +40,7 @@ from qiskit.exceptions import QiskitError from qiskit.quantum_info.operators import Operator from qiskit.quantum_info.synthesis.weyl import weyl_coordinates, transform_to_magic_basis -from qiskit.quantum_info.synthesis.one_qubit_decompose import ( +from qiskit.synthesis.one_qubit.one_qubit_decompose import ( OneQubitEulerDecomposer, DEFAULT_ATOL, ) diff --git a/qiskit/quantum_info/synthesis/xx_decompose/decomposer.py b/qiskit/quantum_info/synthesis/xx_decompose/decomposer.py index e83cf5c18dab..084347e56a41 100644 --- a/qiskit/quantum_info/synthesis/xx_decompose/decomposer.py +++ b/qiskit/quantum_info/synthesis/xx_decompose/decomposer.py @@ -25,7 +25,7 @@ from qiskit.circuit.library.standard_gates import RXXGate, RZXGate from qiskit.exceptions import QiskitError from qiskit.quantum_info.operators import Operator -from qiskit.quantum_info.synthesis.one_qubit_decompose import ONE_QUBIT_EULER_BASIS_GATES +from qiskit.synthesis.one_qubit.one_qubit_decompose import ONE_QUBIT_EULER_BASIS_GATES from qiskit.quantum_info.synthesis.two_qubit_decompose import TwoQubitWeylDecomposition from .circuits import apply_reflection, apply_shift, canonical_xx_circuit diff --git a/qiskit/synthesis/__init__.py b/qiskit/synthesis/__init__.py index 86b2fc1e6194..10b25890a2d4 100644 --- a/qiskit/synthesis/__init__.py +++ b/qiskit/synthesis/__init__.py @@ -94,6 +94,17 @@ .. autofunction:: qs_decomposition +One-qubit Synthesis +=================== + +.. autosummary:: + :toctree: ../stubs/ + + OneQubitEulerDecomposer + +Two-qubits Synthesis +==================== + """ from .evolution import ( @@ -132,3 +143,4 @@ from .discrete_basis import SolovayKitaevDecomposition, generate_basic_approximations from .qft import synth_qft_line from .unitary.qsd import qs_decomposition +from .one_qubit import OneQubitEulerDecomposer diff --git a/qiskit/synthesis/one_qubit/__init__.py b/qiskit/synthesis/one_qubit/__init__.py new file mode 100644 index 000000000000..b36895d47cf2 --- /dev/null +++ b/qiskit/synthesis/one_qubit/__init__.py @@ -0,0 +1,15 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2017 - 2023. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +"""Module containing one qubit unitary synthesis methods.""" + +from .one_qubit_decompose import OneQubitEulerDecomposer diff --git a/qiskit/quantum_info/synthesis/one_qubit_decompose.py b/qiskit/synthesis/one_qubit/one_qubit_decompose.py similarity index 100% rename from qiskit/quantum_info/synthesis/one_qubit_decompose.py rename to qiskit/synthesis/one_qubit/one_qubit_decompose.py diff --git a/qiskit/synthesis/unitary/qsd.py b/qiskit/synthesis/unitary/qsd.py index 525259672eb9..68858ed227be 100644 --- a/qiskit/synthesis/unitary/qsd.py +++ b/qiskit/synthesis/unitary/qsd.py @@ -18,7 +18,8 @@ import scipy import numpy as np from qiskit.circuit.quantumcircuit import QuantumCircuit, QuantumRegister -from qiskit.quantum_info.synthesis import two_qubit_decompose, one_qubit_decompose +from qiskit.quantum_info.synthesis import two_qubit_decompose +from qiskit.synthesis.one_qubit import one_qubit_decompose from qiskit.quantum_info.operators.predicates import is_hermitian_matrix from qiskit.circuit.library.generalized_gates.uc_pauli_rot import UCPauliRotGate, _EPS from qiskit.circuit.library.generalized_gates.ucry import UCRYGate diff --git a/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py b/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py index 9eb31b8f8134..8a09a2bea348 100644 --- a/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +++ b/qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py @@ -17,7 +17,7 @@ from qiskit.transpiler.basepasses import TransformationPass from qiskit.transpiler.passes.utils import control_flow -from qiskit.quantum_info.synthesis import one_qubit_decompose +from qiskit.synthesis.one_qubit import one_qubit_decompose from qiskit._accelerate import euler_one_qubit_decomposer from qiskit.circuit.library.standard_gates import ( UGate, diff --git a/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py b/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py index cf8477278372..6883e4cdc168 100644 --- a/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +++ b/qiskit/transpiler/passes/scheduling/dynamical_decoupling.py @@ -19,7 +19,7 @@ from qiskit.circuit.library.standard_gates import IGate, UGate, U3Gate from qiskit.dagcircuit import DAGOpNode, DAGInNode from qiskit.quantum_info.operators.predicates import matrix_equal -from qiskit.quantum_info.synthesis import OneQubitEulerDecomposer +from qiskit.synthesis.one_qubit import OneQubitEulerDecomposer from qiskit.transpiler.passes.optimization import Optimize1qGates from qiskit.transpiler.basepasses import TransformationPass from qiskit.transpiler.exceptions import TranspilerError diff --git a/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py b/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py index 97946c55df8b..8092ed562eb1 100644 --- a/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +++ b/qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py @@ -22,7 +22,7 @@ from qiskit.circuit.reset import Reset from qiskit.dagcircuit import DAGCircuit, DAGNode, DAGInNode, DAGOpNode from qiskit.quantum_info.operators.predicates import matrix_equal -from qiskit.quantum_info.synthesis import OneQubitEulerDecomposer +from qiskit.synthesis.one_qubit import OneQubitEulerDecomposer from qiskit.transpiler.exceptions import TranspilerError from qiskit.transpiler.instruction_durations import InstructionDurations from qiskit.transpiler.passes.optimization import Optimize1qGates diff --git a/qiskit/transpiler/passes/synthesis/unitary_synthesis.py b/qiskit/transpiler/passes/synthesis/unitary_synthesis.py index 5335a8251540..40c03d5f3fab 100644 --- a/qiskit/transpiler/passes/synthesis/unitary_synthesis.py +++ b/qiskit/transpiler/passes/synthesis/unitary_synthesis.py @@ -24,7 +24,7 @@ from qiskit.transpiler.basepasses import TransformationPass from qiskit.transpiler.exceptions import TranspilerError from qiskit.dagcircuit.dagcircuit import DAGCircuit -from qiskit.quantum_info.synthesis import one_qubit_decompose +from qiskit.synthesis.one_qubit import one_qubit_decompose from qiskit.quantum_info.synthesis.xx_decompose import XXDecomposer, XXEmbodiments from qiskit.quantum_info.synthesis.two_qubit_decompose import ( TwoQubitBasisDecomposer, diff --git a/test/python/synthesis/test_synthesis.py b/test/python/synthesis/test_synthesis.py index 9216ee3a919d..e12d2481d3b0 100644 --- a/test/python/synthesis/test_synthesis.py +++ b/test/python/synthesis/test_synthesis.py @@ -56,7 +56,7 @@ from qiskit.providers.basicaer import UnitarySimulatorPy from qiskit.quantum_info.operators import Operator from qiskit.quantum_info.random import random_unitary -from qiskit.quantum_info.synthesis.one_qubit_decompose import OneQubitEulerDecomposer +from qiskit.synthesis.one_qubit.one_qubit_decompose import OneQubitEulerDecomposer from qiskit.quantum_info.synthesis.two_qubit_decompose import ( TwoQubitWeylDecomposition, TwoQubitWeylIdEquiv,