cirq-core 1.5.0.dev20250403170622__py3-none-any.whl → 1.5.0.dev20250404021339__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 (54) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit.py +144 -147
  4. cirq/circuits/circuit_operation.py +37 -34
  5. cirq/circuits/circuit_operation_test.py +1 -1
  6. cirq/circuits/circuit_test.py +4 -6
  7. cirq/circuits/frozen_circuit.py +30 -26
  8. cirq/circuits/moment.py +37 -37
  9. cirq/circuits/optimization_pass.py +11 -11
  10. cirq/circuits/optimization_pass_test.py +6 -8
  11. cirq/circuits/qasm_output.py +13 -11
  12. cirq/circuits/text_diagram_drawer.py +9 -7
  13. cirq/contrib/acquaintance/bipartite.py +7 -5
  14. cirq/contrib/acquaintance/devices.py +3 -1
  15. cirq/contrib/acquaintance/executor.py +14 -16
  16. cirq/contrib/acquaintance/gates.py +19 -21
  17. cirq/contrib/acquaintance/inspection_utils.py +8 -6
  18. cirq/contrib/acquaintance/mutation_utils.py +8 -6
  19. cirq/contrib/acquaintance/optimizers.py +5 -3
  20. cirq/contrib/acquaintance/permutation.py +19 -19
  21. cirq/contrib/acquaintance/shift.py +5 -3
  22. cirq/contrib/acquaintance/shift_swap_network.py +5 -3
  23. cirq/contrib/acquaintance/strategies/complete.py +4 -2
  24. cirq/contrib/acquaintance/strategies/cubic.py +4 -2
  25. cirq/contrib/acquaintance/strategies/quartic_paired.py +8 -6
  26. cirq/contrib/acquaintance/topological_sort.py +4 -2
  27. cirq/contrib/bayesian_network/bayesian_network_gate.py +4 -2
  28. cirq/contrib/circuitdag/circuit_dag.py +18 -16
  29. cirq/contrib/custom_simulators/custom_state_simulator.py +10 -8
  30. cirq/contrib/custom_simulators/custom_state_simulator_test.py +9 -7
  31. cirq/contrib/graph_device/graph_device.py +4 -2
  32. cirq/contrib/noise_models/noise_models.py +7 -5
  33. cirq/contrib/paulistring/clifford_target_gateset.py +11 -9
  34. cirq/contrib/qcircuit/qcircuit_diagram.py +5 -2
  35. cirq/contrib/quantum_volume/quantum_volume.py +4 -4
  36. cirq/contrib/quimb/mps_simulator.py +25 -26
  37. cirq/contrib/routing/greedy.py +5 -3
  38. cirq/contrib/routing/initialization.py +3 -1
  39. cirq/contrib/routing/swap_network.py +5 -5
  40. cirq/contrib/routing/utils.py +4 -2
  41. cirq/contrib/svg/svg.py +9 -6
  42. cirq/devices/device.py +11 -9
  43. cirq/devices/grid_device_metadata.py +14 -11
  44. cirq/devices/grid_qubit.py +17 -21
  45. cirq/devices/grid_qubit_test.py +1 -1
  46. cirq/devices/insertion_noise_model.py +5 -5
  47. cirq/devices/line_qubit.py +15 -17
  48. cirq/devices/named_topologies.py +6 -4
  49. cirq/devices/noise_model.py +27 -31
  50. {cirq_core-1.5.0.dev20250403170622.dist-info → cirq_core-1.5.0.dev20250404021339.dist-info}/METADATA +1 -1
  51. {cirq_core-1.5.0.dev20250403170622.dist-info → cirq_core-1.5.0.dev20250404021339.dist-info}/RECORD +54 -54
  52. {cirq_core-1.5.0.dev20250403170622.dist-info → cirq_core-1.5.0.dev20250404021339.dist-info}/LICENSE +0 -0
  53. {cirq_core-1.5.0.dev20250403170622.dist-info → cirq_core-1.5.0.dev20250404021339.dist-info}/WHEEL +0 -0
  54. {cirq_core-1.5.0.dev20250403170622.dist-info → cirq_core-1.5.0.dev20250404021339.dist-info}/top_level.txt +0 -0
