cirq-core 1.7.0.dev20250819195403__py3-none-any.whl → 1.7.0.dev20250820205919__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.
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/experiments/z_phase_calibration_test.py +8 -7
- cirq/interop/quirk/cells/arithmetic_cells.py +1 -1
- cirq/interop/quirk/cells/cell_test.py +5 -5
- cirq/interop/quirk/cells/composite_cell_test.py +5 -3
- cirq/interop/quirk/cells/control_cells.py +2 -2
- cirq/interop/quirk/cells/input_cells.py +3 -3
- cirq/interop/quirk/cells/input_rotation_cells.py +2 -2
- cirq/interop/quirk/cells/swap_cell.py +2 -2
- cirq/interop/quirk/cells/testing.py +1 -1
- cirq/interop/quirk/url_to_circuit.py +2 -2
- cirq/interop/quirk/url_to_circuit_test.py +11 -11
- cirq/linalg/decompositions.py +1 -1
- cirq/linalg/decompositions_test.py +52 -50
- cirq/linalg/diagonalize_test.py +2 -2
- cirq/linalg/predicates.py +1 -1
- cirq/linalg/predicates_test.py +24 -24
- cirq/linalg/transformations.py +6 -4
- cirq/neutral_atoms/neutral_atom_devices.py +1 -1
- cirq/ops/classically_controlled_operation.py +2 -2
- cirq/ops/clifford_gate.py +1 -1
- cirq/ops/common_channels_test.py +1 -1
- cirq/ops/common_gates.py +2 -2
- cirq/ops/controlled_operation.py +2 -2
- cirq/ops/controlled_operation_test.py +17 -16
- cirq/ops/dense_pauli_string_test.py +41 -37
- cirq/ops/eigen_gate_test.py +0 -7
- cirq/ops/gateset.py +3 -3
- cirq/ops/gateset_test.py +23 -23
- cirq/ops/linear_combinations.py +1 -1
- cirq/ops/linear_combinations_test.py +103 -89
- cirq/ops/matrix_gates_test.py +31 -31
- cirq/ops/measure_util_test.py +11 -10
- cirq/ops/measurement_gate_test.py +23 -22
- cirq/ops/pauli_gates.py +1 -1
- cirq/ops/pauli_measurement_gate_test.py +12 -12
- cirq/ops/pauli_string_phasor_test.py +45 -40
- cirq/ops/pauli_string_raw_types_test.py +5 -4
- cirq/ops/pauli_string_test.py +190 -118
- cirq/ops/permutation_gate.py +1 -1
- cirq/ops/raw_types.py +3 -4
- cirq/ops/raw_types_test.py +1 -1
- cirq/ops/three_qubit_gates.py +3 -3
- cirq/protocols/act_on_protocol.py +1 -1
- cirq/protocols/act_on_protocol_test.py +4 -4
- cirq/protocols/apply_channel_protocol_test.py +19 -18
- cirq/protocols/apply_mixture_protocol_test.py +20 -19
- cirq/protocols/apply_unitary_protocol_test.py +31 -23
- cirq/protocols/approximate_equality_protocol_test.py +22 -16
- cirq/protocols/circuit_diagram_info_protocol.py +4 -4
- cirq/protocols/commutes_protocol_test.py +4 -4
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250820205919.dist-info}/METADATA +1 -1
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250820205919.dist-info}/RECORD +57 -57
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250820205919.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250820205919.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250820205919.dist-info}/top_level.txt +0 -0
|
@@ -31,11 +31,11 @@ dps_xyz = cirq.DensePauliString('XYZ')
|
|
|
31
31
|
dps_zyx = cirq.DensePauliString('ZYX')
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def _make_qubits(n):
|
|
34
|
+
def _make_qubits(n) -> list[cirq.Qid]:
|
|
35
35
|
return [cirq.NamedQubit(f'q{i}') for i in range(n)]
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def test_init():
|
|
38
|
+
def test_init() -> None:
|
|
39
39
|
a = cirq.LineQubit(0)
|
|
40
40
|
with pytest.raises(ValueError, match='eigenvalues'):
|
|
41
41
|
_ = cirq.PauliStringPhasor(1j * cirq.X(a))
|
|
@@ -50,7 +50,7 @@ def test_init():
|
|
|
50
50
|
assert v2.exponent_pos == -0.125
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def test_qubit_order_mismatch():
|
|
53
|
+
def test_qubit_order_mismatch() -> None:
|
|
54
54
|
q0, q1 = cirq.LineQubit.range(2)
|
|
55
55
|
with pytest.raises(ValueError, match='are not an ordered subset'):
|
|
56
56
|
_ = cirq.PauliStringPhasor(1j * cirq.X(q0), qubits=[q1])
|
|
@@ -62,7 +62,7 @@ def test_qubit_order_mismatch():
|
|
|
62
62
|
_ = cirq.PauliStringPhasor(1j * cirq.X(q0) * cirq.X(q1), qubits=[q1, q0])
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def test_eq_ne_hash():
|
|
65
|
+
def test_eq_ne_hash() -> None:
|
|
66
66
|
q0, q1, q2, q3 = _make_qubits(4)
|
|
67
67
|
eq = cirq.testing.EqualsTester()
|
|
68
68
|
ps1 = cirq.X(q0) * cirq.Y(q1) * cirq.Z(q2)
|
|
@@ -83,7 +83,7 @@ def test_eq_ne_hash():
|
|
|
83
83
|
eq.add_equality_group(cirq.PauliStringPhasor(ps1, qubits=[q0, q1, q2, q3]))
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def test_equal_up_to_global_phase():
|
|
86
|
+
def test_equal_up_to_global_phase() -> None:
|
|
87
87
|
a, b, c = cirq.LineQubit.range(3)
|
|
88
88
|
groups = [
|
|
89
89
|
[
|
|
@@ -106,13 +106,13 @@ def test_equal_up_to_global_phase():
|
|
|
106
106
|
]
|
|
107
107
|
for g1 in groups:
|
|
108
108
|
for e1 in g1:
|
|
109
|
-
assert not e1.equal_up_to_global_phase("not even close")
|
|
109
|
+
assert not e1.equal_up_to_global_phase("not even close") # type: ignore[arg-type]
|
|
110
110
|
for g2 in groups:
|
|
111
111
|
for e2 in g2:
|
|
112
112
|
assert e1.equal_up_to_global_phase(e2) == (g1 is g2)
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
def test_map_qubits():
|
|
115
|
+
def test_map_qubits() -> None:
|
|
116
116
|
q0, q1, q2, q3, q4, q5 = _make_qubits(6)
|
|
117
117
|
qubit_map = {q1: q2, q0: q3}
|
|
118
118
|
before = cirq.PauliStringPhasor(cirq.PauliString({q0: cirq.Z, q1: cirq.Y}), exponent_neg=0.1)
|
|
@@ -129,7 +129,7 @@ def test_map_qubits():
|
|
|
129
129
|
assert before.map_qubits(qubit_map) == after
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
def test_map_qubits_missing_qubits():
|
|
132
|
+
def test_map_qubits_missing_qubits() -> None:
|
|
133
133
|
q0, q1, q2 = _make_qubits(3)
|
|
134
134
|
qubit_map = {q1: q2}
|
|
135
135
|
before = cirq.PauliStringPhasor(cirq.PauliString({q0: cirq.Z, q1: cirq.Y}), exponent_neg=0.1)
|
|
@@ -137,7 +137,8 @@ def test_map_qubits_missing_qubits():
|
|
|
137
137
|
_ = before.map_qubits(qubit_map)
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
def test_pow():
|
|
140
|
+
def test_pow() -> None:
|
|
141
|
+
s: cirq.PauliString[cirq.Qid]
|
|
141
142
|
a = cirq.LineQubit(0)
|
|
142
143
|
s = cirq.PauliString({a: cirq.X})
|
|
143
144
|
p = cirq.PauliStringPhasor(s, exponent_neg=0.25, exponent_pos=0.5)
|
|
@@ -149,7 +150,7 @@ def test_pow():
|
|
|
149
150
|
assert p**0.5 == cirq.PauliStringPhasor(s, exponent_neg=0.125, exponent_pos=0.25)
|
|
150
151
|
|
|
151
152
|
|
|
152
|
-
def test_consistent():
|
|
153
|
+
def test_consistent() -> None:
|
|
153
154
|
a, b = cirq.LineQubit.range(2)
|
|
154
155
|
op = np.exp(1j * np.pi / 2 * cirq.X(a) * cirq.X(b))
|
|
155
156
|
cirq.testing.assert_implements_consistent_protocols(op)
|
|
@@ -157,11 +158,13 @@ def test_consistent():
|
|
|
157
158
|
cirq.testing.assert_implements_consistent_protocols(p)
|
|
158
159
|
|
|
159
160
|
|
|
160
|
-
def test_conjugated_by():
|
|
161
|
+
def test_conjugated_by() -> None:
|
|
161
162
|
q0, q1 = _make_qubits(2)
|
|
162
163
|
op = cirq.SingleQubitCliffordGate.from_double_map(
|
|
163
164
|
{cirq.Z: (cirq.X, False), cirq.X: (cirq.Z, False)}
|
|
164
165
|
)(q0)
|
|
166
|
+
ps_before: cirq.PauliString[cirq.Qid]
|
|
167
|
+
ps_after: cirq.PauliString[cirq.Qid]
|
|
165
168
|
ps_before = cirq.PauliString({q0: cirq.X, q1: cirq.Y}, -1)
|
|
166
169
|
ps_after = cirq.PauliString({q0: cirq.Z, q1: cirq.Y}, -1)
|
|
167
170
|
before = cirq.PauliStringPhasor(ps_before, exponent_neg=0.1)
|
|
@@ -169,7 +172,7 @@ def test_conjugated_by():
|
|
|
169
172
|
assert before.conjugated_by(op).pauli_string == after.pauli_string
|
|
170
173
|
|
|
171
174
|
|
|
172
|
-
def test_extrapolate_effect():
|
|
175
|
+
def test_extrapolate_effect() -> None:
|
|
173
176
|
op1 = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=0.5)
|
|
174
177
|
op2 = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=1.5)
|
|
175
178
|
op3 = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=0.125)
|
|
@@ -177,7 +180,7 @@ def test_extrapolate_effect():
|
|
|
177
180
|
assert op1**0.25 == op3
|
|
178
181
|
|
|
179
182
|
|
|
180
|
-
def test_extrapolate_effect_with_symbol():
|
|
183
|
+
def test_extrapolate_effect_with_symbol() -> None:
|
|
181
184
|
eq = cirq.testing.EqualsTester()
|
|
182
185
|
eq.add_equality_group(
|
|
183
186
|
cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=sympy.Symbol('a')),
|
|
@@ -196,7 +199,8 @@ def test_extrapolate_effect_with_symbol():
|
|
|
196
199
|
)
|
|
197
200
|
|
|
198
201
|
|
|
199
|
-
def test_inverse():
|
|
202
|
+
def test_inverse() -> None:
|
|
203
|
+
i: cirq.PauliString
|
|
200
204
|
i = cirq.PauliString({})
|
|
201
205
|
op1 = cirq.PauliStringPhasor(i, exponent_neg=0.25)
|
|
202
206
|
op2 = cirq.PauliStringPhasor(i, exponent_neg=-0.25)
|
|
@@ -206,7 +210,7 @@ def test_inverse():
|
|
|
206
210
|
assert cirq.inverse(op3, None) == op4
|
|
207
211
|
|
|
208
212
|
|
|
209
|
-
def test_can_merge_with():
|
|
213
|
+
def test_can_merge_with() -> None:
|
|
210
214
|
q0, q1 = _make_qubits(2)
|
|
211
215
|
|
|
212
216
|
op1 = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=0.25)
|
|
@@ -228,7 +232,7 @@ def test_can_merge_with():
|
|
|
228
232
|
assert not op1.can_merge_with(op2)
|
|
229
233
|
|
|
230
234
|
|
|
231
|
-
def test_merge_with():
|
|
235
|
+
def test_merge_with() -> None:
|
|
232
236
|
(q0,) = _make_qubits(1)
|
|
233
237
|
|
|
234
238
|
op1 = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=0.25)
|
|
@@ -262,7 +266,7 @@ def test_merge_with():
|
|
|
262
266
|
op1.merged_with(op2)
|
|
263
267
|
|
|
264
268
|
|
|
265
|
-
def test_is_parameterized():
|
|
269
|
+
def test_is_parameterized() -> None:
|
|
266
270
|
op = cirq.PauliStringPhasor(cirq.PauliString({}))
|
|
267
271
|
assert not cirq.is_parameterized(op)
|
|
268
272
|
assert not cirq.is_parameterized(op**0.1)
|
|
@@ -270,7 +274,7 @@ def test_is_parameterized():
|
|
|
270
274
|
|
|
271
275
|
|
|
272
276
|
@pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
|
|
273
|
-
def test_with_parameters_resolved_by(resolve_fn):
|
|
277
|
+
def test_with_parameters_resolved_by(resolve_fn) -> None:
|
|
274
278
|
op = cirq.PauliStringPhasor(cirq.PauliString({}), exponent_neg=sympy.Symbol('a'))
|
|
275
279
|
resolver = cirq.ParamResolver({'a': 0.1})
|
|
276
280
|
actual = resolve_fn(op, resolver)
|
|
@@ -284,7 +288,7 @@ def test_with_parameters_resolved_by(resolve_fn):
|
|
|
284
288
|
resolve_fn(op, cirq.ParamResolver({'a': 0.1j}))
|
|
285
289
|
|
|
286
290
|
|
|
287
|
-
def test_drop_negligible():
|
|
291
|
+
def test_drop_negligible() -> None:
|
|
288
292
|
(q0,) = _make_qubits(1)
|
|
289
293
|
sym = sympy.Symbol('a')
|
|
290
294
|
circuit = cirq.Circuit(
|
|
@@ -301,7 +305,7 @@ def test_drop_negligible():
|
|
|
301
305
|
assert circuit == expected
|
|
302
306
|
|
|
303
307
|
|
|
304
|
-
def test_manual_default_decompose():
|
|
308
|
+
def test_manual_default_decompose() -> None:
|
|
305
309
|
q0, q1, q2 = _make_qubits(3)
|
|
306
310
|
|
|
307
311
|
mat = cirq.Circuit(
|
|
@@ -352,7 +356,7 @@ def test_manual_default_decompose():
|
|
|
352
356
|
(+1, -1),
|
|
353
357
|
),
|
|
354
358
|
)
|
|
355
|
-
def test_default_decompose(paulis, phase_exponent_negative: float, sign: int):
|
|
359
|
+
def test_default_decompose(paulis, phase_exponent_negative: float, sign: int) -> None:
|
|
356
360
|
paulis = [pauli for pauli in paulis if pauli is not None]
|
|
357
361
|
qubits = _make_qubits(len(paulis))
|
|
358
362
|
|
|
@@ -380,8 +384,9 @@ def test_default_decompose(paulis, phase_exponent_negative: float, sign: int):
|
|
|
380
384
|
cirq.testing.assert_allclose_up_to_global_phase(actual, expected, rtol=1e-7, atol=1e-7)
|
|
381
385
|
|
|
382
386
|
|
|
383
|
-
def test_decompose_with_symbol():
|
|
387
|
+
def test_decompose_with_symbol() -> None:
|
|
384
388
|
(q0,) = _make_qubits(1)
|
|
389
|
+
ps: cirq.PauliString[cirq.Qid]
|
|
385
390
|
ps = cirq.PauliString({q0: cirq.Y})
|
|
386
391
|
op = cirq.PauliStringPhasor(ps, exponent_neg=sympy.Symbol('a'))
|
|
387
392
|
circuit = cirq.Circuit(op)
|
|
@@ -395,7 +400,7 @@ def test_decompose_with_symbol():
|
|
|
395
400
|
cirq.testing.assert_has_diagram(circuit, "q0: ───X^0.5───X───Z^a───X───X^-0.5───")
|
|
396
401
|
|
|
397
402
|
|
|
398
|
-
def test_text_diagram():
|
|
403
|
+
def test_text_diagram() -> None:
|
|
399
404
|
q0, q1, q2 = _make_qubits(3)
|
|
400
405
|
circuit = cirq.Circuit(
|
|
401
406
|
cirq.PauliStringPhasor(cirq.PauliString({q0: cirq.Z})),
|
|
@@ -424,14 +429,14 @@ q2: ────────────────────[Z]───[X]^
|
|
|
424
429
|
)
|
|
425
430
|
|
|
426
431
|
|
|
427
|
-
def test_empty_phasor_diagram():
|
|
432
|
+
def test_empty_phasor_diagram() -> None:
|
|
428
433
|
q = cirq.LineQubit(0)
|
|
429
434
|
op = cirq.PauliSumExponential(cirq.I(q))
|
|
430
435
|
circuit = cirq.Circuit(op)
|
|
431
436
|
cirq.testing.assert_has_diagram(circuit, ' (I)**-0.6366197723675815')
|
|
432
437
|
|
|
433
438
|
|
|
434
|
-
def test_repr():
|
|
439
|
+
def test_repr() -> None:
|
|
435
440
|
q0, q1, q2 = _make_qubits(3)
|
|
436
441
|
cirq.testing.assert_equivalent_repr(
|
|
437
442
|
cirq.PauliStringPhasor(
|
|
@@ -447,7 +452,7 @@ def test_repr():
|
|
|
447
452
|
)
|
|
448
453
|
|
|
449
454
|
|
|
450
|
-
def test_str():
|
|
455
|
+
def test_str() -> None:
|
|
451
456
|
q0, q1, q2 = _make_qubits(3)
|
|
452
457
|
ps = cirq.PauliStringPhasor(cirq.PauliString({q2: cirq.Z, q1: cirq.Y, q0: cirq.X}, +1)) ** 0.5
|
|
453
458
|
assert str(ps) == '(X(q0)*Y(q1)*Z(q2))**0.5'
|
|
@@ -466,7 +471,7 @@ def test_str():
|
|
|
466
471
|
assert str(ps) == '(X(q0))**0.5'
|
|
467
472
|
|
|
468
473
|
|
|
469
|
-
def test_old_json():
|
|
474
|
+
def test_old_json() -> None:
|
|
470
475
|
"""Older versions of PauliStringPhasor did not have a qubit field."""
|
|
471
476
|
old_json = """
|
|
472
477
|
{
|
|
@@ -532,7 +537,7 @@ def test_old_json():
|
|
|
532
537
|
)
|
|
533
538
|
|
|
534
539
|
|
|
535
|
-
def test_gate_init():
|
|
540
|
+
def test_gate_init() -> None:
|
|
536
541
|
a = cirq.LineQubit(0)
|
|
537
542
|
with pytest.raises(ValueError, match='eigenvalues'):
|
|
538
543
|
_ = cirq.PauliStringPhasorGate(1j * cirq.X(a))
|
|
@@ -550,7 +555,7 @@ def test_gate_init():
|
|
|
550
555
|
assert v2.exponent_pos == -0.125
|
|
551
556
|
|
|
552
557
|
|
|
553
|
-
def test_gate_on():
|
|
558
|
+
def test_gate_on() -> None:
|
|
554
559
|
q = cirq.LineQubit(0)
|
|
555
560
|
g1 = cirq.PauliStringPhasorGate(
|
|
556
561
|
cirq.DensePauliString('X', coefficient=-1), exponent_neg=0.25, exponent_pos=-0.5
|
|
@@ -574,7 +579,7 @@ def test_gate_on():
|
|
|
574
579
|
assert op2.exponent_pos == -0.125
|
|
575
580
|
|
|
576
581
|
|
|
577
|
-
def test_gate_eq_ne_hash():
|
|
582
|
+
def test_gate_eq_ne_hash() -> None:
|
|
578
583
|
eq = cirq.testing.EqualsTester()
|
|
579
584
|
dps_xyx = cirq.DensePauliString('XYX')
|
|
580
585
|
eq.make_equality_group(
|
|
@@ -602,7 +607,7 @@ def test_gate_eq_ne_hash():
|
|
|
602
607
|
eq.add_equality_group(cirq.PauliStringPhasorGate(dps_xyz, exponent_neg=sympy.Symbol('a')))
|
|
603
608
|
|
|
604
609
|
|
|
605
|
-
def test_gate_equal_up_to_global_phase():
|
|
610
|
+
def test_gate_equal_up_to_global_phase() -> None:
|
|
606
611
|
groups = [
|
|
607
612
|
[
|
|
608
613
|
cirq.PauliStringPhasorGate(dps_x, exponent_neg=0.25),
|
|
@@ -615,13 +620,13 @@ def test_gate_equal_up_to_global_phase():
|
|
|
615
620
|
]
|
|
616
621
|
for g1 in groups:
|
|
617
622
|
for e1 in g1:
|
|
618
|
-
assert not e1.equal_up_to_global_phase("not even close")
|
|
623
|
+
assert not e1.equal_up_to_global_phase("not even close") # type: ignore[arg-type]
|
|
619
624
|
for g2 in groups:
|
|
620
625
|
for e2 in g2:
|
|
621
626
|
assert e1.equal_up_to_global_phase(e2) == (g1 is g2)
|
|
622
627
|
|
|
623
628
|
|
|
624
|
-
def test_gate_pow():
|
|
629
|
+
def test_gate_pow() -> None:
|
|
625
630
|
s = dps_x
|
|
626
631
|
p = cirq.PauliStringPhasorGate(s, exponent_neg=0.25, exponent_pos=0.5)
|
|
627
632
|
assert p**0.5 == cirq.PauliStringPhasorGate(s, exponent_neg=0.125, exponent_pos=0.25)
|
|
@@ -630,7 +635,7 @@ def test_gate_pow():
|
|
|
630
635
|
assert p**1 == p
|
|
631
636
|
|
|
632
637
|
|
|
633
|
-
def test_gate_extrapolate_effect():
|
|
638
|
+
def test_gate_extrapolate_effect() -> None:
|
|
634
639
|
gate1 = cirq.PauliStringPhasorGate(dps_empty, exponent_neg=0.5)
|
|
635
640
|
gate2 = cirq.PauliStringPhasorGate(dps_empty, exponent_neg=1.5)
|
|
636
641
|
gate3 = cirq.PauliStringPhasorGate(dps_empty, exponent_neg=0.125)
|
|
@@ -638,7 +643,7 @@ def test_gate_extrapolate_effect():
|
|
|
638
643
|
assert gate1**0.25 == gate3
|
|
639
644
|
|
|
640
645
|
|
|
641
|
-
def test_gate_extrapolate_effect_with_symbol():
|
|
646
|
+
def test_gate_extrapolate_effect_with_symbol() -> None:
|
|
642
647
|
eq = cirq.testing.EqualsTester()
|
|
643
648
|
eq.add_equality_group(
|
|
644
649
|
cirq.PauliStringPhasorGate(dps_empty, exponent_neg=sympy.Symbol('a')),
|
|
@@ -656,7 +661,7 @@ def test_gate_extrapolate_effect_with_symbol():
|
|
|
656
661
|
)
|
|
657
662
|
|
|
658
663
|
|
|
659
|
-
def test_gate_inverse():
|
|
664
|
+
def test_gate_inverse() -> None:
|
|
660
665
|
i = dps_empty
|
|
661
666
|
gate1 = cirq.PauliStringPhasorGate(i, exponent_neg=0.25)
|
|
662
667
|
gate2 = cirq.PauliStringPhasorGate(i, exponent_neg=-0.25)
|
|
@@ -666,7 +671,7 @@ def test_gate_inverse():
|
|
|
666
671
|
assert cirq.inverse(gate3, None) == gate4
|
|
667
672
|
|
|
668
673
|
|
|
669
|
-
def test_gate_is_parameterized():
|
|
674
|
+
def test_gate_is_parameterized() -> None:
|
|
670
675
|
gate = cirq.PauliStringPhasorGate(dps_empty)
|
|
671
676
|
assert not cirq.is_parameterized(gate)
|
|
672
677
|
assert not cirq.is_parameterized(gate**0.1)
|
|
@@ -674,7 +679,7 @@ def test_gate_is_parameterized():
|
|
|
674
679
|
|
|
675
680
|
|
|
676
681
|
@pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
|
|
677
|
-
def test_gate_with_parameters_resolved_by(resolve_fn):
|
|
682
|
+
def test_gate_with_parameters_resolved_by(resolve_fn) -> None:
|
|
678
683
|
gate = cirq.PauliStringPhasorGate(dps_empty, exponent_neg=sympy.Symbol('a'))
|
|
679
684
|
resolver = cirq.ParamResolver({'a': 0.1})
|
|
680
685
|
actual = resolve_fn(gate, resolver)
|
|
@@ -682,7 +687,7 @@ def test_gate_with_parameters_resolved_by(resolve_fn):
|
|
|
682
687
|
assert actual == expected
|
|
683
688
|
|
|
684
689
|
|
|
685
|
-
def test_gate_repr():
|
|
690
|
+
def test_gate_repr() -> None:
|
|
686
691
|
cirq.testing.assert_equivalent_repr(
|
|
687
692
|
cirq.PauliStringPhasorGate(dps_zyx, exponent_neg=0.5, exponent_pos=0.25)
|
|
688
693
|
)
|
|
@@ -691,7 +696,7 @@ def test_gate_repr():
|
|
|
691
696
|
)
|
|
692
697
|
|
|
693
698
|
|
|
694
|
-
def test_gate_str():
|
|
699
|
+
def test_gate_str() -> None:
|
|
695
700
|
gate = cirq.PauliStringPhasorGate(cirq.DensePauliString('ZYX', coefficient=+1)) ** 0.5
|
|
696
701
|
assert str(gate) == '(+ZYX)**0.5'
|
|
697
702
|
|
|
@@ -19,11 +19,11 @@ import pytest
|
|
|
19
19
|
import cirq
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def _make_qubits(n):
|
|
22
|
+
def _make_qubits(n) -> list[cirq.Qid]:
|
|
23
23
|
return [cirq.NamedQubit(f'q{i}') for i in range(n)]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
def test_op_calls_validate():
|
|
26
|
+
def test_op_calls_validate() -> None:
|
|
27
27
|
q0, q1, q2 = _make_qubits(3)
|
|
28
28
|
bad_qubit = cirq.NamedQubit('bad')
|
|
29
29
|
|
|
@@ -47,7 +47,7 @@ def test_op_calls_validate():
|
|
|
47
47
|
_ = g.with_qubits(q0, q1, bad_qubit)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def test_on_wrong_number_qubits():
|
|
50
|
+
def test_on_wrong_number_qubits() -> None:
|
|
51
51
|
q0, q1, q2 = _make_qubits(3)
|
|
52
52
|
|
|
53
53
|
class ExampleGate(cirq.PauliStringGateOperation):
|
|
@@ -66,7 +66,7 @@ def test_on_wrong_number_qubits():
|
|
|
66
66
|
_ = g.with_qubits(q0, q1, q2)
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def test_default_text_diagram():
|
|
69
|
+
def test_default_text_diagram() -> None:
|
|
70
70
|
class DiagramGate(cirq.PauliStringGateOperation):
|
|
71
71
|
def map_qubits(self, qubit_map):
|
|
72
72
|
pass
|
|
@@ -76,6 +76,7 @@ def test_default_text_diagram():
|
|
|
76
76
|
) -> cirq.CircuitDiagramInfo:
|
|
77
77
|
return self._pauli_string_diagram_info(args)
|
|
78
78
|
|
|
79
|
+
ps: cirq.PauliString[cirq.Qid]
|
|
79
80
|
q0, q1, q2 = _make_qubits(3)
|
|
80
81
|
ps = cirq.PauliString({q0: cirq.X, q1: cirq.Y, q2: cirq.Z})
|
|
81
82
|
|