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
@@ -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
  import cirq.transformers
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
  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 List
16
18
 
17
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 collections.abc import Mapping
16
18
  from typing import cast
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
 
17
19
  import cirq.transformers.noise_adding as na
@@ -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 pytest
16
18
 
17
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
  import pytest
16
18
 
17
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
  import networkx as nx
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 networkx as nx
16
18
  import pytest
17
19
  from networkx.utils.misc import graphs_equal
@@ -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
@@ -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
@@ -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
  import cirq
16
18
 
17
19
  NO_COMPILE_TAG = "no_compile_tag"
@@ -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 Callable, Hashable, Optional, TYPE_CHECKING
17
19
 
@@ -23,11 +25,11 @@ if TYPE_CHECKING:
23
25
 
24
26
  @transformer_api.transformer
25
27
  def index_tags(
26
- circuit: 'cirq.AbstractCircuit',
28
+ circuit: cirq.AbstractCircuit,
27
29
  *,
28
- context: Optional['cirq.TransformerContext'] = None,
30
+ context: Optional[cirq.TransformerContext] = None,
29
31
  target_tags: Optional[set[Hashable]] = None,
30
- ) -> 'cirq.Circuit':
32
+ ) -> cirq.Circuit:
31
33
  """Indexes tags in target_tags as tag_0, tag_1, ... per tag.
32
34
 
33
35
  Args:
@@ -44,7 +46,7 @@ def index_tags(
44
46
  return circuit.unfreeze(copy=False)
45
47
  tag_iter_by_tags = {tag: itertools.count(start=0, step=1) for tag in target_tags}
46
48
 
47
- def _map_func(op: 'cirq.Operation', _) -> 'cirq.OP_TREE':
49
+ def _map_func(op: cirq.Operation, _) -> cirq.OP_TREE:
48
50
  tag_set = set(op.tags)
49
51
  nonlocal tag_iter_by_tags
50
52
  for tag in target_tags.intersection(op.tags):
@@ -60,12 +62,12 @@ def index_tags(
60
62
 
61
63
  @transformer_api.transformer
62
64
  def remove_tags(
63
- circuit: 'cirq.AbstractCircuit',
65
+ circuit: cirq.AbstractCircuit,
64
66
  *,
65
- context: Optional['cirq.TransformerContext'] = None,
67
+ context: Optional[cirq.TransformerContext] = None,
66
68
  target_tags: Optional[set[Hashable]] = None,
67
69
  remove_if: Callable[[Hashable], bool] = lambda _: False,
68
- ) -> 'cirq.Circuit':
70
+ ) -> cirq.Circuit:
69
71
  """Removes tags from the operations based on the input args.
70
72
 
71
73
  Args:
@@ -82,7 +84,7 @@ def remove_tags(
82
84
  raise ValueError("remove_tags doesn't support tags_to_ignore, use function args instead.")
83
85
  target_tags = target_tags or set()
84
86
 
85
- def _map_func(op: 'cirq.Operation', _) -> 'cirq.OP_TREE':
87
+ def _map_func(op: cirq.Operation, _) -> cirq.OP_TREE:
86
88
  remaing_tags = set()
87
89
  for tag in op.tags:
88
90
  if not remove_if(tag) and tag not in target_tags:
@@ -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
@@ -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 Optional, Sequence, Type
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
  from typing import Optional
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
  from typing import Optional
16
18
  from unittest import mock
17
19
 
cirq/value/abc_alt.py CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
  """A more flexible abstract base class metaclass ABCMetaImplementAnyOneOf."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import abc
18
20
  import functools
19
21
  from typing import Callable, cast, Set, TypeVar
@@ -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 abc
16
18
  from typing import NoReturn, Optional
17
19
 
cirq/value/angle.py CHANGED
@@ -12,12 +12,15 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from typing import Optional, overload
15
+ from __future__ import annotations
16
+
17
+ from typing import Optional, overload, TYPE_CHECKING
16
18
 
17
19
  import numpy as np
18
20
  import sympy
19
21
 
20
- from cirq.value import type_alias
22
+ if TYPE_CHECKING:
23
+ from cirq.value import type_alias
21
24
 
22
25
 
23
26
  def chosen_angle_to_half_turns(
cirq/value/angle_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 numpy as np
16
18
  import pytest
17
19
  import sympy
@@ -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 re
15
18
 
16
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
  import re
16
18
 
17
19
  import pytest
cirq/value/digits.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 typing import Any, Iterable, List, Optional, overload, Union
16
18
 
17
19
 
cirq/value/digits_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
  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 datetime import timedelta
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 numpy as np
16
18
  import pytest
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
  import dataclasses
16
18
  from typing import Any, Dict, FrozenSet, Mapping, Optional, Tuple
17
19
 
@@ -49,7 +51,7 @@ class MeasurementKey:
49
51
  '`MeasurementKey.parse_serialized` for correct behavior.'
50
52
  )
51
53
 
52
- def replace(self, **changes) -> 'MeasurementKey':
54
+ def replace(self, **changes) -> MeasurementKey:
53
55
  """Returns a copy of this MeasurementKey with the specified changes."""
54
56
  return dataclasses.replace(self, **changes)
55
57
 
@@ -102,7 +104,7 @@ class MeasurementKey:
102
104
  return cls(name=name, path=tuple(path))
103
105
 
104
106
  @classmethod
105
- def parse_serialized(cls, key_str: str) -> 'MeasurementKey':
107
+ def parse_serialized(cls, key_str: str) -> MeasurementKey:
106
108
  """Parses the serialized string representation of `Measurementkey` into a `MeasurementKey`.
107
109
 
108
110
  This is the only way to construct a `MeasurementKey` from a nested string representation
@@ -124,9 +126,7 @@ class MeasurementKey:
124
126
  """
125
127
  return self.replace(path=path_component + self.path)
126
128
 
127
- def _with_rescoped_keys_(
128
- self, path: Tuple[str, ...], bindable_keys: FrozenSet['MeasurementKey']
129
- ):
129
+ def _with_rescoped_keys_(self, path: Tuple[str, ...], bindable_keys: FrozenSet[MeasurementKey]):
130
130
  return self.replace(path=path + self.path)
131
131
 
132
132
  def _with_measurement_key_mapping_(self, key_map: Mapping[str, str]):
@@ -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
@@ -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
  import sympy
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 pytest
16
18
 
17
19
  import cirq
@@ -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
  from typing import Any, cast
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 numpy as np
16
18
 
17
19
  import cirq
cirq/value/timestamp.py CHANGED
@@ -11,8 +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
  """A typed location in time that supports picosecond accuracy."""
15
16
 
17
+ from __future__ import annotations
18
+
16
19
  from datetime import timedelta
17
20
  from typing import overload
18
21
 
@@ -45,27 +48,27 @@ class Timestamp:
45
48
  """The timestamp's location in picoseconds from arbitrary time zero."""
46
49
  return self._picos
47
50
 
48
- def __add__(self, other) -> 'Timestamp':
51
+ def __add__(self, other) -> Timestamp:
49
52
  if isinstance(other, timedelta):
50
53
  return Timestamp(picos=self._picos + other.total_seconds() * 10**12)
51
54
  if not isinstance(other, Duration):
52
55
  return NotImplemented
53
56
  return Timestamp(picos=self._picos + other.total_picos())
54
57
 
55
- def __radd__(self, other) -> 'Timestamp':
58
+ def __radd__(self, other) -> Timestamp:
56
59
  return self.__add__(other)
57
60
 
58
61
  # pylint: disable=function-redefined
59
62
  @overload
60
- def __sub__(self, other: 'Timestamp') -> Duration:
63
+ def __sub__(self, other: Timestamp) -> Duration:
61
64
  pass
62
65
 
63
66
  @overload
64
- def __sub__(self, other: Duration) -> 'Timestamp':
67
+ def __sub__(self, other: Duration) -> Timestamp:
65
68
  pass
66
69
 
67
70
  @overload
68
- def __sub__(self, other: timedelta) -> 'Timestamp':
71
+ def __sub__(self, other: timedelta) -> Timestamp:
69
72
  pass
70
73
 
71
74
  def __sub__(self, other):
@@ -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 datetime import timedelta
16
18
 
17
19
  import pytest
cirq/value/type_alias.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 typing import Union
16
18
 
17
19
  import numpy as np
@@ -11,8 +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
  """Defines `@cirq.value_equality`, for easy __eq__/__hash__ methods."""
15
16
 
17
+ from __future__ import annotations
18
+
16
19
  from typing import Any, Callable, Dict, Optional, overload, Union
17
20
 
18
21
  from typing_extensions import Protocol
@@ -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
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tool to visualize the magnitudes and phases in the density matrix"""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  from typing import Optional
18
20
 
19
21
  import matplotlib.pyplot as plt
@@ -11,8 +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
  """Tests for Density Matrix Plotter."""
15
16
 
17
+ from __future__ import annotations
18
+
16
19
  import numpy as np
17
20
  import pytest
18
21
  from matplotlib import axis, lines, patches, pyplot as plt, spines, text
cirq/vis/heatmap_test.py CHANGED
@@ -11,8 +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
  """Tests for Heatmap."""
15
16
 
17
+ from __future__ import annotations
18
+
16
19
  import pathlib
17
20
  import shutil
18
21
  import string
cirq/vis/histogram.py CHANGED
@@ -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, Mapping, Optional, Sequence, SupportsFloat, Union
15
18
 
16
19
  import numpy as np
@@ -11,8 +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
  """Tests for Histogram."""
15
16
 
17
+ from __future__ import annotations
18
+
16
19
  import matplotlib.pyplot as plt
17
20
  import numpy as np
18
21
  import pytest
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tool to visualize the results of a study."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import collections
18
20
  from typing import Optional, Sequence, SupportsFloat, Union
19
21
 
@@ -23,7 +25,7 @@ import numpy as np
23
25
  import cirq.study.result as result
24
26
 
25
27
 
26
- def get_state_histogram(result: 'result.Result') -> np.ndarray:
28
+ def get_state_histogram(result: result.Result) -> np.ndarray:
27
29
  """Computes a state histogram from a single result with repetitions.
28
30
 
29
31
  Args:
@@ -52,7 +54,7 @@ def get_state_histogram(result: 'result.Result') -> np.ndarray:
52
54
 
53
55
 
54
56
  def plot_state_histogram(
55
- data: Union['result.Result', collections.Counter, Sequence[SupportsFloat]],
57
+ data: Union[result.Result, collections.Counter, Sequence[SupportsFloat]],
56
58
  ax: Optional[plt.Axes] = None,
57
59
  *,
58
60
  tick_label: Optional[Sequence[str]] = None,
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tests for state_histogram."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import matplotlib as mpl
18
20
  import numpy as np
19
21
  import pytest
cirq/vis/vis_utils.py CHANGED
@@ -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 TYPE_CHECKING
15
18
 
16
19
  import numpy as np
@@ -19,7 +22,7 @@ if TYPE_CHECKING:
19
22
  from numpy.typing import ArrayLike
20
23
 
21
24
 
22
- def relative_luminance(color: 'ArrayLike') -> float:
25
+ def relative_luminance(color: ArrayLike) -> float:
23
26
  """Returns the relative luminance according to W3C specification.
24
27
 
25
28
  Spec: https://www.w3.org/TR/WCAG21/#dfn-relative-luminance.