cirq-core 1.6.0.dev20250702182429__py3-none-any.whl → 1.6.0.dev20250704055727__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 (60) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit.py +4 -2
  4. cirq/circuits/circuit_operation.py +2 -2
  5. cirq/circuits/circuit_test.py +157 -148
  6. cirq/circuits/moment_test.py +61 -51
  7. cirq/circuits/optimization_pass.py +1 -1
  8. cirq/circuits/text_diagram_drawer.py +6 -6
  9. cirq/conftest.py +4 -3
  10. cirq/contrib/acquaintance/bipartite_test.py +10 -8
  11. cirq/contrib/acquaintance/devices_test.py +3 -3
  12. cirq/contrib/acquaintance/executor_test.py +8 -6
  13. cirq/contrib/acquaintance/gates.py +1 -1
  14. cirq/contrib/acquaintance/gates_test.py +18 -16
  15. cirq/contrib/acquaintance/inspection_utils.py +7 -3
  16. cirq/contrib/acquaintance/permutation_test.py +24 -17
  17. cirq/contrib/acquaintance/shift_swap_network_test.py +7 -6
  18. cirq/contrib/acquaintance/strategies/quartic_paired_test.py +8 -6
  19. cirq/contrib/bayesian_network/bayesian_network_gate.py +2 -2
  20. cirq/contrib/bayesian_network/bayesian_network_gate_test.py +10 -8
  21. cirq/contrib/circuitdag/circuit_dag.py +2 -2
  22. cirq/contrib/circuitdag/circuit_dag_test.py +15 -15
  23. cirq/contrib/custom_simulators/custom_state_simulator_test.py +7 -3
  24. cirq/contrib/graph_device/graph_device.py +6 -5
  25. cirq/contrib/graph_device/graph_device_test.py +16 -14
  26. cirq/contrib/graph_device/hypergraph.py +2 -2
  27. cirq/contrib/graph_device/hypergraph_test.py +11 -11
  28. cirq/contrib/graph_device/uniform_graph_device_test.py +9 -3
  29. cirq/contrib/hacks/disable_validation.py +4 -1
  30. cirq/contrib/json.py +2 -2
  31. cirq/contrib/noise_models/noise_models.py +5 -5
  32. cirq/contrib/noise_models/noise_models_test.py +4 -0
  33. cirq/contrib/qcircuit/qcircuit_diagram_info.py +1 -1
  34. cirq/contrib/qcircuit/qcircuit_diagram_info_test.py +2 -1
  35. cirq/contrib/qcircuit/qcircuit_pdf.py +1 -1
  36. cirq/contrib/quantum_volume/quantum_volume_test.py +17 -16
  37. cirq/contrib/quimb/density_matrix.py +1 -1
  38. cirq/contrib/quimb/density_matrix_test.py +7 -7
  39. cirq/devices/noise_model_test.py +16 -14
  40. cirq/transformers/align.py +2 -2
  41. cirq/transformers/dynamical_decoupling.py +4 -4
  42. cirq/transformers/dynamical_decoupling_test.py +1 -1
  43. cirq/transformers/expand_composite_test.py +1 -1
  44. cirq/transformers/measurement_transformers.py +1 -1
  45. cirq/transformers/merge_single_qubit_gates.py +3 -3
  46. cirq/transformers/merge_single_qubit_gates_test.py +2 -2
  47. cirq/transformers/noise_adding.py +2 -2
  48. cirq/transformers/optimize_for_target_gateset.py +3 -3
  49. cirq/transformers/qubit_management_transformers.py +2 -2
  50. cirq/transformers/randomized_measurements.py +7 -7
  51. cirq/transformers/stratify.py +1 -1
  52. cirq/transformers/symbolize.py +1 -1
  53. cirq/transformers/tag_transformers.py +3 -3
  54. cirq/transformers/transformer_api.py +2 -2
  55. cirq/transformers/transformer_primitives.py +6 -6
  56. {cirq_core-1.6.0.dev20250702182429.dist-info → cirq_core-1.6.0.dev20250704055727.dist-info}/METADATA +1 -1
  57. {cirq_core-1.6.0.dev20250702182429.dist-info → cirq_core-1.6.0.dev20250704055727.dist-info}/RECORD +60 -60
  58. {cirq_core-1.6.0.dev20250702182429.dist-info → cirq_core-1.6.0.dev20250704055727.dist-info}/WHEEL +0 -0
  59. {cirq_core-1.6.0.dev20250702182429.dist-info → cirq_core-1.6.0.dev20250704055727.dist-info}/licenses/LICENSE +0 -0
  60. {cirq_core-1.6.0.dev20250702182429.dist-info → cirq_core-1.6.0.dev20250704055727.dist-info}/top_level.txt +0 -0
