diff --git a/cirq-core/cirq/__init__.py b/cirq-core/cirq/__init__.py index 3d8c90da603..3b09a3f152a 100644 --- a/cirq-core/cirq/__init__.py +++ b/cirq-core/cirq/__init__.py @@ -328,12 +328,7 @@ from cirq.optimizers import ( AlignLeft, AlignRight, - compute_cphase_exponents_for_fsim_decomposition, ConvertToCzAndSingleGates, - decompose_clifford_tableau_to_operations, - decompose_cphase_into_two_fsim, - decompose_multi_controlled_x, - decompose_multi_controlled_rotation, decompose_two_qubit_interaction_into_four_fsim_gates, DropEmptyMoments, DropNegligible, @@ -360,6 +355,11 @@ ) from cirq.transformers import ( + compute_cphase_exponents_for_fsim_decomposition, + decompose_clifford_tableau_to_operations, + decompose_cphase_into_two_fsim, + decompose_multi_controlled_x, + decompose_multi_controlled_rotation, map_moments, map_operations, map_operations_and_unroll, diff --git a/cirq-core/cirq/optimizers/__init__.py b/cirq-core/cirq/optimizers/__init__.py index 5b09423b70e..7c1c9bacf87 100644 --- a/cirq-core/cirq/optimizers/__init__.py +++ b/cirq-core/cirq/optimizers/__init__.py @@ -22,18 +22,6 @@ AlignRight, ) -from cirq.optimizers.clifford_decomposition import decompose_clifford_tableau_to_operations - -from cirq.optimizers.cphase_to_fsim import ( - compute_cphase_exponents_for_fsim_decomposition, - decompose_cphase_into_two_fsim, -) - -from cirq.optimizers.controlled_gate_decomposition import ( - decompose_multi_controlled_x, - decompose_multi_controlled_rotation, -) - from cirq.optimizers.drop_empty_moments import ( DropEmptyMoments, ) @@ -105,3 +93,29 @@ from cirq.optimizers.two_qubit_to_fsim import ( decompose_two_qubit_interaction_into_four_fsim_gates, ) + +from cirq import _compat + +_compat.deprecated_submodule( + new_module_name="cirq.transformers.analytical_decompositions.clifford_decomposition", + old_parent="cirq.optimizers", + old_child="clifford_decomposition", + deadline="v0.16", + create_attribute=True, +) + +_compat.deprecated_submodule( + new_module_name="cirq.transformers.analytical_decompositions.cphase_to_fsim", + old_parent="cirq.optimizers", + old_child="cphase_to_fsim", + deadline="v0.16", + create_attribute=True, +) + +_compat.deprecated_submodule( + new_module_name="cirq.transformers.analytical_decompositions.controlled_gate_decomposition", + old_parent="cirq.optimizers", + old_child="controlled_gate_decomposition", + deadline="v0.16", + create_attribute=True, +) diff --git a/cirq-core/cirq/transformers/__init__.py b/cirq-core/cirq/transformers/__init__.py index 134d61427d7..d818e53a000 100644 --- a/cirq-core/cirq/transformers/__init__.py +++ b/cirq-core/cirq/transformers/__init__.py @@ -15,6 +15,11 @@ """Circuit transformation utilities.""" from cirq.transformers.analytical_decompositions import ( + compute_cphase_exponents_for_fsim_decomposition, + decompose_cphase_into_two_fsim, + decompose_clifford_tableau_to_operations, + decompose_multi_controlled_x, + decompose_multi_controlled_rotation, prepare_two_qubit_state_using_cz, prepare_two_qubit_state_using_sqrt_iswap, ) diff --git a/cirq-core/cirq/transformers/analytical_decompositions/__init__.py b/cirq-core/cirq/transformers/analytical_decompositions/__init__.py index 0ed5ca0bbe1..c8e0e456bbd 100644 --- a/cirq-core/cirq/transformers/analytical_decompositions/__init__.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/__init__.py @@ -14,6 +14,20 @@ """Utilities for analytical decomposition of cirq gates.""" +from cirq.transformers.analytical_decompositions.clifford_decomposition import ( + decompose_clifford_tableau_to_operations, +) + +from cirq.transformers.analytical_decompositions.controlled_gate_decomposition import ( + decompose_multi_controlled_x, + decompose_multi_controlled_rotation, +) + +from cirq.transformers.analytical_decompositions.cphase_to_fsim import ( + compute_cphase_exponents_for_fsim_decomposition, + decompose_cphase_into_two_fsim, +) + from cirq.transformers.analytical_decompositions.two_qubit_state_preparation import ( prepare_two_qubit_state_using_cz, prepare_two_qubit_state_using_sqrt_iswap, diff --git a/cirq-core/cirq/optimizers/clifford_decomposition.py b/cirq-core/cirq/transformers/analytical_decompositions/clifford_decomposition.py similarity index 100% rename from cirq-core/cirq/optimizers/clifford_decomposition.py rename to cirq-core/cirq/transformers/analytical_decompositions/clifford_decomposition.py diff --git a/cirq-core/cirq/optimizers/clifford_decomposition_test.py b/cirq-core/cirq/transformers/analytical_decompositions/clifford_decomposition_test.py similarity index 95% rename from cirq-core/cirq/optimizers/clifford_decomposition_test.py rename to cirq-core/cirq/transformers/analytical_decompositions/clifford_decomposition_test.py index 64ba424ce51..75c016897a6 100644 --- a/cirq-core/cirq/optimizers/clifford_decomposition_test.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/clifford_decomposition_test.py @@ -18,6 +18,16 @@ import cirq from cirq.testing import assert_allclose_up_to_global_phase +ALLOW_DEPRECATION_IN_TEST = 'ALLOW_DEPRECATION_IN_TEST' + + +def test_deprecated_submodule(): + with cirq.testing.assert_deprecated( + "Use cirq.transformers.analytical_decompositions.clifford_decomposition instead", + deadline="v0.16", + ): + _ = cirq.optimizers.clifford_decomposition.decompose_clifford_tableau_to_operations + def test_misaligned_qubits(): qubits = cirq.LineQubit.range(1) diff --git a/cirq-core/cirq/optimizers/controlled_gate_decomposition.py b/cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py similarity index 100% rename from cirq-core/cirq/optimizers/controlled_gate_decomposition.py rename to cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py diff --git a/cirq-core/cirq/optimizers/controlled_gate_decomposition_test.py b/cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py similarity index 93% rename from cirq-core/cirq/optimizers/controlled_gate_decomposition_test.py rename to cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py index 2c67c5e86ea..1bbe22ffa6b 100644 --- a/cirq-core/cirq/optimizers/controlled_gate_decomposition_test.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py @@ -17,6 +17,16 @@ import cirq +ALLOW_DEPRECATION_IN_TEST = 'ALLOW_DEPRECATION_IN_TEST' + + +def test_deprecated_submodule(): + with cirq.testing.assert_deprecated( + "Use cirq.transformers.analytical_decompositions.controlled_gate_decomposition instead", + deadline="v0.16", + ): + _ = cirq.optimizers.controlled_gate_decomposition.decompose_multi_controlled_rotation + def test_decompose_x(): """Verifies correctness of multi-controlled X decomposition.""" diff --git a/cirq-core/cirq/optimizers/cphase_to_fsim.py b/cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim.py similarity index 93% rename from cirq-core/cirq/optimizers/cphase_to_fsim.py rename to cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim.py index f763e5aaecf..b766795bdb5 100644 --- a/cirq-core/cirq/optimizers/cphase_to_fsim.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim.py @@ -1,4 +1,17 @@ -# pylint: disable=wrong-or-nonexistent-copyright-notice +# Copyright 2021 The Cirq Developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from typing import Optional, Sequence, Tuple, TYPE_CHECKING import numpy as np diff --git a/cirq-core/cirq/optimizers/cphase_to_fsim_test.py b/cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py similarity index 84% rename from cirq-core/cirq/optimizers/cphase_to_fsim_test.py rename to cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py index f8d1c813fc1..c5323607c1c 100644 --- a/cirq-core/cirq/optimizers/cphase_to_fsim_test.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py @@ -1,4 +1,17 @@ -# pylint: disable=wrong-or-nonexistent-copyright-notice +# Copyright 2021 The Cirq Developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from typing import List, Sequence, Tuple import itertools @@ -8,6 +21,15 @@ import cirq +ALLOW_DEPRECATION_IN_TEST = 'ALLOW_DEPRECATION_IN_TEST' + + +def test_deprecated_submodule(): + with cirq.testing.assert_deprecated( + "Use cirq.transformers.analytical_decompositions.cphase_to_fsim instead", deadline="v0.16" + ): + _ = cirq.optimizers.cphase_to_fsim.decompose_cphase_into_two_fsim + class FakeSycamoreGate(cirq.FSimGate): def __init__(self):