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/_version.py CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 11, 0): # pragma: no cover
28
28
  'of cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.6.0.dev20250519212157"
31
+ __version__ = "1.6.0.dev20250520002718"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.6.0.dev20250519212157"
6
+ assert cirq.__version__ == "1.6.0.dev20250520002718"
@@ -30,13 +30,13 @@ from typing import (
30
30
  Union,
31
31
  )
32
32
 
33
- import numpy as np
34
-
35
33
  from cirq import _compat, protocols
36
34
  from cirq.circuits import AbstractCircuit, Alignment, Circuit
37
35
  from cirq.circuits.insert_strategy import InsertStrategy
38
36
 
39
37
  if TYPE_CHECKING:
38
+ import numpy as np
39
+
40
40
  import cirq
41
41
 
42
42
 
@@ -18,11 +18,11 @@ import operator
18
18
  import random
19
19
  from typing import Any, Callable, cast, Iterable, TYPE_CHECKING
20
20
 
21
- import networkx
22
-
23
21
  from cirq import ops
24
22
 
25
23
  if TYPE_CHECKING:
24
+ import networkx
25
+
26
26
  import cirq
27
27
 
28
28
 
@@ -16,12 +16,12 @@ from __future__ import annotations
16
16
 
17
17
  from typing import Any, Dict, Generic, Sequence, Type, TYPE_CHECKING
18
18
 
19
- import numpy as np
20
-
21
19
  from cirq import sim
22
20
  from cirq.sim.simulation_state import TSimulationState
23
21
 
24
22
  if TYPE_CHECKING:
23
+ import numpy as np
24
+
25
25
  import cirq
26
26
 
27
27
 
@@ -18,11 +18,11 @@ from enum import Enum
18
18
  from types import NotImplementedType
19
19
  from typing import cast, List, Type, TYPE_CHECKING, Union
20
20
 
21
- import numpy as np
22
-
23
21
  from cirq import linalg, ops, protocols, transformers
24
22
 
25
23
  if TYPE_CHECKING:
24
+ import numpy as np
25
+
26
26
  import cirq
27
27
 
28
28
 
@@ -6,15 +6,17 @@ https://arxiv.org/abs/1811.12926.
6
6
  from __future__ import annotations
7
7
 
8
8
  from dataclasses import dataclass
9
- from typing import Callable, Dict, List, Optional, Set, Tuple
9
+ from typing import Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
10
10
 
11
- import networkx as nx
12
11
  import numpy as np
13
- import pandas as pd
14
12
 
15
13
  import cirq
16
14
  import cirq.contrib.routing as ccr
17
15
 
16
+ if TYPE_CHECKING:
17
+ import networkx as nx
18
+ import pandas as pd
19
+
18
20
 
