Skip to content

Commit b2ece33

Browse files
babacrypavoljuhas
authored andcommitted
Fix a couple of typos in transformers (quantumlib#7471)
I came across a couple of typos in transformers, so I ask the code assistant to help identify more of them and update all here. --------- Co-authored-by: Pavol Juhas <juhas@google.com>
1 parent ee0888d commit b2ece33

17 files changed

+42
-42
lines changed

cirq-core/cirq/transformers/align.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
def align_left(
3131
circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
3232
) -> cirq.Circuit:
33-
"""Align gates to the left of the circuit.
33+
"""Aligns gates to the left of the circuit.
3434
3535
Note that tagged operations with tag in `context.tags_to_ignore` will continue to stay in their
3636
original position and will not be aligned.
@@ -62,7 +62,7 @@ def align_left(
6262
def align_right(
6363
circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
6464
) -> cirq.Circuit:
65-
"""Align gates to the right of the circuit.
65+
"""Aligns gates to the right of the circuit.
6666
6767
Note that tagged operations with tag in `context.tags_to_ignore` will continue to stay in their
6868
original position and will not be aligned.

cirq-core/cirq/transformers/dynamical_decoupling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _pauli_up_to_global_phase(gate: ops.Gate) -> ops.Pauli | None:
6161
def _validate_dd_sequence(dd_sequence: tuple[ops.Gate, ...]) -> None:
6262
"""Validates a given dynamical decoupling sequence.
6363
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.
6565
6666
Args:
6767
dd_sequence: Input dynamical sequence to be validated.
@@ -82,7 +82,7 @@ def _validate_dd_sequence(dd_sequence: tuple[ops.Gate, ...]) -> None:
8282

8383
if not protocols.equal_up_to_global_phase(product, np.eye(2)):
8484
raise ValueError(
85-
'Invalid dynamical decoupling sequence. Expect sequence production equals'
85+
'Invalid dynamical decoupling sequence. Expect sequence product equals'
8686
f' identity up to a global phase, got {product}.'.replace('\n', ' ')
8787
)
8888

@@ -208,13 +208,13 @@ def add_dynamical_decoupling(
208208
single_qubit_gate_moments_only: bool = True,
209209
) -> cirq.Circuit:
210210
"""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.
212212
213213
Args:
214214
circuit: Input circuit to transform.
215215
context: `cirq.TransformerContext` storing common configurable options for transformers.
216216
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.
218218
Otherwise, customized dynamical decoupling sequence will be applied.
219219
single_qubit_gate_moments_only: If set True, dynamical decoupling operation will only be
220220
added in single-qubit gate moments.

cirq-core/cirq/transformers/dynamical_decoupling_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_pull_through_h_gate_case2(single_qubit_gate_moments_only: bool):
236236
([X], 'Invalid dynamical decoupling sequence. Expect more than one gates.'),
237237
(
238238
[X, Y],
239-
'Invalid dynamical decoupling sequence. Expect sequence production equals identity'
239+
'Invalid dynamical decoupling sequence. Expect sequence product equals identity'
240240
' up to a global phase, got',
241241
),
242242
(

cirq-core/cirq/transformers/expand_composite_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def test_do_not_decompose_no_compile():
191191
assert_equal_mod_empty(c, cirq.expand_composite(c, context=context))
192192

193193

194-
def test_expands_composite_recursively_preserving_structur():
194+
def test_expands_composite_recursively_preserving_structure():
195195
q = cirq.LineQubit.range(2)
196196
c_nested = cirq.FrozenCircuit(
197197
cirq.SWAP(*q[:2]), cirq.SWAP(*q[:2]).with_tags("ignore"), cirq.SWAP(*q[:2])

cirq-core/cirq/transformers/measurement_transformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _all_possible_datastore_states(
172172
keys: Iterable[tuple[cirq.MeasurementKey, int]],
173173
measurement_qubits: dict[cirq.MeasurementKey, list[tuple[cirq.Qid, ...]]],
174174
) -> 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."""
176176
# First we get the list of all possible values. So if we have a key mapped to qubits of shape
177177
# (2, 2) and a key mapped to a qutrit, the possible measurement values are:
178178
# [((0, 0), (0,)),

cirq-core/cirq/transformers/merge_single_qubit_gates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _sweep_on_symbols(sweep: Sweep, symbols: set[sympy.Symbol]) -> Sweep:
185185
def _calc_phxz_sweeps(
186186
symbolized_circuit: cirq.Circuit, resolved_circuits: list[cirq.Circuit]
187187
) -> 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.
189189
190190
Raises:
191191
ValueError: Structural mismatch: A `resolved_circuit` contains an unexpected gate type.
@@ -246,7 +246,7 @@ def merge_single_qubit_gates_to_phxz_symbolized(
246246
Args:
247247
circuit: Input circuit to transform. It will not be modified.
248248
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
250250
based on the transformation.
251251
atol: Absolute tolerance to angle error. Larger values allow more negligible gates to be
252252
dropped, smaller values increase accuracy.
@@ -280,7 +280,7 @@ def merge_single_qubit_gates_to_phxz_symbolized(
280280
remaining_symbols: set[sympy.Symbol] = set(
281281
protocols.parameter_symbols(circuit) - single_qubit_gate_symbols
282282
)
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
284284
# the transformer.
285285
if not single_qubit_gate_symbols:
286286
return (merge_single_qubit_gates_to_phxz(circuit, context=context, atol=atol), sweep)

cirq-core/cirq/transformers/merge_single_qubit_gates_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_case1(self):
287287
)
288288
assert_optimizes(output_circuit, expected)
289289

290-
# Check the unitaries are preserved for each set of sweep paramerization.
290+
# Check the unitaries are preserved for each set of sweep parameterization.
291291
for old_resolver, new_resolver in zip(sweep, new_sweep):
292292
cirq.testing.assert_circuits_have_same_unitary_given_final_permutation(
293293
cirq.resolve_parameters(input_circuit, old_resolver),
@@ -310,7 +310,7 @@ def test_with_gauge_compiling_as_sweep_success(self):
310310
new_circuit, new_sweep = cirq.merge_single_qubit_gates_to_phxz_symbolized(
311311
old_circuit, sweep=old_sweep
312312
)
313-
# Check the unitaries are preserved for each set of sweep paramerization.
313+
# Check the unitaries are preserved for each set of sweep parameterization.
314314
for old_resolver, new_resolver in zip(old_sweep, new_sweep):
315315
cirq.testing.assert_circuits_have_same_unitary_given_final_permutation(
316316
cirq.resolve_parameters(old_circuit[0:-1], old_resolver),

cirq-core/cirq/transformers/noise_adding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DepolarizingNoiseTransformer:
3636
3737
Attrs:
3838
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
4040
"""
4141

4242
def __init__(
@@ -88,7 +88,7 @@ def __call__(
8888
rng = np.random.default_rng()
8989
target_gate = self.target_gate
9090

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
9292
assert target_gate.num_qubits() == 2, "`target_gate` must be a two-qubit gate."
9393
paulis = [ops.I, ops.X, ops.Y, ops.Z]
9494
new_moments = []

cirq-core/cirq/transformers/optimize_for_target_gateset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def _decompose_operations_to_target_gateset(
4646
"""Decomposes every operation to `gateset` using `cirq.decompose` and `decomposer`.
4747
4848
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
5252
decompose the given operation or the given operation belongs to `gateset`.
5353
5454
Args:

cirq-core/cirq/transformers/qubit_management_transformers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def map_clean_and_borrowable_qubits(
5858
This transformer uses the `QubitManager` provided in the input to:
5959
- Allocate clean ancilla qubits by delegating to `qm.qalloc` for all `CleanQubit`s.
6060
- 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
6262
that can be borrowed, i.e. ones which do not have any overlapping operations
6363
between circuit[start_index : end_index] where `(start_index, end_index)` is the
6464
lifespan of temporary borrowable qubit under consideration. If yes, borrow the system
@@ -84,7 +84,7 @@ def map_clean_and_borrowable_qubits(
8484
circuit: Input `cirq.Circuit` containing temporarily allocated
8585
`CleanQubit`/`BorrowableQubit`s.
8686
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.
8888
8989
Returns:
9090
An updated `cirq.Circuit` with all `CleanQubit`/`BorrowableQubit` mapped to either existing

0 commit comments

Comments
 (0)