@@ -25,13 +25,15 @@ from cirq.devices.noise_model import validate_all_measurements
25
25
  from cirq.testing import assert_equivalent_op_tree
26
26
 
27
27
 
28
- def assert_equivalent_op_tree_sequence(x: Sequence[cirq.OP_TREE], y: Sequence[cirq.OP_TREE]):
28
+ def assert_equivalent_op_tree_sequence(
29
+ x: Sequence[cirq.OP_TREE], y: Sequence[cirq.OP_TREE]
30
+ ) -> None:
29
31
  assert len(x) == len(y)
30
32
  for a, b in zip(x, y):
31
33
  assert_equivalent_op_tree(a, b)
32
34
 
33
35
 
34
- def test_requires_one_override():
36
+ def test_requires_one_override() -> None:
35
37
  class C(cirq.NoiseModel):
36
38
  pass
37
39
 
@@ -39,7 +41,7 @@ def test_requires_one_override():
39
41
  _ = C()
40
42
 
41
43
 
42
- def test_infers_other_methods():
44
+ def test_infers_other_methods() -> None:
43
45
  q = cirq.LineQubit(0)
44
46
 
45
47
  class NoiseModelWithNoisyMomentListMethod(cirq.NoiseModel):
@@ -93,7 +95,7 @@ def test_infers_other_methods():
93
95
  )
94
96
 
95
97
 
96
- def test_no_noise():
98
+ def test_no_noise() -> None:
97
99
  q = cirq.LineQubit(0)
98
100
  m = cirq.Moment([cirq.X(q)])
99
101
  assert cirq.NO_NOISE.noisy_operation(cirq.X(q)) == cirq.X(q)
@@ -104,7 +106,7 @@ def test_no_noise():
104
106
  cirq.testing.assert_equivalent_repr(cirq.NO_NOISE)
105
107
 
106
108
 
107
- def test_constant_qubit_noise():
109
+ def test_constant_qubit_noise() -> None:
108
110
  a, b, c = cirq.LineQubit.range(3)
109
111
  damp = cirq.amplitude_damp(0.5)
110
112
  damp_all = cirq.ConstantQubitNoiseModel(damp)
@@ -126,7 +128,7 @@ def test_constant_qubit_noise():
126
128
  _ = cirq.ConstantQubitNoiseModel(cirq.CNOT**0.01)
127
129
 
128
130
 
129
- def test_constant_qubit_noise_prepend():
131
+ def test_constant_qubit_noise_prepend() -> None:
130
132
  a, b, c = cirq.LineQubit.range(3)
131
133
  damp = cirq.amplitude_damp(0.5)
132
134
  damp_all = cirq.ConstantQubitNoiseModel(damp, prepend=True)
@@ -145,7 +147,7 @@ def test_constant_qubit_noise_prepend():
145
147
  cirq.testing.assert_equivalent_repr(damp_all)
146
148
 
147
149
 
148
- def test_noise_composition():
150
+ def test_noise_composition() -> None:
149
151
  # Verify that noise models can be composed without regard to ordering, as
150
152
  # long as the noise operators commute with one another.
151
153
  a, b, c = cirq.LineQubit.range(3)
@@ -174,11 +176,11 @@ def test_noise_composition():
174
176
  assert_equivalent_op_tree(actual_zs, expected_circuit)
175
177
 
176
178
 
177
- def test_constant_qubit_noise_repr():
179
+ def test_constant_qubit_noise_repr() -> None:
178
180
  cirq.testing.assert_equivalent_repr(cirq.ConstantQubitNoiseModel(cirq.X**0.01))
179
181
 
180
182
 
181
- def test_wrap():
183
+ def test_wrap() -> None:
182
184
  class Forget(cirq.NoiseModel):
183
185
  def noisy_operation(self, operation):
184
186
  raise NotImplementedError()
@@ -195,13 +197,13 @@ def test_wrap():
195
197
  assert cirq.NoiseModel.from_noise_model_like(forget) is forget
196
198
 
197
199
  with pytest.raises(TypeError, match='Expected a NOISE_MODEL_LIKE'):