@@ -18,6 +18,9 @@ A CircuitOperation is an Operation object that wraps a FrozenCircuit. When
18
18
  applied as part of a larger circuit, a CircuitOperation will execute all
19
19
  component operations in order, including any nested CircuitOperations.
20
20
  """
21
+
22
+ from __future__ import annotations
23
+
21
24
  import math
22
25
  from functools import cached_property
23
26
  from typing import (
@@ -81,16 +84,16 @@ class CircuitOperation(ops.Operation):
81
84
 
82
85
  def __init__(
83
86
  self,
84
- circuit: 'cirq.FrozenCircuit',
87
+ circuit: cirq.FrozenCircuit,
85
88
  repetitions: INT_TYPE = 1,
86
- qubit_map: Optional[Dict['cirq.Qid', 'cirq.Qid']] = None,
89
+ qubit_map: Optional[Dict[cirq.Qid, cirq.Qid]] = None,
87
90
  measurement_key_map: Optional[Dict[str, str]] = None,
88
91
  param_resolver: Optional[study.ParamResolverOrSimilarType] = None,
89
92
  repetition_ids: Optional[Sequence[str]] = None,
90
93
  parent_path: Tuple[str, ...] = (),
91
- extern_keys: FrozenSet['cirq.MeasurementKey'] = frozenset(),
94
+ extern_keys: FrozenSet[cirq.MeasurementKey] = frozenset(),
92
95
  use_repetition_ids: Optional[bool] = None,
93
- repeat_until: Optional['cirq.Condition'] = None,
96
+ repeat_until: Optional[cirq.Condition] = None,
94
97
  ):
95
98
  """Initializes a CircuitOperation.
96
99
 
@@ -214,7 +217,7 @@ class CircuitOperation(ops.Operation):
214
217
  raise ValueError('Infinite loop: condition is not modified in subcircuit.')
215
218
 
216
219
  @property
217
- def circuit(self) -> 'cirq.FrozenCircuit':
220
+ def circuit(self) -> cirq.FrozenCircuit:
218
221
  return self._circuit
219
222
 
220
223
  @property
@@ -230,11 +233,11 @@ class CircuitOperation(ops.Operation):
230
233
  return self._use_repetition_ids
231
234
 
232
235
  @property
233
- def repeat_until(self) -> Optional['cirq.Condition']:
236
+ def repeat_until(self) -> Optional[cirq.Condition]:
234
237
  return self._repeat_until
235
238
 
236
239
  @property
237
- def qubit_map(self) -> Mapping['cirq.Qid', 'cirq.Qid']:
240
+ def qubit_map(self) -> Mapping[cirq.Qid, cirq.Qid]:
238
241
  return self._qubit_map
239
242
 
240
243
  @property
@@ -249,14 +252,14 @@ class CircuitOperation(ops.Operation):
249
252
  def parent_path(self) -> Tuple[str, ...]:
250
253
  return self._parent_path
251
254
 
252
- def base_operation(self) -> 'cirq.CircuitOperation':
255
+ def base_operation(self) -> cirq.CircuitOperation:
253
256
  """Returns a copy of this operation with only the wrapped circuit.
254
257
 
255
258
  Key and qubit mappings, parameter values, and repetitions are not copied.
256
259
  """
257
260
  return CircuitOperation(self.circuit)
258
261
 
259
- def replace(self, **changes) -> 'cirq.CircuitOperation':
262
+ def replace(self, **changes) -> cirq.CircuitOperation:
260
263
  """Returns a copy of this operation with the specified changes."""