19
21
  def generate_model_circuit(
20
22
  num_qubits: int, depth: int, *, random_state: cirq.RANDOM_STATE_OR_SEED_LIKE = None
@@ -14,12 +14,13 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- from typing import Iterator
18
-
19
- import networkx as nx
17
+ from typing import Iterator, TYPE_CHECKING
20
18
 
21
19
  import cirq
22
20
 
21
+ if TYPE_CHECKING:
22
+ import networkx as nx
23
+
23
24
 
24
25
  def get_grid_moments(
25
26
  problem_graph: nx.Graph, two_qubit_gate=cirq.ZZPowGate
@@ -3,14 +3,16 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import warnings
6
- from typing import cast, Dict, List, Optional, Sequence, Tuple, Union
6
+ from typing import cast, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
7
7
 
8
- import numpy as np
9
8
  import quimb
10
9
  import quimb.tensor as qtn
11
10
 
12
11
  import cirq
13
12
 
13
+ if TYPE_CHECKING:
14
+ import numpy as np
15
+
14
16
 
15
17
  def _get_quimb_version():
16
18
  """Returns the quimb version and parsed (major,minor) numbers if possible.
@@ -16,12 +16,12 @@ from __future__ import annotations
16
16
 
17
17
  from typing import Callable, Optional, TYPE_CHECKING
18
18
 
19
- import networkx as nx
20
-
21
19
  from cirq import circuits, protocols
22
20
  from cirq.contrib.routing.greedy import route_circuit_greedily
23
21
 
24
22
  if TYPE_CHECKING:
23
+ import networkx as nx
24
+
25
25
  from cirq.contrib.routing.swap_network import SwapNetwork
26
26
 
27
27
  ROUTERS = {'greedy': route_circuit_greedily}
@@ -34,7 +34,6 @@ import numpy as np
34
34
  from matplotlib import pyplot as plt
35
35
 
36
36
  # this is for older systems with matplotlib <3.2 otherwise 3d projections fail
37
- from mpl_toolkits import mplot3d
38
37
  from scipy.optimize import curve_fit
39
38
 
40
39
  import cirq.vis.heatmap as cirq_heatmap
@@ -43,6 +42,8 @@ from cirq import circuits, ops, protocols
43
42
  from cirq.devices import grid_qubit
44
43
 
45
44
  if TYPE_CHECKING:
45
+ from mpl_toolkits import mplot3d
46
+
46
47
  import cirq
47
48
 
48
49
 
@@ -33,13 +33,14 @@ from typing import (
33
33
  Union,
34
34
  )
35
35
 
36
- import networkx as nx
37
36
  import numpy as np
38
37
 
39
38
  from cirq import circuits, devices, ops, protocols, value
40
39
  from cirq._doc import document
41
40
 
42
41
  if TYPE_CHECKING:
42
+ import networkx as nx
43
+
43
44
  import cirq
44
45
 
45
46
  QidPairT = Tuple['cirq.Qid', 'cirq.Qid']
@@ -24,7 +24,6 @@ from typing import Any, cast, Dict, Mapping, Optional, Sequence, Tuple, TYPE_CHE
24
24
 
25
25
  import networkx as nx
26
26
  import numpy as np
27
- import pandas as pd
28
27
  from matplotlib import pyplot as plt
29
28
 
30
29
  from cirq import ops, value, vis
@@ -45,6 +44,8 @@ from cirq.qis import noise_utils
45
44
  if TYPE_CHECKING:
46
45
  import multiprocessing
47
46
 
47
+ import pandas as pd
48
+
48
49
  import cirq
49
50
 
50
51
 
cirq/linalg/predicates.py CHANGED
@@ -302,7 +302,7 @@ def slice_for_qubits_equal_to(
302
302
  out_size = (
303
303
  cast(int, num_qubits) if out_size_specified else max(target_qubit_axes, default=-1) + 1
304
304
  )
305
- result = cast(List[Union[slice, int, 'ellipsis']], [slice(None)] * out_size)
305
+ result = cast(List[Union[slice, int, EllipsisType]], [slice(None)] * out_size)
306
306
  if not out_size_specified:
307
307
  result.append(Ellipsis)
308
308
  if qid_shape is None:
@@ -36,13 +36,14 @@ from typing import (
36
36
  Union,
37
37
  )
38
38
 
39
- import numpy as np
40
39
  from typing_extensions import Self
41
40
 
42
41
  from cirq import ops, protocols, value
43
42
  from cirq.ops import control_values as cv, gate_features, raw_types
44
43
 
45
44
  if TYPE_CHECKING:
45
+ import numpy as np
46
+
46
47
  import cirq
47
48
 
48
49
 
@@ -32,9 +32,7 @@ from typing import (
32
32
  )
33
33
 
34
34
  import numpy as np
35
- from scipy.sparse import csr_matrix
36
- from sympy.core.expr import Expr
37
- from sympy.core.symbol import Symbol
35
+ import sympy
38
36
  from sympy.logic.boolalg import And, Not, Or, Xor
39
37
 
40
38
  from cirq import linalg, protocols, qis, value
@@ -46,6 +44,8 @@ from cirq.ops.projector import ProjectorString
46
44
  from cirq.value.linear_dict import _format_terms
47
45
 
48
46
  if TYPE_CHECKING:
47
+ from scipy.sparse import csr_matrix
48
+
49
49
  import cirq
50
50
 
51
51
  UnitPauliStringT = FrozenSet[Tuple[raw_types.Qid, pauli_gates.Pauli]]
@@ -490,7 +490,7 @@ class PauliSum:
490
490
 
491
491
  @classmethod
492
492
  def from_boolean_expression(
493
- cls, boolean_expr: Expr, qubit_map: Dict[str, cirq.Qid]
493
+ cls, boolean_expr: sympy.Expr, qubit_map: Dict[str, cirq.Qid]
494
494
  ) -> PauliSum:
495
495
  """Builds the Hamiltonian representation of a Boolean expression.
496
496
 
@@ -507,7 +507,7 @@ class PauliSum:
507
507
  Raises:
508
508
  ValueError: If `boolean_expr` is of an unsupported type.
509
509
  """
510
- if isinstance(boolean_expr, Symbol):
510
+ if isinstance(boolean_expr, sympy.Symbol):
511
511
  # In table 1, the entry for 'x' is '1/2.I - 1/2.Z'
512
512
  return cls.from_pauli_strings(
513
513
  [
@@ -27,8 +27,6 @@ from typing import (
27
27
  Union,
28
28
  )
29
29
 
30
- import sympy
31
-
32
30
  from cirq import protocols, value
33
31
  from cirq._compat import deprecated, proper_repr
34
32
  from cirq.ops import (
@@ -42,6 +40,8 @@ from cirq.ops import (
42
40
  )
43
41
 
44
42
  if TYPE_CHECKING:
43
+ import sympy
44
+
45
45
  import cirq
46
46
 
47
47
 
cirq/ops/raw_types.py CHANGED
@@ -39,7 +39,6 @@ from typing import (
39
39
  )
40
40
 
41
41
  import numpy as np
42
- import sympy
43
42
  from typing_extensions import Self
44
43
 
45
44
  from cirq import protocols, value
@@ -52,6 +51,8 @@ line_qubit = LazyLoader("line_qubit", globals(), "cirq.devices.line_qubit")
52
51
 
53
52
 
54
53
  if TYPE_CHECKING:
54
+ import sympy
55
+
55
56
  import cirq
56
57
  from cirq.ops import control_values as cv
57
58
 
@@ -19,12 +19,12 @@ from __future__ import annotations
19
19
 
20
20
  from typing import Optional, Sequence, TYPE_CHECKING
21
21
 
22
- import numpy as np
23
-
24
22
  from cirq.qis import clifford_tableau
25
23
  from cirq.sim.clifford.stabilizer_simulation_state import StabilizerSimulationState
26
24
 
27
25
  if TYPE_CHECKING:
26
+ import numpy as np
27
+
28
28
  import cirq
29
29
 
30
30
 
@@ -16,13 +16,13 @@ from __future__ import annotations
16
16
 
17
17
  from typing import Optional, Sequence, TYPE_CHECKING, Union
18
18
 
19
- import numpy as np
20
-
21
19
  from cirq._compat import proper_repr
22
20
  from cirq.sim.clifford import stabilizer_state_ch_form
23
21
  from cirq.sim.clifford.stabilizer_simulation_state import StabilizerSimulationState
24
22
 
25
23
  if TYPE_CHECKING:
24
+ import numpy as np
25
+
26
26
  import cirq
27
27
 
28
28
 
@@ -18,7 +18,6 @@ import abc
18
18
  from types import NotImplementedType
19
19
  from typing import Any, cast, Generic, Optional, Sequence, TYPE_CHECKING, TypeVar, Union
20
20
 
21
- import numpy as np
22
21
  import sympy
23
22
 
24
23
  from cirq import linalg, ops, protocols
@@ -28,6 +27,8 @@ from cirq.protocols import has_unitary, num_qubits, unitary
28
27
  from cirq.sim.simulation_state import SimulationState
29
28
 
30
29
  if TYPE_CHECKING:
30
+ import numpy as np
31
+
31
32
  import cirq
32
33
 
33
34
 
@@ -33,12 +33,13 @@ from typing import (
33
33
  Union,
34
34
  )
35
35
 
36
- import numpy as np
37
36
  from typing_extensions import Self
38
37
 
39
38
  from cirq import protocols, value
40
39
 
41
40
  if TYPE_CHECKING:
41
+ import numpy as np
42
+
42
43
  import cirq
43
44
 
44
45
 
@@ -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 Any, Dict, Optional, Sequence, Type
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 types import NotImplementedType
16
18
  from typing import AbstractSet, List, Sequence, Tuple, Union
17
19
 
@@ -83,7 +85,7 @@ class GoodGate(cirq.testing.SingleQubitGate):
83
85
  exponent=self.exponent, phase_exponent=self.phase_exponent + phase_turns * 2
84
86
  )
85
87
 
86
- def __pow__(self, exponent: Union[float, sympy.Expr]) -> 'GoodGate':
88
+ def __pow__(self, exponent: Union[float, sympy.Expr]) -> GoodGate:
87
89
  new_exponent = cirq.mul(self.exponent, exponent, NotImplemented)
88
90
  if new_exponent is NotImplemented:
89
91
  return NotImplemented # pragma: no cover
@@ -101,7 +103,7 @@ class GoodGate(cirq.testing.SingleQubitGate):
101
103
  def _parameter_names_(self) -> AbstractSet[str]:
102
104
  return cirq.parameter_names(self.exponent) | cirq.parameter_names(self.phase_exponent)
103
105
 
104
- def _resolve_parameters_(self, resolver, recursive) -> 'GoodGate':
106
+ def _resolve_parameters_(self, resolver, recursive) -> GoodGate:
105
107
  return GoodGate(
106
108
  phase_exponent=resolver.value_of(self.phase_exponent, recursive),
107
109
  exponent=resolver.value_of(self.exponent, recursive),
@@ -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 warnings
16
18
  from typing import Any, List, Optional, Sequence
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 warnings
16
18
  from typing import 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 Any
16
18
 
17
19
  import sympy
@@ -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 Any
16
18
 
17
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 numpy as np
16
18
  import pytest
17
19
 
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ from __future__ import annotations
17
+
16
18
  from typing import Any
17
19
 
18
20
  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 numpy as np
16
18
  import pytest
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 contextlib
15
18
  import logging
16
19
  import os
@@ -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 warnings
15
18
 
16
19
  import pytest
cirq/testing/devices.py CHANGED
@@ -11,7 +11,11 @@
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
+
14
15
  """Provides test devices that can validate circuits."""
16
+
17
+ from __future__ import annotations
18
+
15
19
  from typing import AbstractSet, cast, Tuple
16
20
 
17
21
  from cirq import devices, ops
@@ -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
@@ -20,6 +20,8 @@ group are all equal to each other, but that items between each group are never
20
20
  equal to each other. It will also check that a==b implies hash(a)==hash(b).
21
21
  """
22
22
 
23
+ from __future__ import annotations
24
+
23
25
  import collections
24
26
  import itertools
25
27
  from typing import Any, Callable, List, Tuple, Union
@@ -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
@@ -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 Dict, Optional, Sequence
16
18
 
17
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 pytest
15
18
 
16
19
  import cirq
@@ -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 Any, Dict, Optional
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
 
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Simple gates used for testing purposes."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  from cirq.ops import raw_types
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 pytest
16
18
 
17
19
  import cirq
cirq/testing/json.py CHANGED
@@ -12,19 +12,23 @@
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
  import inspect
17
19
  import io
18
20
  import pathlib
19
21
  from dataclasses import dataclass
20
22
  from types import ModuleType
21
- from typing import Dict, Iterator, List, Set, Tuple, Type
23
+ from typing import Dict, Iterator, List, Set, Tuple, Type, TYPE_CHECKING
22
24
 
23
25
  import numpy as np
24
26
  import pandas as pd
25
27
 
26
28
  import cirq
27
- from cirq.protocols.json_serialization import ObjectFactory
29
+
30
+ if TYPE_CHECKING:
31
+ from cirq.protocols.json_serialization import ObjectFactory
28
32
 
29
33
  # This is the testing framework for json serialization
30
34
  # The actual tests live in cirq.protocols.json_serialization_test.py.
cirq/testing/json_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 pytest
16
18
 
17
19
  from cirq.testing.json import spec_for
@@ -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
 
cirq/testing/logs.py CHANGED
@@ -11,7 +11,11 @@
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
+
14
15
  """Helper for testing python logging statements."""
16
+
17
+ from __future__ import annotations
18
+
15
19
  import contextlib
16
20
  import logging
17
21
  from typing import Iterator, List, Optional