198
- _ = cirq.NoiseModel.from_noise_model_like('test')
200
+ _ = cirq.NoiseModel.from_noise_model_like('test') # type: ignore[arg-type]
199
201
 
200
202
  with pytest.raises(ValueError, match='Multi-qubit gate'):
201
203
  _ = cirq.NoiseModel.from_noise_model_like(cirq.CZ**0.01)
202
204
 
203
205
 
204
- def test_gate_substitution_noise_model():
206
+ def test_gate_substitution_noise_model() -> None:
205
207
  def _overrotation(op):
206
208
  if isinstance(op.gate, cirq.XPowGate):
207
209
  return cirq.XPowGate(exponent=op.gate.exponent + 0.1).on(*op.qubits)
@@ -217,14 +219,14 @@ def test_gate_substitution_noise_model():
217
219
  np.testing.assert_allclose(rho1, rho2)
218
220
 
219
221
 
220
- def test_moment_is_measurements():
222
+ def test_moment_is_measurements() -> None:
221
223
  q = cirq.LineQubit.range(2)
222
224
  circ = cirq.Circuit([cirq.X(q[0]), cirq.X(q[1]), cirq.measure(*q, key='z')])
223
225
  assert not validate_all_measurements(circ[0])
224
226
  assert validate_all_measurements(circ[1])
225
227
 
226
228
 
227
- def test_moment_is_measurements_mixed1():
229
+ def test_moment_is_measurements_mixed1() -> None:
228
230
  q = cirq.LineQubit.range(2)
229
231
  circ = cirq.Circuit([cirq.X(q[0]), cirq.X(q[1]), cirq.measure(q[0], key='z'), cirq.Z(q[1])])
230
232
  assert not validate_all_measurements(circ[0])
@@ -233,7 +235,7 @@ def test_moment_is_measurements_mixed1():
233
235
  assert e.match(".*must be homogeneous: all measurements.*")
234
236
 
235
237
 
236
- def test_moment_is_measurements_mixed2():
238
+ def test_moment_is_measurements_mixed2() -> None:
237
239
  q = cirq.LineQubit.range(2)
238
240
  circ = cirq.Circuit([cirq.X(q[0]), cirq.X(q[1]), cirq.Z(q[0]), cirq.measure(q[1], key='z')])
239
241
  assert not validate_all_measurements(circ[0])
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
30
30
  def align_left(
31
31
  circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
32
32
  ) -> cirq.Circuit:
33
- """Align gates to the left of the circuit.
33
+ """Aligns gates to the left of the circuit.
34
34
 
35
35
  Note that tagged operations with tag in `context.tags_to_ignore` will continue to stay in their
36
36
  original position and will not be aligned.