261
264
  kwargs = {
262
265
  'circuit': self.circuit,
@@ -293,7 +296,7 @@ class CircuitOperation(ops.Operation):
293
296
  # Methods for getting post-mapping properties of the contained circuit.
294
297
 
295
298
  @property
296
- def qubits(self) -> Tuple['cirq.Qid', ...]:
299
+ def qubits(self) -> Tuple[cirq.Qid, ...]:
297
300
  """Returns the qubits operated on by this object."""
298
301
  ordered_qubits = ops.QubitOrder.DEFAULT.order_for(self.circuit.all_qubits())
299
302
  return tuple(self.qubit_map.get(q, q) for q in ordered_qubits)
@@ -319,7 +322,7 @@ class CircuitOperation(ops.Operation):
319
322
  raise ValueError('Cannot unroll circuit due to nondeterministic repetitions')
320
323
 
321
324
  @cached_property
322
- def _measurement_key_objs(self) -> FrozenSet['cirq.MeasurementKey']:
325
+ def _measurement_key_objs(self) -> FrozenSet[cirq.MeasurementKey]:
323
326
  circuit_keys = protocols.measurement_key_objs(self.circuit)
324
327
  if circuit_keys and self.use_repetition_ids:
325
328
  self._ensure_deterministic_loop_count()
@@ -337,14 +340,14 @@ class CircuitOperation(ops.Operation):
337
340
  for key in circuit_keys
338
341
  )
339
342
 
340
- def _measurement_key_objs_(self) -> FrozenSet['cirq.MeasurementKey']:
343
+ def _measurement_key_objs_(self) -> FrozenSet[cirq.MeasurementKey]:
341
344
  return self._measurement_key_objs
342
345
 
343
346
  def _measurement_key_names_(self) -> FrozenSet[str]:
344
347
  return frozenset(str(key) for key in self._measurement_key_objs_())
345
348
 
346
349
  @cached_property
347
- def _control_keys(self) -> FrozenSet['cirq.MeasurementKey']:
350
+ def _control_keys(self) -> FrozenSet[cirq.MeasurementKey]:
348
351
  keys = (
349
352
  frozenset()
350
353
  if not protocols.control_keys(self.circuit)
@@ -355,7 +358,7 @@ class CircuitOperation(ops.Operation):
355
358
  keys |= frozenset(mapped_repeat_until.keys) - self._measurement_key_objs_()
356
359
  return keys
357
360
 
358
- def _control_keys_(self) -> FrozenSet['cirq.MeasurementKey']:
361
+ def _control_keys_(self) -> FrozenSet[cirq.MeasurementKey]:
359
362
  return self._control_keys
360
363
 
361
364
  def _is_parameterized_(self) -> bool:
@@ -370,7 +373,7 @@ class CircuitOperation(ops.Operation):
370
373
  yield from protocols.parameter_names(self._mapped_any_loop)
371
374
 
372
375
  @cached_property
373
- def _mapped_any_loop(self) -> 'cirq.Circuit':
376
+ def _mapped_any_loop(self) -> cirq.Circuit:
374
377
  circuit = self.circuit.unfreeze()
375
378
  if self.qubit_map:
376
379
  circuit = circuit.transform_qubits(lambda q: self.qubit_map.get(q, q))
@@ -382,7 +385,7 @@ class CircuitOperation(ops.Operation):
382
385
  circuit = protocols.resolve_parameters(circuit, self.param_resolver, recursive=False)
383
386
  return circuit.unfreeze(copy=False)
384
387
 
385
- def _mapped_single_loop(self, repetition_id: Optional[str] = None) -> 'cirq.Circuit':
388
+ def _mapped_single_loop(self, repetition_id: Optional[str] = None) -> cirq.Circuit:
386
389
  circuit = self._mapped_any_loop
387
390
  if repetition_id:
388
391
  circuit = protocols.with_rescoped_keys(circuit, (repetition_id,))
@@ -391,7 +394,7 @@ class CircuitOperation(ops.Operation):
391
394
  )
392
395
 
393
396
  @cached_property
394
- def _mapped_repeat_until(self) -> Optional['cirq.Condition']:
397
+ def _mapped_repeat_until(self) -> Optional[cirq.Condition]:
395
398
  """Applies measurement_key_map, param_resolver, and current scope to repeat_until."""
396
399
  repeat_until = self.repeat_until
397
400
  if not repeat_until:
@@ -410,7 +413,7 @@ class CircuitOperation(ops.Operation):
410
413
  bindable_keys=self._extern_keys | self._measurement_key_objs,
411
414
  )
412
415
 
