cirq-core 1.6.0.dev20250519212157__py3-none-any.whl → 1.6.0.dev20250520002718__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cirq-core might be problematic. Click here for more details.

Files changed (166) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/frozen_circuit.py +2 -2
  4. cirq/contrib/acquaintance/topological_sort.py +2 -2
  5. cirq/contrib/custom_simulators/custom_state_simulator.py +2 -2
  6. cirq/contrib/paulistring/clifford_target_gateset.py +2 -2
  7. cirq/contrib/quantum_volume/quantum_volume.py +5 -3
  8. cirq/contrib/quimb/grid_circuits.py +4 -3
  9. cirq/contrib/quimb/state_vector.py +4 -2
  10. cirq/contrib/routing/router.py +2 -2
  11. cirq/experiments/qubit_characterizations.py +2 -1
  12. cirq/experiments/random_quantum_circuit_generation.py +2 -1
  13. cirq/experiments/two_qubit_xeb.py +2 -1
  14. cirq/linalg/predicates.py +1 -1
  15. cirq/ops/gate_operation.py +2 -1
  16. cirq/ops/linear_combinations.py +5 -5
  17. cirq/ops/pauli_string_phasor.py +2 -2
  18. cirq/ops/raw_types.py +2 -1
  19. cirq/sim/clifford/clifford_tableau_simulation_state.py +2 -2
  20. cirq/sim/clifford/stabilizer_ch_form_simulation_state.py +2 -2
  21. cirq/sim/clifford/stabilizer_simulation_state.py +2 -1
  22. cirq/sim/simulation_state_base.py +2 -1
  23. cirq/testing/consistent_protocols.py +2 -0
  24. cirq/testing/consistent_protocols_test.py +4 -2
  25. cirq/testing/consistent_qasm.py +2 -0
  26. cirq/testing/consistent_qasm_test.py +2 -0
  27. cirq/testing/consistent_resolve_parameters.py +2 -0
  28. cirq/testing/consistent_specified_has_unitary.py +2 -0
  29. cirq/testing/consistent_specified_has_unitary_test.py +2 -0
  30. cirq/testing/consistent_unitary.py +2 -0
  31. cirq/testing/consistent_unitary_test.py +2 -0
  32. cirq/testing/deprecation.py +3 -0
  33. cirq/testing/deprecation_test.py +3 -0
  34. cirq/testing/devices.py +4 -0
  35. cirq/testing/devices_test.py +3 -0
  36. cirq/testing/equals_tester.py +2 -0
  37. cirq/testing/equals_tester_test.py +2 -0
  38. cirq/testing/equivalent_basis_map.py +2 -0
  39. cirq/testing/equivalent_basis_map_test.py +3 -0
  40. cirq/testing/equivalent_repr_eval.py +2 -0
  41. cirq/testing/equivalent_repr_eval_test.py +2 -0
  42. cirq/testing/gate_features.py +2 -0
  43. cirq/testing/gate_features_test.py +2 -0
  44. cirq/testing/json.py +6 -2
  45. cirq/testing/json_test.py +2 -0
  46. cirq/testing/lin_alg_utils_test.py +2 -0
  47. cirq/testing/logs.py +4 -0
  48. cirq/testing/logs_test.py +2 -0
  49. cirq/testing/no_identifier_qubit.py +3 -0
  50. cirq/testing/no_identifier_qubit_test.py +2 -0
  51. cirq/testing/op_tree.py +2 -0
  52. cirq/testing/op_tree_test.py +3 -0
  53. cirq/testing/order_tester.py +2 -0
  54. cirq/testing/order_tester_test.py +2 -0
  55. cirq/testing/pytest_utils.py +2 -0
  56. cirq/testing/pytest_utils_test.py +2 -0
  57. cirq/testing/random_circuit_test.py +3 -0
  58. cirq/testing/repr_pretty_tester.py +1 -0
  59. cirq/testing/repr_pretty_tester_test.py +2 -0
  60. cirq/testing/routing_devices_test.py +3 -0
  61. cirq/testing/sample_circuits_test.py +2 -0
  62. cirq/testing/sample_gates.py +3 -0
  63. cirq/testing/sample_gates_test.py +3 -0
  64. cirq/transformers/align_test.py +2 -0
  65. cirq/transformers/analytical_decompositions/clifford_decomposition_test.py +2 -0
  66. cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py +2 -0
  67. cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py +2 -0
  68. cirq/transformers/analytical_decompositions/pauli_string_decomposition.py +2 -0
  69. cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py +2 -0
  70. cirq/transformers/analytical_decompositions/quantum_shannon_decomposition_test.py +2 -0
  71. cirq/transformers/analytical_decompositions/single_qubit_decompositions.py +2 -0
  72. cirq/transformers/analytical_decompositions/single_qubit_decompositions_test.py +2 -0
  73. cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry_test.py +3 -0
  74. cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +2 -0
  75. cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +2 -0
  76. cirq/transformers/analytical_decompositions/two_qubit_state_preparation_test.py +2 -0
  77. cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +2 -0
  78. cirq/transformers/analytical_decompositions/two_qubit_to_fsim_test.py +2 -0
  79. cirq/transformers/analytical_decompositions/two_qubit_to_ms.py +2 -2
  80. cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py +2 -0
  81. cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py +2 -0
  82. cirq/transformers/drop_empty_moments_test.py +2 -0
  83. cirq/transformers/drop_negligible_operations_test.py +2 -0
  84. cirq/transformers/eject_phased_paulis_test.py +3 -0
  85. cirq/transformers/eject_z_test.py +2 -0
  86. cirq/transformers/expand_composite_test.py +2 -0
  87. cirq/transformers/gauge_compiling/cphase_gauge_test.py +2 -0
  88. cirq/transformers/gauge_compiling/cz_gauge.py +2 -0
  89. cirq/transformers/gauge_compiling/cz_gauge_test.py +1 -0
  90. cirq/transformers/gauge_compiling/gauge_compiling.py +9 -5
  91. cirq/transformers/gauge_compiling/gauge_compiling_test.py +2 -0
  92. cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py +1 -0
  93. cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py +6 -1
  94. cirq/transformers/gauge_compiling/iswap_gauge.py +2 -0
  95. cirq/transformers/gauge_compiling/iswap_gauge_test.py +2 -0
  96. cirq/transformers/gauge_compiling/spin_inversion_gauge.py +2 -0
  97. cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py +2 -0
  98. cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +3 -3
  99. cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py +2 -0
  100. cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py +2 -0
  101. cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py +2 -0
  102. cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +3 -0
  103. cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils_test.py +3 -0
  104. cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation_test.py +2 -0
  105. cirq/transformers/insertion_sort_test.py +2 -0
  106. cirq/transformers/measurement_transformers_test.py +2 -0
  107. cirq/transformers/merge_single_qubit_gates_test.py +2 -0
  108. cirq/transformers/noise_adding.py +2 -0
  109. cirq/transformers/noise_adding_test.py +2 -0
  110. cirq/transformers/qubit_management_transformers_test.py +2 -0
  111. cirq/transformers/randomized_measurements_test.py +2 -0
  112. cirq/transformers/routing/initial_mapper_test.py +2 -0
  113. cirq/transformers/routing/line_initial_mapper_test.py +2 -0
  114. cirq/transformers/routing/mapping_manager_test.py +2 -0
  115. cirq/transformers/routing/route_circuit_cqc_test.py +2 -0
  116. cirq/transformers/routing/visualize_routed_circuit_test.py +2 -0
  117. cirq/transformers/stratify_test.py +3 -0
  118. cirq/transformers/synchronize_terminal_measurements_test.py +2 -0
  119. cirq/transformers/tag_transformers.py +10 -8
  120. cirq/transformers/tag_transformers_test.py +2 -0
  121. cirq/transformers/target_gatesets/cz_gateset_test.py +2 -0
  122. cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +2 -0
  123. cirq/transformers/transformer_api_test.py +2 -0
  124. cirq/value/abc_alt.py +2 -0
  125. cirq/value/abc_alt_test.py +2 -0
  126. cirq/value/angle.py +5 -2
  127. cirq/value/angle_test.py +2 -0
  128. cirq/value/classical_data_test.py +3 -0
  129. cirq/value/condition_test.py +2 -0
  130. cirq/value/digits.py +2 -0
  131. cirq/value/digits_test.py +2 -0
  132. cirq/value/duration_test.py +2 -0
  133. cirq/value/linear_dict_test.py +2 -0
  134. cirq/value/measurement_key.py +5 -5
  135. cirq/value/measurement_key_test.py +2 -0
  136. cirq/value/periodic_value_test.py +2 -0
  137. cirq/value/probability_test.py +2 -0
  138. cirq/value/product_state_test.py +3 -0
  139. cirq/value/random_state.py +2 -0
  140. cirq/value/random_state_test.py +2 -0
  141. cirq/value/timestamp.py +8 -5
  142. cirq/value/timestamp_test.py +2 -0
  143. cirq/value/type_alias.py +2 -0
  144. cirq/value/value_equality_attr.py +3 -0
  145. cirq/value/value_equality_attr_test.py +3 -0
  146. cirq/vis/density_matrix.py +2 -0
  147. cirq/vis/density_matrix_test.py +3 -0
  148. cirq/vis/heatmap_test.py +3 -0
  149. cirq/vis/histogram.py +3 -0
  150. cirq/vis/histogram_test.py +3 -0
  151. cirq/vis/state_histogram.py +4 -2
  152. cirq/vis/state_histogram_test.py +2 -0
  153. cirq/vis/vis_utils.py +4 -1
  154. cirq/vis/vis_utils_test.py +3 -0
  155. cirq/work/collector_test.py +2 -0
  156. cirq/work/observable_grouping.py +2 -0
  157. cirq/work/observable_grouping_test.py +2 -0
  158. cirq/work/observable_measurement_data_test.py +4 -1
  159. cirq/work/observable_measurement_test.py +3 -0
  160. cirq/work/observable_settings_test.py +2 -0
  161. cirq/work/pauli_sum_collector_test.py +2 -0
  162. {cirq_core-1.6.0.dev20250519212157.dist-info → cirq_core-1.6.0.dev20250520002718.dist-info}/METADATA +1 -1
  163. {cirq_core-1.6.0.dev20250519212157.dist-info → cirq_core-1.6.0.dev20250520002718.dist-info}/RECORD +166 -166
  164. {cirq_core-1.6.0.dev20250519212157.dist-info → cirq_core-1.6.0.dev20250520002718.dist-info}/WHEEL +0 -0
  165. {cirq_core-1.6.0.dev20250519212157.dist-info → cirq_core-1.6.0.dev20250520002718.dist-info}/licenses/LICENSE +0 -0
  166. {cirq_core-1.6.0.dev20250519212157.dist-info → cirq_core-1.6.0.dev20250520002718.dist-info}/top_level.txt +0 -0