@@ -62,7 +62,7 @@ def align_left(
62
62
  def align_right(
63
63
  circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
64
64
  ) -> cirq.Circuit:
65
- """Align gates to the right of the circuit.
65
+ """Aligns gates to the right of the circuit.
66
66
 
67
67
  Note that tagged operations with tag in `context.tags_to_ignore` will continue to stay in their
68
68
  original position and will not be aligned.
@@ -61,7 +61,7 @@ def _pauli_up_to_global_phase(gate: ops.Gate) -> ops.Pauli | None:
61
61
  def _validate_dd_sequence(dd_sequence: tuple[ops.Gate, ...]) -> None:
62
62
  """Validates a given dynamical decoupling sequence.
63
63
 
64
- The sequence should only consists of Pauli gates and is essentially an identity gate.
64
+ The sequence should only consist of Pauli gates and is essentially an identity gate.
65
65
 
66
66
  Args:
67
67
  dd_sequence: Input dynamical sequence to be validated.
@@ -82,7 +82,7 @@ def _validate_dd_sequence(dd_sequence: tuple[ops.Gate, ...]) -> None:
82
82
 
83
83
  if not protocols.equal_up_to_global_phase(product, np.eye(2)):
84
84
  raise ValueError(
85
- 'Invalid dynamical decoupling sequence. Expect sequence production equals'
85
+ 'Invalid dynamical decoupling sequence. Expect sequence product equals'
86
86
  f' identity up to a global phase, got {product}.'.replace('\n', ' ')
87
87
  )
88
88
 
@@ -208,13 +208,13 @@ def add_dynamical_decoupling(
208
208
  single_qubit_gate_moments_only: bool = True,
209
209
  ) -> cirq.Circuit:
210
210
  """Adds dynamical decoupling gate operations to a given circuit.
211
- This transformer might add new moments thus change structure of the original circuit.
211
+ This transformer might add new moments and thus change the structure of the original circuit.
212
212
 
213
213
  Args:
214
214
  circuit: Input circuit to transform.
215
215
  context: `cirq.TransformerContext` storing common configurable options for transformers.
216
216
  schema: Dynamical decoupling schema name or a dynamical decoupling sequence.
217
- If a schema is specified, provided dynamical decouping sequence will be used.
217
+ If a schema is specified, the provided dynamical decoupling sequence will be used.
218
218
  Otherwise, customized dynamical decoupling sequence will be applied.
219
219
  single_qubit_gate_moments_only: If set True, dynamical decoupling operation will only be
220
220
  added in single-qubit gate moments.
@@ -236,7 +236,7 @@ def test_pull_through_h_gate_case2(single_qubit_gate_moments_only: bool):
236
236
  ([X], 'Invalid dynamical decoupling sequence. Expect more than one gates.'),
237
237
  (
238
238
  [X, Y],
239
- 'Invalid dynamical decoupling sequence. Expect sequence production equals identity'
239
+ 'Invalid dynamical decoupling sequence. Expect sequence product equals identity'
240
240
  ' up to a global phase, got',
241
241
  ),
242
242
  (
@@ -191,7 +191,7 @@ def test_do_not_decompose_no_compile():
191
191
  assert_equal_mod_empty(c, cirq.expand_composite(c, context=context))
192
192
 
193
193
 
194
- def test_expands_composite_recursively_preserving_structur():
194
+ def test_expands_composite_recursively_preserving_structure():
195
195
  q = cirq.LineQubit.range(2)
196
196
  c_nested = cirq.FrozenCircuit(
197
197
  cirq.SWAP(*q[:2]), cirq.SWAP(*q[:2]).with_tags("ignore"), cirq.SWAP(*q[:2])
@@ -172,7 +172,7 @@ def _all_possible_datastore_states(
172
172
  keys: Iterable[tuple[cirq.MeasurementKey, int]],
173
173
  measurement_qubits: dict[cirq.MeasurementKey, list[tuple[cirq.Qid, ...]]],
174
174
  ) -> Iterable[cirq.ClassicalDataStoreReader]:
175
- """The cartesian product of all possible DataStore states for the given keys."""
175
+ """The Cartesian product of all possible DataStore states for the given keys."""
176
176
  # First we get the list of all possible values. So if we have a key mapped to qubits of shape
177
177
  # (2, 2) and a key mapped to a qutrit, the possible measurement values are:
178
178
  # [((0, 0), (0,)),
@@ -185,7 +185,7 @@ def _sweep_on_symbols(sweep: Sweep, symbols: set[sympy.Symbol]) -> Sweep:
185
185
  def _calc_phxz_sweeps(
186
186
  symbolized_circuit: cirq.Circuit, resolved_circuits: list[cirq.Circuit]
187
187
  ) -> Sweep:
188
- """Return the phxz sweep of the symbolized_circuit on resolved_circuits.
188
+ """Returns the phxz sweep of the symbolized_circuit on resolved_circuits.
189
189
 
190
190
  Raises:
191
191
  ValueError: Structural mismatch: A `resolved_circuit` contains an unexpected gate type.
@@ -246,7 +246,7 @@ def merge_single_qubit_gates_to_phxz_symbolized(
246
246
  Args:
247
247
  circuit: Input circuit to transform. It will not be modified.
248
248
  context: `cirq.TransformerContext` storing common configurable options for transformers.
249
- sweep: Sweep of the symbols in the input circuit, updated Sweep will be returned
249
+ sweep: Sweep of the symbols in the input circuit. An updated Sweep will be returned
250
250
  based on the transformation.
251
251
  atol: Absolute tolerance to angle error. Larger values allow more negligible gates to be
252
252
  dropped, smaller values increase accuracy.
@@ -280,7 +280,7 @@ def merge_single_qubit_gates_to_phxz_symbolized(
280
280
  remaining_symbols: set[sympy.Symbol] = set(
281
281
  protocols.parameter_symbols(circuit) - single_qubit_gate_symbols
282
282
  )
283
- # If all single qubit gates are not parameterized, call the nonparamerized version of
283
+ # If all single qubit gates are not parameterized, call the non-parameterized version of
284
284
  # the transformer.
285
285
  if not single_qubit_gate_symbols:
286
286
  return (merge_single_qubit_gates_to_phxz(circuit, context=context, atol=atol), sweep)
@@ -287,7 +287,7 @@ class TestMergeSingleQubitGatesSymbolized(TestCase):
287
287
  )
288
288
  assert_optimizes(output_circuit, expected)
289
289
 
290
- # Check the unitaries are preserved for each set of sweep paramerization.
290
+ # Check the unitaries are preserved for each set of sweep parameterization.
291
291
  for old_resolver, new_resolver in zip(sweep, new_sweep):
292
292
  cirq.testing.assert_circuits_have_same_unitary_given_final_permutation(
293
293
  cirq.resolve_parameters(input_circuit, old_resolver),
@@ -310,7 +310,7 @@ class TestMergeSingleQubitGatesSymbolized(TestCase):
310
310
  new_circuit, new_sweep = cirq.merge_single_qubit_gates_to_phxz_symbolized(
311
311
  old_circuit, sweep=old_sweep
312
312
  )
313
- # Check the unitaries are preserved for each set of sweep paramerization.
313
+ # Check the unitaries are preserved for each set of sweep parameterization.
314
314
  for old_resolver, new_resolver in zip(old_sweep, new_sweep):
315
315
  cirq.testing.assert_circuits_have_same_unitary_given_final_permutation(
316
316
  cirq.resolve_parameters(old_circuit[0:-1], old_resolver),
@@ -36,7 +36,7 @@ class DepolarizingNoiseTransformer:
36
36
 
37
37
  Attrs:
38
38
  p: The probability with which to add noise.
39
- target_gate: Add depolarizing nose after this type of gate
39
+ target_gate: Add depolarizing noise after this type of gate
40
40
  """
41
41
 
42
42
  def __init__(
@@ -88,7 +88,7 @@ class DepolarizingNoiseTransformer:
88
88
  rng = np.random.default_rng()
89
89
  target_gate = self.target_gate
90
90
 
91
- # add random Pauli gates with probability p after each of the specified gate
91
+ # add random Pauli gates with probability p after each specified gate
92
92
  assert target_gate.num_qubits() == 2, "`target_gate` must be a two-qubit gate."
93
93
  paulis = [ops.I, ops.X, ops.Y, ops.Z]
94
94
  new_moments = []
@@ -46,9 +46,9 @@ def _decompose_operations_to_target_gateset(
46
46
  """Decomposes every operation to `gateset` using `cirq.decompose` and `decomposer`.
47
47
 
48
48
  This transformer attempts to decompose every operation `op` in the given circuit to `gateset`
49
- using `cirq.decompose` protocol with `decomposer` used as an intercepting decomposer. This
50
- ensures that `op` is recursively decomposed using implicitly defined known decompositions
51
- (eg: in `_decompose_` magic method on the gaet class) till either `decomposer` knows how to
49
+ using the `cirq.decompose` protocol with `decomposer` used as an intercepting decomposer. This
50
+ ensures that `op` is recursively decomposed using implicitly defined known decompositions (e.g.
51
+ in the `_decompose_` magic method on the gate class) until either `decomposer` knows how to
52
52
  decompose the given operation or the given operation belongs to `gateset`.
53
53
 
54
54
  Args:
@@ -58,7 +58,7 @@ def map_clean_and_borrowable_qubits(
58
58
  This transformer uses the `QubitManager` provided in the input to:
59
59
  - Allocate clean ancilla qubits by delegating to `qm.qalloc` for all `CleanQubit`s.
60
60
  - Allocate dirty qubits for all `BorrowableQubit` types via the following two steps:
61
- 1. First analyse the input circuit and check if there are any suitable system qubits
61
+ 1. First analyze the input circuit and check if there are any suitable system qubits
62
62
  that can be borrowed, i.e. ones which do not have any overlapping operations
63
63
  between circuit[start_index : end_index] where `(start_index, end_index)` is the
64
64
  lifespan of temporary borrowable qubit under consideration. If yes, borrow the system
@@ -84,7 +84,7 @@ def map_clean_and_borrowable_qubits(
84
84
  circuit: Input `cirq.Circuit` containing temporarily allocated
85
85
  `CleanQubit`/`BorrowableQubit`s.
86
86
  qm: An instance of `cirq.QubitManager` specifying the strategy to use for allocating /
87
- / deallocating new ancilla qubits to replace the temporary qubits.
87
+ deallocating new ancilla qubits to replace the temporary qubits.
88
88
 
89
89
  Returns:
90
90
  An updated `cirq.Circuit` with all `CleanQubit`/`BorrowableQubit` mapped to either existing
@@ -34,8 +34,8 @@ class RandomizedMeasurements:
34
34
  For more details on the randomized measurement toolbox see https://arxiv.org/abs/2203.11374
35
35
 
36
36
  Args:
37
- subsystem: The specific subsystem (e.g qubit index) to measure in random basis
38
- rest of the qubits are measured in the computational basis
37
+ subsystem: The specific subsystem (e.g., qubit index) to measure in a random basis.
38
+ The rest of the qubits are measured in the computational basis.
39
39
  """
40
40
  self.subsystem = subsystem
41
41
 
@@ -48,9 +48,9 @@ class RandomizedMeasurements:
48
48
  context: transformer_api.TransformerContext | None = None,
49
49
  ) -> cirq.Circuit:
50
50
  """Apply the transformer to the given circuit. Given an input circuit returns
51
- a new circuit with the pre-measurement unitaries and measurements gates added.
52
- to the qubits in the subsystem provided.If no subsystem is specified in the
53
- construction of this class it defaults to measuring all the qubits in the
51
+ a new circuit with the pre-measurement unitaries and measurement gates added
52
+ to the qubits in the subsystem provided. If no subsystem is specified in the
53
+ construction of this class, it defaults to measuring all the qubits in the
54
54
  randomized bases.
55
55
 
56
56
  Args:
@@ -138,7 +138,7 @@ def _pauli_basis_rotation(rng: np.random.Generator) -> cirq.Gate:
138
138
 
139
139
 
140
140
  def _single_qubit_clifford(rng: np.random.Generator) -> cirq.Gate:
141
- """Randomly generate a single-qubit Clifford rotation.
141
+ """Randomly generates a single-qubit Clifford rotation.
142
142
 
143
143
  Args:
144
144
  rng: Random number generator
@@ -156,7 +156,7 @@ def _single_qubit_clifford(rng: np.random.Generator) -> cirq.Gate:
156
156
 
157
157
 
158
158
  def _single_qubit_cue(rng: np.random.Generator) -> cirq.Gate:
159
- """Randomly generate a CUE gate.
159
+ """Randomly generates a CUE gate.
160
160
 
161
161
  Args:
162
162
  rng: Random number generator
@@ -164,7 +164,7 @@ def _stratify_circuit(
164
164
  new_moments += [[] for _ in range(num_classes)]
165
165
  new_moments[time_index].append(op)
166
166
 
167
- # Update qubit, measurment key, and control key moments.
167
+ # Update qubit, measurement key, and control key moments.
168
168
  for qubit in op.qubits:
169
169
  qubit_time_index[qubit] = time_index
170
170
  for key in protocols.measurement_key_objs(op):
@@ -75,7 +75,7 @@ def symbolize_single_qubit_gates_by_indexed_tags(
75
75
  """
76
76
 
77
77
  def _map_func(op: cirq.Operation, _):
78
- """Maps an op with tag `{tag_prefix}_i` to a symbolzied `PhasedXZGate(xi,zi,ai)`."""
78
+ """Maps an op with tag `{tag_prefix}_i` to a symbolized `PhasedXZGate(xi,zi,ai)`."""
79
79
  tags: set[Hashable] = set(op.tags)
80
80
  tag_id: None | int = None
81
81
  for tag in tags:
@@ -85,12 +85,12 @@ def remove_tags(
85
85
  target_tags = target_tags or set()
86
86
 
87
87
  def _map_func(op: cirq.Operation, _) -> cirq.OP_TREE:
88
- remaing_tags = set()
88
+ remaining_tags = set()
89
89
  for tag in op.tags:
90
90
  if not remove_if(tag) and tag not in target_tags:
91
- remaing_tags.add(tag)
91
+ remaining_tags.add(tag)
92
92
 
93
- return op.untagged.with_tags(*remaing_tags)
93
+ return op.untagged.with_tags(*remaining_tags)
94
94
 
95
95
  return transformer_primitives.map_operations(
96
96
  circuit, _map_func, deep=context.deep if context else False
@@ -88,8 +88,8 @@ class TransformerLogger:
88
88
 
89
89
  The logger assumes that
90
90
  - Transformers are run sequentially.
91
- - Nested transformers are allowed, in which case the behavior would be similar to a
92
- doing a depth first search on the graph of transformers -- i.e. the top level transformer
91
+ - Nested transformers are allowed, in which case the behavior would be similar to
92
+ doing a depth-first search on the graph of transformers -- i.e. the top level transformer
93
93
  would end (i.e. receive a `register_final` call) once all nested transformers (i.e. all
94
94
  `register_initial` calls received while the top level transformer was active) have
95
95
  finished (i.e. corresponding `register_final` calls have also been received).
@@ -125,7 +125,7 @@ def _map_operations_impl(
125
125
  resulting optree spans more than 1 moment, it's either wrapped in a tagged circuit
126
126
  operation and inserted in-place in the same moment (if `wrap_in_circuit_op` is True)
127
127
  OR the mapped operations are inserted directly in the circuit, preserving moment
128
- strucutre. The effect is equivalent to (but much faster) a two-step approach of first
128
+ structure. The effect is equivalent to (but much faster) a two-step approach of first
129
129
  wrapping the operations in a circuit operation and then calling `cirq.unroll_circuit_op`
130
130
  to unroll the corresponding circuit ops.
131
131
  deep: If true, `map_func` will be recursively applied to circuits wrapped inside
@@ -364,13 +364,13 @@ def merge_operations(
364
364
  """Merges operations in a circuit by calling `merge_func` iteratively on operations.
365
365
 
366
366
  Two operations op1 and op2 are merge-able if
367
- - There is no other operations between op1 and op2 in the circuit
367
+ - There is no other operation between op1 and op2 in the circuit
368
368
  - is_subset(op1.qubits, op2.qubits) or is_subset(op2.qubits, op1.qubits)
369
369
 
370
370
  The `merge_func` is a callable which, given two merge-able operations
371
371
  op1 and op2, decides whether they should be merged into a single operation
372
372
  or not. If not, it should return None, else it should return the single merged
373
- operations `op`.
373
+ operation `op`.
374
374
 
375
375
  The method iterates on the input circuit moment-by-moment from left to right and attempts
376
376
  to repeatedly merge each operation in the latest moment with all the corresponding merge-able
@@ -383,7 +383,7 @@ def merge_operations(
383
383
 
384
384
  The number of calls to `merge_func` is O(N), where N = Total no. of operations, because:
385
385
  - Every time the `merge_func` returns a new operation, the number of operations in the
386
- circuit reduce by 1 and hence this can happen at most O(N) times
386
+ circuit reduces by 1 and hence this can happen at most O(N) times
387
387
  - Every time the `merge_func` returns None, the current operation is inserted into the
388
388
  frontier and we go on to process the next operation, which can also happen at-most
389
389
  O(N) times.
@@ -501,7 +501,7 @@ def merge_operations_to_circuit_op(
501
501
  Args:
502
502
  circuit: Input circuit to apply the transformations on. The input circuit is not mutated.
503
503
  can_merge: Callable to determine whether a new operation `right_op` can be merged into an
504
- existing connected component of operations `left_ops` based on boolen returned by
504
+ existing connected component of operations `left_ops` based on boolean returned by
505
505
  `can_merge(left_ops, right_op)`.
506
506
  tags_to_ignore: Tagged operations marked any of `tags_to_ignore` will not be considered as
507
507
  potential candidates for any connected component.
@@ -771,7 +771,7 @@ def unroll_circuit_op_greedy_frontier(
771
771
  def toggle_tags(circuit: CIRCUIT_TYPE, tags: Sequence[Hashable], *, deep: bool = False):
772
772
  """Toggles tags applied on each operation in the circuit, via `op.tags ^= tags`
773
773
 
774
- For every operations `op` in the input circuit, the tags on `op` are replaced by a symmetric
774
+ For every operation `op` in the input circuit, the tags on `op` are replaced by a symmetric
775
775
  difference of `op.tags` and `tags` -- this is useful in scenarios where you mark a small subset
776
776
  of operations with a specific tag and then toggle the set of marked operations s.t. every
777
777
  marked operation is now unmarked and vice versa.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250702182429
3
+ Version: 1.6.0.dev20250704055727
4
4
  Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
5
5
  Home-page: http://github.com/quantumlib/cirq
6
6
  Author: The Cirq Developers