413
- def mapped_circuit(self, deep: bool = False) -> 'cirq.Circuit':
416
+ def mapped_circuit(self, deep: bool = False) -> cirq.Circuit:
414
417
  """Applies all maps to the contained circuit and returns the result.
415
418
 
416
419
  Args:
@@ -438,14 +441,14 @@ class CircuitOperation(ops.Operation):
438
441
  )
439
442
  return circuit
440
443
 
441
- def mapped_op(self, deep: bool = False) -> 'cirq.CircuitOperation':
444
+ def mapped_op(self, deep: bool = False) -> cirq.CircuitOperation:
442
445
  """As `mapped_circuit`, but wraps the result in a CircuitOperation."""
443
446
  return CircuitOperation(circuit=self.mapped_circuit(deep=deep).freeze())
444
447
 
445
- def _decompose_(self) -> Iterator['cirq.Operation']:
448
+ def _decompose_(self) -> Iterator[cirq.Operation]:
446
449
  return self.mapped_circuit(deep=False).all_operations()
447
450
 
448
- def _act_on_(self, sim_state: 'cirq.SimulationStateBase') -> bool:
451
+ def _act_on_(self, sim_state: cirq.SimulationStateBase) -> bool:
449
452
  mapped_repeat_until = self._mapped_repeat_until
450
453
  if mapped_repeat_until:
451
454
  circuit = self._mapped_single_loop()
@@ -593,7 +596,7 @@ class CircuitOperation(ops.Operation):
593
596
  repetitions: Optional[IntParam] = None,
594
597
  repetition_ids: Optional[Sequence[str]] = None,
595
598
  use_repetition_ids: Optional[bool] = None,
596
- ) -> 'CircuitOperation':
599
+ ) -> CircuitOperation:
597
600
  """Returns a copy of this operation repeated 'repetitions' times.
598
601
  Each repetition instance will be identified by a single repetition_id.
599
602
 
@@ -656,7 +659,7 @@ class CircuitOperation(ops.Operation):
656
659
  use_repetition_ids=use_repetition_ids,
657
660
  )
658
661
 
659
- def __pow__(self, power: IntParam) -> 'cirq.CircuitOperation':
662
+ def __pow__(self, power: IntParam) -> cirq.CircuitOperation:
660
663
  return self.repeat(power)
661
664
 
662
665
  def _with_key_path_(self, path: Tuple[str, ...]):
@@ -666,7 +669,7 @@ class CircuitOperation(ops.Operation):
666
669
  return self.replace(parent_path=prefix + self.parent_path)
667
670
 
668
671
  def _with_rescoped_keys_(
669
- self, path: Tuple[str, ...], bindable_keys: FrozenSet['cirq.MeasurementKey']
672
+ self, path: Tuple[str, ...], bindable_keys: FrozenSet[cirq.MeasurementKey]
670
673
  ):
671
674
  # The following line prevents binding to measurement keys in previous repeated subcircuits
672
675
  # "just because their repetition ids matched". If we eventually decide to change that
@@ -690,7 +693,7 @@ class CircuitOperation(ops.Operation):
690
693
  """
691
694
  return self._with_key_path_(path)
692
695
 
693
- def with_repetition_ids(self, repetition_ids: List[str]) -> 'cirq.CircuitOperation':
696
+ def with_repetition_ids(self, repetition_ids: List[str]) -> cirq.CircuitOperation:
694
697
  """Returns a copy of this `CircuitOperation` with the given repetition IDs.
695
698
 
696
699
  Args:
@@ -703,8 +706,8 @@ class CircuitOperation(ops.Operation):
703
706
  return self.replace(repetition_ids=repetition_ids)
704
707
 
705
708
  def with_qubit_mapping(
706
- self, qubit_map: Union[Mapping['cirq.Qid', 'cirq.Qid'], Callable[['cirq.Qid'], 'cirq.Qid']]
707
- ) -> 'cirq.CircuitOperation':
709
+ self, qubit_map: Union[Mapping[cirq.Qid, cirq.Qid], Callable[[cirq.Qid], cirq.Qid]]
710
+ ) -> cirq.CircuitOperation:
708
711
  """Returns a copy of this operation with an updated qubit mapping.
709
712
 
710
713
  Users should pass either 'qubit_map' or 'transform' to this method.
@@ -743,7 +746,7 @@ class CircuitOperation(ops.Operation):
743
746
  )
744
747
  return new_op
745
748
 
746
- def with_qubits(self, *new_qubits: 'cirq.Qid') -> 'cirq.CircuitOperation':
749
+ def with_qubits(self, *new_qubits: cirq.Qid) -> cirq.CircuitOperation:
747
750
  """Returns a copy of this operation with an updated qubit mapping.