cirq/testing/logs_test.py CHANGED
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import logging
16
18
  import warnings
17
19
 
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  from typing import Any, Dict
15
18
 
16
19
  from cirq import protocols
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
 
17
19
 
cirq/testing/op_tree.py CHANGED
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from cirq import ops
16
18
 
17
19
 
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import pytest
15
18
 
16
19
  import cirq
@@ -23,6 +23,8 @@ added items or groups.
23
23
  It will also check that a==b implies hash(a)==hash(b).
24
24
  """
25
25
 
26
+ from __future__ import annotations
27
+
26
28
  from typing import Any
27
29
 
28
30
  from cirq.testing.equals_tester import EqualsTester
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import fractions
16
18
 
17
19
  import pytest
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Support one retry of tests that fail for a specific seed from pytest-randomly."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import functools
18
20
  import warnings
19
21
  from typing import Any, Callable
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from unittest.mock import Mock
16
18
 
17
19
  import pytest
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import random
15
18
  from typing import cast, Dict, Optional, Sequence, Union
16
19
 
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
15
16
 
16
17
  from typing import Any
17
18
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq.testing
16
18
 
17
19
 
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import networkx as nx
15
18
  import pytest
16
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
 
17
19
 
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import dataclasses
15
18
 
16
19
  import numpy as np
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import numpy as np
15
18
  import pytest
16
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
 
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import numpy as np
16
18
  import pytest
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import numpy as np
16
18
  import scipy.stats
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import itertools
16
18
  from typing import List, Sequence, Tuple
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from typing import cast, Optional, Tuple
16
18
 
17
19
  import numpy as np
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cmath
16
18
  import itertools
17
19
  from typing import cast
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import numpy as np
16
18
  import pytest
17
19
  from scipy.stats import unitary_group
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Utility methods related to optimizing quantum circuits."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import math
18
20
  from typing import List, Optional, Tuple
19
21
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import random
16
18
  from typing import Sequence
17
19
 
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import numpy as np
15
18
  import pytest
16
19
 
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Utility methods for decomposing three-qubit unitaries."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  from typing import List, Optional, Sequence, Tuple, Union
18
20
 
19
21
  import numpy as np
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from random import random
16
18
  from typing import Callable
17
19
 
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tests for efficient two qubit state preparation methods."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import copy
18
20
 
19
21
  import numpy as np
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cmath
16
18
  import random
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import itertools
16
18
  import random
17
19
  from typing import Any
@@ -23,12 +23,12 @@ from __future__ import annotations
23
23
 
24
24
  from typing import cast, Iterable, List, Optional, Tuple, TYPE_CHECKING
25
25
 
26
- import numpy as np
27
-
28
26
  from cirq import linalg, ops, protocols
29
27
  from cirq.transformers.analytical_decompositions import single_qubit_decompositions, two_qubit_to_cz
30
28
 
31
29
  if TYPE_CHECKING:
30
+ import numpy as np
31
+
32
32
  import cirq
33
33
 
34
34
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import random
16
18
 
17
19
  import numpy as np
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import itertools
16
18
 
17
19
  import numpy as np
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
 
17
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
 
17
19
  NO_COMPILE_TAG = "no_compile_tag"
@@ -11,6 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
14
17
  import dataclasses
15
18
  from typing import cast, Iterable
16
19
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import dataclasses
16
18
 
17
19
  import numpy as np
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tests for the expand composite transformer pass."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import cirq
18
20
 
19
21
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
  from cirq.transformers.gauge_compiling.cphase_gauge import CPhaseGaugeTransformer
17
19
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
@@ -14,6 +14,8 @@
14
14
 
15
15
  """A Gauge Transformer for the CZ gate."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  from cirq import ops
