cirq-core 1.7.0.dev20250915211227__py3-none-any.whl → 1.7.0.dev20250917023732__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 (66) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit_operation_test.py +5 -0
  4. cirq/ops/classically_controlled_operation.py +3 -7
  5. cirq/ops/measure_util.py +7 -6
  6. cirq/ops/pauli_string_test.py +2 -2
  7. cirq/ops/raw_types.py +19 -2
  8. cirq/protocols/has_stabilizer_effect_protocol_test.py +11 -9
  9. cirq/protocols/has_unitary_protocol_test.py +3 -3
  10. cirq/protocols/json_serialization.py +3 -3
  11. cirq/protocols/json_serialization_test.py +31 -31
  12. cirq/protocols/kraus_protocol_test.py +5 -5
  13. cirq/protocols/measurement_key_protocol.py +31 -8
  14. cirq/protocols/mixture_protocol.py +1 -1
  15. cirq/protocols/mixture_protocol_test.py +7 -7
  16. cirq/protocols/mul_protocol_test.py +4 -4
  17. cirq/protocols/phase_protocol.py +13 -4
  18. cirq/protocols/pow_protocol_test.py +5 -5
  19. cirq/protocols/resolve_parameters.py +1 -1
  20. cirq/protocols/unitary_protocol_test.py +31 -19
  21. cirq/qis/clifford_tableau.py +14 -14
  22. cirq/qis/clifford_tableau_test.py +17 -17
  23. cirq/qis/entropy.py +1 -1
  24. cirq/qis/entropy_test.py +1 -1
  25. cirq/qis/states_test.py +54 -54
  26. cirq/sim/classical_simulator_test.py +56 -28
  27. cirq/sim/clifford/clifford_simulator.py +5 -5
  28. cirq/sim/clifford/clifford_simulator_test.py +50 -49
  29. cirq/sim/clifford/stabilizer_state_ch_form.py +9 -9
  30. cirq/sim/density_matrix_simulation_state.py +6 -6
  31. cirq/sim/density_matrix_simulator.py +1 -1
  32. cirq/sim/density_matrix_simulator_test.py +94 -84
  33. cirq/sim/density_matrix_utils_test.py +1 -1
  34. cirq/sim/mux_test.py +26 -26
  35. cirq/sim/simulation_product_state_test.py +7 -7
  36. cirq/sim/simulation_state.py +4 -4
  37. cirq/sim/simulation_state_base.py +1 -1
  38. cirq/sim/simulation_state_test.py +5 -5
  39. cirq/sim/simulator.py +2 -2
  40. cirq/sim/simulator_base_test.py +49 -35
  41. cirq/sim/simulator_test.py +39 -35
  42. cirq/sim/sparse_simulator.py +1 -1
  43. cirq/sim/sparse_simulator_test.py +92 -82
  44. cirq/sim/state_vector.py +1 -1
  45. cirq/sim/state_vector_simulation_state.py +7 -7
  46. cirq/sim/state_vector_simulator_test.py +9 -9
  47. cirq/sim/state_vector_test.py +37 -37
  48. cirq/study/result_test.py +20 -20
  49. cirq/study/sweepable_test.py +20 -20
  50. cirq/study/sweeps_test.py +43 -43
  51. cirq/testing/circuit_compare_test.py +16 -14
  52. cirq/testing/consistent_channels.py +2 -2
  53. cirq/testing/consistent_controlled_gate_op.py +1 -1
  54. cirq/testing/consistent_decomposition.py +4 -2
  55. cirq/testing/consistent_phase_by.py +1 -1
  56. cirq/testing/consistent_qasm.py +2 -2
  57. cirq/testing/consistent_qasm_test.py +3 -3
  58. cirq/transformers/eject_z.py +1 -0
  59. cirq/transformers/gauge_compiling/__init__.py +5 -0
  60. cirq/transformers/gauge_compiling/idle_moments_gauge.py +222 -0
  61. cirq/transformers/gauge_compiling/idle_moments_gauge_test.py +193 -0
  62. {cirq_core-1.7.0.dev20250915211227.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/METADATA +1 -1
  63. {cirq_core-1.7.0.dev20250915211227.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/RECORD +66 -64
  64. {cirq_core-1.7.0.dev20250915211227.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/WHEEL +0 -0
  65. {cirq_core-1.7.0.dev20250915211227.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/licenses/LICENSE +0 -0
  66. {cirq_core-1.7.0.dev20250915211227.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/top_level.txt +0 -0
@@ -32,10 +32,10 @@ class Fixed(cirq.Operation):
32
32
  return self.unitary
33
33
 
34
34
  @property
35
- def qubits(self):
36
- return cirq.LineQubit.range(self.unitary.shape[0].bit_length() - 1)
35
+ def qubits(self) -> tuple[cirq.Qid, ...]:
36
+ return tuple(cirq.LineQubit.range(self.unitary.shape[0].bit_length() - 1))
37
37
 
38
- def with_qubits(self, *new_qubits):
38
+ def with_qubits(self, *new_qubits) -> Fixed:
39
39
  raise NotImplementedError()
40
40
 
41
41
  def _qasm_(self, args: cirq.QasmArgs):
@@ -119,6 +119,7 @@ def eject_z(
119
119
  return []
120
120
 
121
121
  # Try to move the tracked phases over the operation via protocols.phase_by(op)
122
+ phased_op: cirq.Operation | None
122
123
  phased_op = op
123
124
  for i, p in enumerate([qubit_phase[q] for q in op.qubits]):
124
125
  if not single_qubit_decompositions.is_negligible_turn(p, atol):
@@ -42,3 +42,8 @@ from cirq.transformers.gauge_compiling.sqrt_iswap_gauge import (
42
42
  from cirq.transformers.gauge_compiling.cphase_gauge import (
43
43
  CPhaseGaugeTransformer as CPhaseGaugeTransformer,
44
44
  )
45
+
46
+
47
+ from cirq.transformers.gauge_compiling.idle_moments_gauge import (
48
+ IdleMomentsGauge as IdleMomentsGauge,
49
+ )
@@ -0,0 +1,222 @@
1
+ # Copyright 2025 The Cirq Developers
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ from __future__ import annotations
15
+
16
+ import functools
17
+ from typing import Hashable, Iterator, Sequence, TYPE_CHECKING
18
+
19
+ import attrs
20
+ import numpy as np
21
+
22
+ import cirq.circuits as circuits
23
+ import cirq.ops as ops
24
+ import cirq.protocols as protocols
25
+ import cirq.transformers.transformer_api as transformer_api
26
+
27
+ if TYPE_CHECKING:
28
+ import cirq
29
+
30
+ _PAULIS: tuple[cirq.Gate, ...] = (ops.I, ops.X, ops.Y, ops.Z) # type: ignore[has-type]
31
+ _CLIFFORDS = tuple(ops.SingleQubitCliffordGate.all_single_qubit_cliffords)
32
+ _INV_CLIFFORDS = tuple(c**-1 for c in ops.SingleQubitCliffordGate.all_single_qubit_cliffords)
33
+
34
+ _NAME_TO_GATES = {'pauli': _PAULIS, 'clifford': _CLIFFORDS, 'inv_clifford': _INV_CLIFFORDS}
35
+
36
+
37
+ def _gauges_arg_converter(gauges: str | Sequence[cirq.Gate] = 'clifford') -> tuple[cirq.Gate, ...]:
38
+ if isinstance(gauges, str):
39
+ if gauges not in _NAME_TO_GATES:
40
+ valid_names = tuple(_NAME_TO_GATES.keys())
41
+ raise ValueError(f"{gauges} is not a valid gauge name, valid names are {valid_names}")
42
+ return _NAME_TO_GATES[gauges]
43
+ return tuple(gauges)
44
+
45
+
46
+ def _repr_fn(gauges: tuple[cirq.Gate, ...]) -> str:
47
+ if gauges is _PAULIS or gauges == _PAULIS:
48
+ return '"pauli"'
49
+ if gauges is _CLIFFORDS or gauges == _CLIFFORDS:
50
+ return '"clifford"'
51
+ if gauges is _INV_CLIFFORDS or gauges == _INV_CLIFFORDS:
52
+ return '"inv_clifford"'
53
+ return repr(gauges)
54
+
55
+
56
+ def _get_structure(
57
+ active: list[tuple[int, bool]],
58
+ min_length: int,
59
+ n: int,
60
+ gauge_beginning: bool,
61
+ gauge_ending: bool,
62
+ ) -> Iterator[tuple[int, int]]:
63
+ if gauge_beginning:
64
+ stop, is_mergable = active[0]
65
+ if min_length <= stop:
66
+ if is_mergable:
67
+ yield (0, stop)
68
+ else:
69
+ yield (0, stop - 1)
70
+
71
+ for i in range(len(active) - 1):
72
+ left_pos, left_is_mergable = active[i]
73
+ right_pos, right_is_mergable = active[i + 1]
74
+ if right_pos - left_pos - 1 >= min_length:
75
+ yield (left_pos + 1 - left_is_mergable, right_pos - 1 + right_is_mergable)
76
+
77
+ if gauge_ending:
78
+ stop, is_mergable = active[-1]
79
+ if min_length <= n - stop - 1:
80
+ if is_mergable:
81
+ yield (stop, n - 1)
82
+ else:
83
+ yield (stop + 1, n - 1)
84
+
85
+
86
+ def _merge(g1: cirq.Gate, g2: cirq.Gate, q: cirq.Qid, tags: Sequence[Hashable]) -> cirq.Operation:
87
+ u1 = protocols.unitary(g1)
88
+ u2 = protocols.unitary(g2)
89
+ return ops.PhasedXZGate.from_matrix(u2 @ u1)(q).with_tags(*tags)
90
+
91
+
92
+ @transformer_api.transformer
93
+ @attrs.frozen
94
+ class IdleMomentsGauge:
95
+ r"""A transformer that inserts identity-preserving "gauge" gates around idle qubit moments.
96
+
97
+ This transformer identifies sequences of consecutive idle moments on a single qubit
98
+ that meet a `min_length` threshold. For each such sequence, it inserts a randomly
99
+ selected gate `G` from `gauges` at the start of the idle period and its inverse `G^-1`
100
+ at the end. This ensures the logical circuit behavior remains unchanged ($G \cdot G^{-1} = I$).
101
+
102
+ The primary goal is to introduce specific structure into idle periods, which is
103
+ useful for experiments.
104
+
105
+ Attributes:
106
+ min_length: Minimum number of consecutive idle moments for a gauge to be applied (>= 1).
107
+
108
+ gauges: A sequence of `cirq.Gate` objects to randomly select from.
109
+ Can be a custom tuple or a string alias:
110
+ - `"pauli"`: Uses single-qubit Pauli gates (I, X, Y, Z).
111
+ - `"clifford"`: Uses all 24 single-qubit Clifford gates.
112
+
113
+ gauge_beginning: If `True`, applies a gauge to idle moments at the circuit's start,
114
+ before any other qubit operation. Defaults to `False`.
115
+
116
+ gauge_ending: If `True`, applies a gauge to idle moments at the circuit's end,
117
+ after the last qubit operation. Defaults to `False`.
118
+ """
119
+
120
+ min_length: int = attrs.field(
121
+ validator=(attrs.validators.instance_of(int), attrs.validators.ge(1))
122
+ )
123
+ gauges: tuple[cirq.Gate, ...] = attrs.field(
124
+ default='clifford', converter=_gauges_arg_converter, repr=_repr_fn
125
+ )
126
+ gauge_beginning: bool = False
127
+ gauge_ending: bool = False
128
+
129
+ @functools.cached_property
130
+ def gauges_inverse(self) -> tuple[cirq.Gate, ...]:
131
+ if self.gauges is _PAULIS:
132
+ return _PAULIS
133
+ if self.gauges is _CLIFFORDS:
134
+ return _INV_CLIFFORDS
135
+ if self.gauges is _INV_CLIFFORDS:
136
+ return _CLIFFORDS
137
+ return tuple(g**-1 for g in self.gauges)
138
+
139
+ def __call__(
140
+ self,
141
+ circuit: cirq.AbstractCircuit,
142
+ *,
143
+ context: transformer_api.TransformerContext | None = None,
144
+ rng_or_seed: np.random.Generator | int | None = None,
145
+ ):
146
+ """Apply the IdleMomentGauge transformer.
147
+
148
+ Args:
149
+ circuit: The circuit to process.
150
+ context: The TransformerContext.
151
+ rng_or_seed: The source of randomness.
152
+
153
+ Returns:
154
+ A transformed circuit.
155
+
156
+ Raises:
157
+ ValueError: if the TransformerContext has deep=True.
158
+ """
159
+ rng = (
160
+ rng_or_seed
161
+ if isinstance(rng_or_seed, np.random.Generator)
162
+ else np.random.default_rng(rng_or_seed)
163
+ )
164
+ context = (
165
+ context
166
+ if isinstance(context, transformer_api.TransformerContext)
167
+ else transformer_api.TransformerContext(deep=False)
168
+ )
169
+ if context.deep:
170
+ raise ValueError("IdleMomentsGauge doesn't support deep TransformerContext")
171
+
172
+ tags_to_ignore = frozenset(context.tags_to_ignore)
173
+ all_qubits = circuit.all_qubits()
174
+
175
+ active_moments: dict[cirq.Qid, list[tuple[int, bool]]] = {q: [] for q in all_qubits}
176
+ for m_id, moment in enumerate(circuit):
177
+ if not tags_to_ignore.isdisjoint(moment.tags):
178
+ for q in all_qubits:
179
+ active_moments[q].append((m_id, False))
180
+ else:
181
+ for op in moment:
182
+ is_mergable = (
183
+ len(op.qubits) == 1
184
+ and tags_to_ignore.isdisjoint(op.tags)
185
+ and op.gate is not None
186
+ )
187
+ for q in op.qubits:
188
+ active_moments[q].append((m_id, is_mergable))
189
+
190
+ single_qubit_moments = [{q: op for op in m if len(op.qubits) == 1} for m in circuit]
191
+ non_single_qubit_moments = [[op for op in m if len(op.qubits) != 1] for m in circuit]
192
+
193
+ for q, active in active_moments.items():
194
+ for s, e in _get_structure(
195
+ active, self.min_length, len(circuit), self.gauge_beginning, self.gauge_ending
196
+ ):
197
+ gate_index = rng.choice(len(self.gauges))
198
+ gate = self.gauges[gate_index]
199
+ gate_inv = self.gauges_inverse[gate_index]
200
+
201
+ if existing_op := single_qubit_moments[s].get(q, None):
202
+ existing_gate = existing_op.gate
203
+ assert existing_gate is not None
204
+ single_qubit_moments[s][q] = _merge(existing_gate, gate, q, existing_op.tags)
205
+ else:
206
+ single_qubit_moments[s][q] = gate(q)
207
+
208
+ if existing_op := single_qubit_moments[e].get(q, None):
209
+ existing_gate = existing_op.gate
210
+ assert existing_gate is not None
211
+ single_qubit_moments[e][q] = _merge(
212
+ gate_inv, existing_gate, q, existing_op.tags
213
+ )
214
+ else:
215
+ single_qubit_moments[e][q] = gate_inv(q)
216
+
217
+ return circuits.Circuit.from_moments(
218
+ *(
219
+ [op for op in sq.values()] + nsq
220
+ for sq, nsq in zip(single_qubit_moments, non_single_qubit_moments, strict=True)
221
+ )
222
+ )
@@ -0,0 +1,193 @@
1
+ # Copyright 2025 The Cirq Developers
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ import numpy as np
17
+ import pytest
18
+
19
+ import cirq
20
+ from cirq.transformers import gauge_compiling
21
+
22
+
23
+ class _MockRng(np.random.Generator):
24
+
25
+ def __init__(self, vals):
26
+ self._n_calls = 0
27
+ self._res = tuple(vals)
28
+
29
+ def choice(self, seq):
30
+ ret = self._res[self._n_calls]
31
+ self._n_calls += 1
32
+ return ret
33
+
34
+
35
+ def test_add_gauge_merges_gates():
36
+ tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
37
+
38
+ circuit = cirq.Circuit.from_moments([], [], [], cirq.X(cirq.q(0)), [], [], cirq.X(cirq.q(0)))
39
+ transformed_circuit = tr(circuit, rng_or_seed=_MockRng([3]))
40
+
41
+ assert transformed_circuit == cirq.Circuit.from_moments(
42
+ [],
43
+ [],
44
+ [],
45
+ cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
46
+ [],
47
+ [],
48
+ cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
49
+ )
50
+
51
+
52
+ def test_add_gauge_respects_ignore_tag():
53
+ tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
54
+
55
+ circuit = cirq.Circuit.from_moments(
56
+ cirq.X(cirq.q(0)), [], [], cirq.X(cirq.q(0)).with_tags('ignore')
57
+ )
58
+ transformed_circuit = tr(
59
+ circuit,
60
+ context=cirq.TransformerContext(tags_to_ignore=("ignore",)),
61
+ rng_or_seed=_MockRng([3]),
62
+ )
63
+ assert transformed_circuit == cirq.Circuit.from_moments(
64
+ cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
65
+ [],
66
+ cirq.Z(cirq.q(0)),
67
+ cirq.X(cirq.q(0)).with_tags('ignore'),
68
+ )
69
+
70
+
71
+ def test_add_gauge_respects_ignore_moment():
72
+ tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
73
+
74
+ circuit = cirq.Circuit.from_moments(
75
+ cirq.X(cirq.q(0)), [], [], cirq.Moment(cirq.X(cirq.q(0))).with_tags('ignore')
76
+ )
77
+ transformed_circuit = tr(
78
+ circuit,
79
+ context=cirq.TransformerContext(tags_to_ignore=("ignore",)),
80
+ rng_or_seed=_MockRng([3]),
81
+ )
82
+ assert transformed_circuit == cirq.Circuit.from_moments(
83
+ cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
84
+ [],
85
+ cirq.Z(cirq.q(0)),
86
+ cirq.Moment(cirq.X(cirq.q(0))).with_tags('ignore'),
87
+ )
88
+
89
+
90
+ def test_add_gauge_on_prefix():
91
+ tr = gauge_compiling.IdleMomentsGauge(3, gauges='clifford', gauge_beginning=True)
92
+
93
+ circuit = cirq.Circuit.from_moments([], [], [], cirq.CNOT(cirq.q(0), cirq.q(1)))
94
+ transformed_circuit = tr(circuit, rng_or_seed=_MockRng([20, 15]))
95
+ assert transformed_circuit == cirq.Circuit.from_moments(
96
+ [
97
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)),
98
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)),
99
+ ],
100
+ [],
101
+ [
102
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)) ** -1,
103
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)) ** -1,
104
+ ],
105
+ cirq.CNOT(cirq.q(0), cirq.q(1)),
106
+ )
107
+
108
+
109
+ def test_add_gauge_on_prefix_with_merge():
110
+ tr = gauge_compiling.IdleMomentsGauge(3, gauges=[cirq.Y], gauge_beginning=True)
111
+
112
+ circuit = cirq.Circuit.from_moments([], [], [], cirq.X(cirq.q(0)))
113
+ transformed_circuit = tr(circuit, rng_or_seed=_MockRng([0]))
114
+ assert transformed_circuit == cirq.Circuit.from_moments(
115
+ [cirq.Y(cirq.q(0))],
116
+ [],
117
+ [],
118
+ cirq.PhasedXZGate(axis_phase_exponent=0, x_exponent=0, z_exponent=1)(cirq.q(0)),
119
+ )
120
+
121
+
122
+ def test_add_gauge_on_suffix():
123
+ tr = gauge_compiling.IdleMomentsGauge(3, gauges='inv_clifford', gauge_ending=True)
124
+
125
+ circuit = cirq.Circuit.from_moments(cirq.CNOT(cirq.q(0), cirq.q(1)), [], [], [])
126
+ transformed_circuit = tr(circuit, rng_or_seed=_MockRng([20, 15]))
127
+ assert transformed_circuit == cirq.Circuit.from_moments(
128
+ cirq.CNOT(cirq.q(0), cirq.q(1)),
129
+ [
130
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)) ** -1,
131
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)) ** -1,
132
+ ],
133
+ [],
134
+ [
135
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)),
136
+ cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)),
137
+ ],
138
+ )
139
+
140
+
141
+ def test_add_gauge_on_suffix_with_merge():
142
+ tr = gauge_compiling.IdleMomentsGauge(3, gauges=[cirq.Y], gauge_ending=True)
143
+
144
+ circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], [], [])
145
+ transformed_circuit = tr(circuit, rng_or_seed=_MockRng([0]))
146
+ assert transformed_circuit == cirq.Circuit.from_moments(
147
+ cirq.PhasedXZGate(axis_phase_exponent=0, x_exponent=0, z_exponent=1)(cirq.q(0)),
148
+ [],
149
+ [],
150
+ cirq.Y(cirq.q(0)),
151
+ )
152
+
153
+
154
+ def test_add_gauge_respects_min_length():
155
+ tr = gauge_compiling.IdleMomentsGauge(2, gauges=[cirq.X])
156
+
157
+ circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], cirq.X(cirq.q(0)))
158
+ transformed_circuit = tr(circuit)
159
+ assert transformed_circuit == circuit
160
+
161
+
162
+ def test_context_with_deep_raises():
163
+ tr = gauge_compiling.IdleMomentsGauge(2, gauges=[cirq.X])
164
+
165
+ circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], cirq.X(cirq.q(0)))
166
+ with pytest.raises(
167
+ ValueError, match="IdleMomentsGauge doesn't support deep TransformerContext"
168
+ ):
169
+ _ = tr(circuit, context=cirq.TransformerContext(deep=True))
170
+
171
+
172
+ def test_gauge_with_invalid_name_raises():
173
+ with pytest.raises(ValueError, match='valid gauge'):
174
+ _ = gauge_compiling.IdleMomentsGauge(2, gauges='invalid')
175
+
176
+
177
+ def test_repr():
178
+ assert repr(gauge_compiling.IdleMomentsGauge(3, gauges='pauli')) == (
179
+ 'IdleMomentsGauge(min_length=3, gauges="pauli", '
180
+ 'gauge_beginning=False, gauge_ending=False)'
181
+ )
182
+ assert repr(gauge_compiling.IdleMomentsGauge(4, gauges='clifford')) == (
183
+ 'IdleMomentsGauge(min_length=4, gauges="clifford", '
184
+ 'gauge_beginning=False, gauge_ending=False)'
185
+ )
186
+ assert repr(gauge_compiling.IdleMomentsGauge(5, gauges='inv_clifford')) == (
187
+ 'IdleMomentsGauge(min_length=5, gauges="inv_clifford", '
188
+ 'gauge_beginning=False, gauge_ending=False)'
189
+ )
190
+ assert repr(gauge_compiling.IdleMomentsGauge(6, gauges=[cirq.X])) == (
191
+ 'IdleMomentsGauge(min_length=6, gauges=(cirq.X,), '
192
+ 'gauge_beginning=False, gauge_ending=False)'
193
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20250915211227
3
+ Version: 1.7.0.dev20250917023732
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