748
751
 
749
752
  Args:
@@ -763,7 +766,7 @@ class CircuitOperation(ops.Operation):
763
766
  raise ValueError(f'Expected {expected} qubits, got {len(new_qubits)}.')
764
767
  return self.with_qubit_mapping(dict(zip(self.qubits, new_qubits)))
765
768
 
766
- def with_measurement_key_mapping(self, key_map: Mapping[str, str]) -> 'cirq.CircuitOperation':
769
+ def with_measurement_key_mapping(self, key_map: Mapping[str, str]) -> cirq.CircuitOperation:
767
770
  """Returns a copy of this operation with an updated key mapping.
768
771
 
769
772
  Args:
@@ -797,12 +800,12 @@ class CircuitOperation(ops.Operation):
797
800
  )
798
801
  return new_op
799
802
 
800
- def _with_measurement_key_mapping_(self, key_map: Mapping[str, str]) -> 'cirq.CircuitOperation':
803
+ def _with_measurement_key_mapping_(self, key_map: Mapping[str, str]) -> cirq.CircuitOperation:
801
804
  return self.with_measurement_key_mapping(key_map)
802
805
 
803
806
  def with_params(
804
- self, param_values: 'cirq.ParamResolverOrSimilarType', recursive: bool = False
805
- ) -> 'cirq.CircuitOperation':
807
+ self, param_values: cirq.ParamResolverOrSimilarType, recursive: bool = False
808
+ ) -> cirq.CircuitOperation:
806
809
  """Returns a copy of this operation with an updated ParamResolver.
807
810
 
808
811
  Any existing parameter mappings will have their values updated given
@@ -838,8 +841,8 @@ class CircuitOperation(ops.Operation):
838
841
  return self.replace(param_resolver=new_params)
839
842
 
840
843
  def _resolve_parameters_(
841
- self, resolver: 'cirq.ParamResolver', recursive: bool
842
- ) -> 'cirq.CircuitOperation':
844
+ self, resolver: cirq.ParamResolver, recursive: bool
845
+ ) -> cirq.CircuitOperation:
843
846
  resolved = self.with_params(resolver.param_dict, recursive)
844
847
  # repetitions can resolve to a float, but this is ok since constructor converts to
845
848
  # nearby int.
@@ -168,7 +168,7 @@ def test_with_qubits():
168
168
 
169
169
  assert op_base.with_qubit_mapping({a: d, b: c, d: a}) == op_with_qubits
170
170
 
171
- def map_fn(qubit: 'cirq.Qid') -> 'cirq.Qid':
171
+ def map_fn(qubit: cirq.Qid) -> cirq.Qid:
172
172
  if qubit == a:
173
173
  return d
174
174
  if qubit == b:
@@ -11,12 +11,13 @@
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
  import itertools
15
16
  import os
16
17
  import time
17
18
  from collections import defaultdict
18
19
  from random import randint, random, randrange, sample
19
- from typing import Iterator, Optional, Tuple, TYPE_CHECKING
20
+ from typing import Iterator, Optional, Tuple
20
21
 
21
22
  import numpy as np
22
23
  import pytest
@@ -49,9 +50,6 @@ BCONE = ValidatingTestDevice(
49
50
  )
50
51
 
51
52
 
52
- if TYPE_CHECKING:
53
- import cirq
54
-
55
53
  q0, q1, q2, q3 = cirq.LineQubit.range(4)
56
54
 
57
55
 
@@ -893,8 +891,8 @@ def test_insert_at_frontier():
893
891
  self.replacer = replacer
894
892
 
895
893
  def optimization_at(
896
- self, circuit: 'cirq.Circuit', index: int, op: 'cirq.Operation'
897
- ) -> Optional['cirq.PointOptimizationSummary']:
894
+ self, circuit: cirq.Circuit, index: int, op: cirq.Operation
895
+ ) -> Optional[cirq.PointOptimizationSummary]:
898
896
  new_ops = self.replacer(op)