18
20
  from cirq.ops.common_gates import CZ
19
21
  from cirq.transformers.gauge_compiling.gauge_compiling import (
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
15
16
 
16
17
  import cirq
17
18
  from cirq.transformers.gauge_compiling import CZGaugeTransformer
@@ -14,12 +14,14 @@
14
14
 
15
15
  """Creates the abstraction for gauge compiling as a cirq transformer."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import abc
18
20
  import functools
19
21
  import itertools
20
22
  from dataclasses import dataclass
21
23
  from numbers import Real
22
- from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
24
+ from typing import Callable, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
23
25
 
24
26
  import numpy as np
25
27
  import sympy
@@ -28,11 +30,13 @@ from attrs import field, frozen
28
30
  from cirq import circuits, ops
29
31
  from cirq.protocols import unitary_protocol
30
32
  from cirq.protocols.has_unitary_protocol import has_unitary
31
- from cirq.study import sweepable
32
33
  from cirq.study.sweeps import Points, Zip
33
34
  from cirq.transformers import transformer_api
34
35
  from cirq.transformers.analytical_decompositions import single_qubit_decompositions
35
36
 
37
+ if TYPE_CHECKING:
38
+ import cirq
39
+
36
40
 
37
41
  class Gauge(abc.ABC):
38
42
  """A gauge replaces a two qubit gate with an equivalent subcircuit.
@@ -49,7 +53,7 @@ class Gauge(abc.ABC):
49
53
  return 1.0
50
54
 
51
55
  @abc.abstractmethod
52
- def sample(self, gate: ops.Gate, prng: np.random.Generator) -> "ConstantGauge":
56
+ def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
53
57
  """Returns a ConstantGauge sampled from a family of gauges.
54
58
 
55
59
  Args:
@@ -80,7 +84,7 @@ class ConstantGauge(Gauge):
80
84
  )
81
85
  swap_qubits: bool = False
82
86
 
83
- def sample(self, gate: ops.Gate, prng: np.random.Generator) -> "ConstantGauge":
87
+ def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
84
88
  return self
85
89
 
86
90
  @property
@@ -256,7 +260,7 @@ class GaugeTransformer:
256
260
  N: int,
257
261
  context: Optional[transformer_api.TransformerContext] = None,
258
262
  prng: Optional[np.random.Generator] = None,
259
- ) -> Tuple[circuits.AbstractCircuit, sweepable.Sweepable]:
263
+ ) -> Tuple[circuits.AbstractCircuit, cirq.Sweepable]:
260
264
  """Generates a parameterized circuit with *N* sets of sweepable parameters.
261
265
 
262
266
  Args:
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import unittest.mock
16
18
 
17
19
  import numpy as np
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
15
16
 
16
17
  from unittest.mock import patch
17
18
 
@@ -13,12 +13,17 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- import numpy as np
16
+ from __future__ import annotations
17
+
18
+ from typing import TYPE_CHECKING
17
19
 
18
20
  import cirq
19
21
  from cirq.transformers import ConstantGauge, GaugeSelector, GaugeTransformer
20
22
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
21
23
 
24
+ if TYPE_CHECKING:
25
+ import numpy as np
26
+
22
27
 
23
28
  class ExampleGate(cirq.testing.TwoQubitGate):
24
29
  unitary = cirq.unitary(cirq.CZ**0.123)
@@ -14,6 +14,8 @@
14
14
 
15
15
  """A Gauge transformer for ISWAP gate."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import numpy as np
18
20
 
19
21
  from cirq import ops
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ from __future__ import annotations
17
+
16
18
  import cirq
17
19
  from cirq.transformers.gauge_compiling import ISWAPGaugeTransformer
18
20
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
@@ -14,6 +14,8 @@
14
14
 
15
15
  """The spin inversion gauge transformer."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  from cirq import ops
18
20
  from cirq.transformers.gauge_compiling.gauge_compiling import (
19
21
  GaugeSelector,
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
  from cirq.transformers.gauge_compiling import SpinInversionGaugeTransformer
17
19
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
@@ -20,9 +20,6 @@ from __future__ import annotations
20
20
  from numbers import Real
21
21
  from typing import Dict, Sequence, Tuple, TYPE_CHECKING
22
22
 
23
- import numpy as np
24
- import sympy
25
-
26
23
  from cirq.ops import CZ, CZPowGate, Gate, Gateset, S, X
27
24
  from cirq.transformers.gauge_compiling.gauge_compiling import (
28
25
  ConstantGauge,
@@ -33,6 +30,9 @@ from cirq.transformers.gauge_compiling.gauge_compiling import (
33
30
  )
34
31
 
35
32
  if TYPE_CHECKING:
33
+ import numpy as np
34
+ import sympy
35
+
36
36
  import cirq
37
37
 
38
38
  _SQRT_CZ = CZ**0.5
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
  from cirq.transformers.gauge_compiling import SqrtCZGaugeTransformer
17
19
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
@@ -14,6 +14,8 @@
14
14
 
15
15
  """A Gauge transformer for SQRT_ISWAP gate."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import numpy as np
18
20
 
19
21
  from cirq import ops
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import cirq
16
18
  from cirq.transformers.gauge_compiling import SqrtISWAPGaugeTransformer
17
19
  from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
@@ -1,4 +1,7 @@
1
1
  # pylint: disable=wrong-or-nonexistent-copyright-notice
2
+
3
+ from __future__ import annotations
4
+
2
5
  import itertools
3
6
  from typing import Optional, Sequence, Union
4
7
 
@@ -1,4 +1,7 @@
1
1
  # pylint: disable=wrong-or-nonexistent-copyright-notice
2
+
3
+ from __future__ import annotations
4
+
2
5
  import numpy as np
3
6
  import pytest
4
7
 
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import numpy as np
16
18
  import pytest
17
19