899
897
  return cirq.PointOptimizationSummary(
900
898
  clear_span=1, clear_qubits=op.qubits, new_operations=new_ops
@@ -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
  """An immutable version of the Circuit data structure."""
16
+
17
+ from __future__ import annotations
18
+
15
19
  from functools import cached_property
16
20
  from types import NotImplementedType
17
21
  from typing import (
@@ -46,8 +50,8 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
46
50
 
47
51
  def __init__(
48
52
  self,
49
- *contents: 'cirq.OP_TREE',
50
- strategy: 'cirq.InsertStrategy' = InsertStrategy.EARLIEST,
53
+ *contents: cirq.OP_TREE,
54
+ strategy: cirq.InsertStrategy = InsertStrategy.EARLIEST,
51
55
  tags: Sequence[Hashable] = (),
52
56
  ) -> None:
53
57
  """Initializes a frozen circuit.
@@ -71,19 +75,19 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
71
75
  self._tags = tuple(tags)
72
76
 
73
77
  @classmethod
74
- def _from_moments(cls, moments: Iterable['cirq.Moment']) -> 'FrozenCircuit':
78
+ def _from_moments(cls, moments: Iterable[cirq.Moment]) -> FrozenCircuit:
75
79
  new_circuit = FrozenCircuit()
76
80
  new_circuit._moments = tuple(moments)
77
81
  return new_circuit
78
82
 
79
83
  @property
80
- def moments(self) -> Sequence['cirq.Moment']:
84
+ def moments(self) -> Sequence[cirq.Moment]:
81
85
  return self._moments
82
86
 
83
- def freeze(self) -> 'cirq.FrozenCircuit':
87
+ def freeze(self) -> cirq.FrozenCircuit:
84
88
  return self
85
89
 
86
- def unfreeze(self, copy: bool = True) -> 'cirq.Circuit':
90
+ def unfreeze(self, copy: bool = True) -> cirq.Circuit:
87
91
  return Circuit._from_moments(self._moments)
88
92
 
89
93
  @property
@@ -92,11 +96,11 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
92
96
  return self._tags
93
97
 
94
98
  @cached_property
95
- def untagged(self) -> 'cirq.FrozenCircuit':
99
+ def untagged(self) -> cirq.FrozenCircuit:
96
100
  """Returns the underlying FrozenCircuit without any tags."""
97
101
  return self._from_moments(self._moments) if self.tags else self
98
102
 
99
- def with_tags(self, *new_tags: Hashable) -> 'cirq.FrozenCircuit':
103
+ def with_tags(self, *new_tags: Hashable) -> cirq.FrozenCircuit:
100
104
  """Creates a new tagged `FrozenCircuit` with `self.tags` and `new_tags` combined."""
101
105
  if not new_tags:
102
106
  return self
@@ -146,28 +150,28 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
146
150
  return protocols.is_measurement(self.unfreeze())
147
151
 
148
152
  @_compat.cached_method
149
- def all_qubits(self) -> FrozenSet['cirq.Qid']:
153
+ def all_qubits(self) -> FrozenSet[cirq.Qid]:
150
154
  return super().all_qubits()
151
155
 
152
156
  @cached_property
153
- def _all_operations(self) -> Tuple['cirq.Operation', ...]:
157
+ def _all_operations(self) -> Tuple[cirq.Operation, ...]:
154
158
  return tuple(super().all_operations())
155
159
 
156
- def all_operations(self) -> Iterator['cirq.Operation']:
160
+ def all_operations(self) -> Iterator[cirq.Operation]:
157
161
  return iter(self._all_operations)
158
162
 
159
163
  def has_measurements(self) -> bool:
160
164
  return self._is_measurement_()
161
165
 
162
166
  @_compat.cached_method
163
- def all_measurement_key_objs(self) -> FrozenSet['cirq.MeasurementKey']:
167
+ def all_measurement_key_objs(self) -> FrozenSet[cirq.MeasurementKey]:
164
168
  return super().all_measurement_key_objs()
165
169
 
166
- def _measurement_key_objs_(self) -> FrozenSet['cirq.MeasurementKey']:
170
+ def _measurement_key_objs_(self) -> FrozenSet[cirq.MeasurementKey]:
167
171
  return self.all_measurement_key_objs()
168
172
 
169
173
  @_compat.cached_method
170
- def _control_keys_(self) -> FrozenSet['cirq.MeasurementKey']:
174
+ def _control_keys_(self) -> FrozenSet[cirq.MeasurementKey]:
171
175
  return super()._control_keys_()
172
176
 
173
177
  @_compat.cached_method
@@ -190,8 +194,8 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
190
194
  return super()._parameter_names_() | tag_params
191
195
 
192
196
  def _resolve_parameters_(
193
- self, resolver: 'cirq.ParamResolver', recursive: bool
194
- ) -> 'cirq.FrozenCircuit':
197
+ self, resolver: cirq.ParamResolver, recursive: bool
198
+ ) -> cirq.FrozenCircuit:
195
199
  resolved_circuit = super()._resolve_parameters_(resolver, recursive)
196
200
  resolved_tags = [
197
201
  protocols.resolve_parameters(tag, resolver, recursive) for tag in self.tags
@@ -201,23 +205,23 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
201
205
  def _measurement_key_names_(self) -> FrozenSet[str]:
202
206
  return self.all_measurement_key_names()
203
207
 
204
- def __add__(self, other) -> 'cirq.FrozenCircuit':
208
+ def __add__(self, other) -> cirq.FrozenCircuit:
205
209
  return (self.unfreeze() + other).freeze()
206
210
 
207
- def __radd__(self, other) -> 'cirq.FrozenCircuit':
211
+ def __radd__(self, other) -> cirq.FrozenCircuit:
208
212
  return (other + self.unfreeze()).freeze()
209
213
 
210
214
  # Needed for numpy to handle multiplication by np.int64 correctly.
211
215
  __array_priority__ = 10000
212
216
 
213
217
  # TODO: handle multiplication / powers differently?
214
- def __mul__(self, other) -> 'cirq.FrozenCircuit':
218
+ def __mul__(self, other) -> cirq.FrozenCircuit:
215
219
  return (self.unfreeze() * other).freeze()
216
220
 
217
- def __rmul__(self, other) -> 'cirq.FrozenCircuit':
221
+ def __rmul__(self, other) -> cirq.FrozenCircuit:
218
222
  return (other * self.unfreeze()).freeze()
219
223
 
220
- def __pow__(self, other) -> 'cirq.FrozenCircuit':
224
+ def __pow__(self, other) -> cirq.FrozenCircuit:
221
225
  try:
222
226
  return (self.unfreeze() ** other).freeze()
223
227
  except:
@@ -238,20 +242,20 @@ class FrozenCircuit(AbstractCircuit, protocols.SerializableByKey):
238
242
  return cls(moments, strategy=InsertStrategy.EARLIEST, tags=tags)
239
243
 
240
244
  def concat_ragged(
241
- *circuits: 'cirq.AbstractCircuit', align: Union['cirq.Alignment', str] = Alignment.LEFT
242
- ) -> 'cirq.FrozenCircuit':
245
+ *circuits: cirq.AbstractCircuit, align: Union[cirq.Alignment, str] = Alignment.LEFT
246
+ ) -> cirq.FrozenCircuit:
243
247
  return AbstractCircuit.concat_ragged(*circuits, align=align).freeze()
244
248
 
245
249
  concat_ragged.__doc__ = AbstractCircuit.concat_ragged.__doc__
246
250
 
247
251
  def zip(
248
- *circuits: 'cirq.AbstractCircuit', align: Union['cirq.Alignment', str] = Alignment.LEFT
249
- ) -> 'cirq.FrozenCircuit':
252
+ *circuits: cirq.AbstractCircuit, align: Union[cirq.Alignment, str] = Alignment.LEFT
253
+ ) -> cirq.FrozenCircuit:
250
254
  return AbstractCircuit.zip(*circuits, align=align).freeze()
251
255
 
252
256
  zip.__doc__ = AbstractCircuit.zip.__doc__
253
257
 
254
- def to_op(self) -> 'cirq.CircuitOperation':
258
+ def to_op(self) -> cirq.CircuitOperation:
255
259
  """Creates a CircuitOperation wrapping this circuit."""
256
260
  from cirq.circuits import CircuitOperation
257
261