cirq-core 1.6.0.dev20250529194600__py3-none-any.whl → 1.6.0.dev20250530203656__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/circuits/_bucket_priority_queue_test.py +20 -20
- cirq/circuits/circuit_operation_test.py +58 -56
- cirq/circuits/frozen_circuit_test.py +6 -5
- cirq/circuits/qasm_output_test.py +22 -22
- cirq/circuits/text_diagram_drawer_test.py +17 -17
- cirq/contrib/custom_simulators/custom_state_simulator_test.py +11 -10
- cirq/contrib/qasm_import/_lexer_test.py +47 -13
- cirq/contrib/qasm_import/_parser_test.py +5 -5
- cirq/contrib/qasm_import/qasm_test.py +4 -4
- cirq/contrib/quirk/export_to_quirk_test.py +16 -16
- cirq/devices/insertion_noise_model.py +2 -2
- cirq/linalg/transformations_test.py +71 -43
- cirq/ops/boolean_hamiltonian_test.py +8 -8
- cirq/ops/classically_controlled_operation_test.py +51 -51
- cirq/ops/clifford_gate_test.py +58 -54
- cirq/ops/common_gate_families_test.py +9 -7
- cirq/ops/common_gates_test.py +81 -81
- cirq/ops/control_values_test.py +17 -17
- cirq/ops/controlled_gate_test.py +34 -32
- cirq/ops/diagonal_gate_test.py +11 -11
- cirq/ops/eigen_gate_test.py +28 -20
- cirq/ops/fourier_transform.py +1 -3
- cirq/ops/fourier_transform_test.py +13 -12
- cirq/ops/gate_operation_test.py +43 -42
- cirq/ops/global_phase_op_test.py +22 -20
- cirq/ops/identity_test.py +21 -20
- cirq/ops/kraus_channel_test.py +11 -11
- cirq/ops/named_qubit_test.py +13 -13
- cirq/ops/op_tree_test.py +19 -19
- cirq/ops/phased_x_gate_test.py +16 -16
- cirq/ops/phased_x_z_gate_test.py +14 -11
- cirq/ops/projector_test.py +16 -16
- cirq/ops/qubit_order_test.py +10 -10
- cirq/ops/raw_types.py +2 -2
- cirq/ops/raw_types_test.py +51 -49
- cirq/ops/wait_gate.py +1 -1
- cirq/ops/wait_gate_test.py +6 -6
- cirq/protocols/qasm.py +2 -2
- cirq/qis/entropy_test.py +1 -1
- cirq/testing/consistent_protocols.py +1 -3
- cirq/testing/consistent_protocols_test.py +3 -3
- cirq/value/digits.py +5 -0
- cirq/value/duration.py +1 -1
- {cirq_core-1.6.0.dev20250529194600.dist-info → cirq_core-1.6.0.dev20250530203656.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250529194600.dist-info → cirq_core-1.6.0.dev20250530203656.dist-info}/RECORD +50 -50
- {cirq_core-1.6.0.dev20250529194600.dist-info → cirq_core-1.6.0.dev20250530203656.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250529194600.dist-info → cirq_core-1.6.0.dev20250530203656.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250529194600.dist-info → cirq_core-1.6.0.dev20250530203656.dist-info}/top_level.txt +0 -0
|
@@ -24,7 +24,7 @@ import cirq
|
|
|
24
24
|
ALL_SIMULATORS = (cirq.Simulator(), cirq.DensityMatrixSimulator(), cirq.CliffordSimulator())
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def test_diagram():
|
|
27
|
+
def test_diagram() -> None:
|
|
28
28
|
q0, q1 = cirq.LineQubit.range(2)
|
|
29
29
|
circuit = cirq.Circuit(cirq.measure(q0, key='a'), cirq.X(q1).with_classical_controls('a'))
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ a: ═══@═══^═══
|
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
def test_diagram_pauli():
|
|
44
|
+
def test_diagram_pauli() -> None:
|
|
45
45
|
q0, q1 = cirq.LineQubit.range(2)
|
|
46
46
|
circuit = cirq.Circuit(
|
|
47
47
|
cirq.measure_single_paulistring(cirq.X(q0), key='a'),
|
|
@@ -61,7 +61,7 @@ a: ═══@══════^═══
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def test_diagram_extra_measurements():
|
|
64
|
+
def test_diagram_extra_measurements() -> None:
|
|
65
65
|
q0, q1 = cirq.LineQubit.range(2)
|
|
66
66
|
circuit = cirq.Circuit(
|
|
67
67
|
cirq.measure(q0, key='a'),
|
|
@@ -82,7 +82,7 @@ a: ═══@═══^════════
|
|
|
82
82
|
)
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
def test_diagram_extra_controlled_bits():
|
|
85
|
+
def test_diagram_extra_controlled_bits() -> None:
|
|
86
86
|
q0, q1 = cirq.LineQubit.range(2)
|
|
87
87
|
circuit = cirq.Circuit(cirq.measure(q0, key='a'), cirq.CX(q0, q1).with_classical_controls('a'))
|
|
88
88
|
|
|
@@ -99,7 +99,7 @@ a: ═══@═══^═══
|
|
|
99
99
|
)
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
def test_diagram_extra_control_bits():
|
|
102
|
+
def test_diagram_extra_control_bits() -> None:
|
|
103
103
|
q0, q1 = cirq.LineQubit.range(2)
|
|
104
104
|
circuit = cirq.Circuit(
|
|
105
105
|
cirq.measure(q0, key='a'),
|
|
@@ -122,7 +122,7 @@ b: ═══════@═══^═══
|
|
|
122
122
|
)
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
def test_diagram_multiple_ops_single_moment():
|
|
125
|
+
def test_diagram_multiple_ops_single_moment() -> None:
|
|
126
126
|
q0, q1 = cirq.LineQubit.range(2)
|
|
127
127
|
circuit = cirq.Circuit(
|
|
128
128
|
cirq.measure(q0, key='a'),
|
|
@@ -148,7 +148,7 @@ b: ═════@══════^════
|
|
|
148
148
|
)
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
def test_diagram_subcircuit():
|
|
151
|
+
def test_diagram_subcircuit() -> None:
|
|
152
152
|
q0, q1 = cirq.LineQubit.range(2)
|
|
153
153
|
circuit = cirq.Circuit(
|
|
154
154
|
cirq.CircuitOperation(
|
|
@@ -171,7 +171,7 @@ def test_diagram_subcircuit():
|
|
|
171
171
|
)
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def test_diagram_subcircuit_layered():
|
|
174
|
+
def test_diagram_subcircuit_layered() -> None:
|
|
175
175
|
q0, q1 = cirq.LineQubit.range(2)
|
|
176
176
|
circuit = cirq.Circuit(
|
|
177
177
|
cirq.measure(q0, key='a'),
|
|
@@ -198,7 +198,7 @@ a: ═══@═══╩══════════════════
|
|
|
198
198
|
)
|
|
199
199
|
|
|
200
200
|
|
|
201
|
-
def test_qasm_sympy_condition():
|
|
201
|
+
def test_qasm_sympy_condition() -> None:
|
|
202
202
|
q0, q1 = cirq.LineQubit.range(2)
|
|
203
203
|
circuit = cirq.Circuit(
|
|
204
204
|
cirq.measure(q0, key='a'),
|
|
@@ -224,7 +224,7 @@ if (m_a==0) x q[1];
|
|
|
224
224
|
)
|
|
225
225
|
|
|
226
226
|
|
|
227
|
-
def test_qasm_key_condition():
|
|
227
|
+
def test_qasm_key_condition() -> None:
|
|
228
228
|
q0, q1 = cirq.LineQubit.range(2)
|
|
229
229
|
circuit = cirq.Circuit(cirq.measure(q0, key='a'), cirq.X(q1).with_classical_controls('a'))
|
|
230
230
|
qasm = cirq.qasm(circuit)
|
|
@@ -247,7 +247,7 @@ if (m_a==1) x q[1];
|
|
|
247
247
|
)
|
|
248
248
|
|
|
249
249
|
|
|
250
|
-
def test_qasm_no_conditions():
|
|
250
|
+
def test_qasm_no_conditions() -> None:
|
|
251
251
|
q0, q1 = cirq.LineQubit.range(2)
|
|
252
252
|
circuit = cirq.Circuit(
|
|
253
253
|
cirq.measure(q0, key='a'), cirq.ClassicallyControlledOperation(cirq.X(q1), [])
|
|
@@ -272,7 +272,7 @@ x q[1];
|
|
|
272
272
|
)
|
|
273
273
|
|
|
274
274
|
|
|
275
|
-
def test_qasm_multiple_conditions():
|
|
275
|
+
def test_qasm_multiple_conditions() -> None:
|
|
276
276
|
q0, q1 = cirq.LineQubit.range(2)
|
|
277
277
|
circuit = cirq.Circuit(
|
|
278
278
|
cirq.measure(q0, key='a'),
|
|
@@ -286,7 +286,7 @@ def test_qasm_multiple_conditions():
|
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
289
|
-
def test_key_unset(sim):
|
|
289
|
+
def test_key_unset(sim) -> None:
|
|
290
290
|
q0, q1 = cirq.LineQubit.range(2)
|
|
291
291
|
circuit = cirq.Circuit(
|
|
292
292
|
cirq.measure(q0, key='a'),
|
|
@@ -299,7 +299,7 @@ def test_key_unset(sim):
|
|
|
299
299
|
|
|
300
300
|
|
|
301
301
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
302
|
-
def test_key_set(sim):
|
|
302
|
+
def test_key_set(sim) -> None:
|
|
303
303
|
q0, q1 = cirq.LineQubit.range(2)
|
|
304
304
|
circuit = cirq.Circuit(
|
|
305
305
|
cirq.X(q0),
|
|
@@ -313,7 +313,7 @@ def test_key_set(sim):
|
|
|
313
313
|
|
|
314
314
|
|
|
315
315
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
316
|
-
def test_repeated_measurement_unset(sim):
|
|
316
|
+
def test_repeated_measurement_unset(sim) -> None:
|
|
317
317
|
q0, q1 = cirq.LineQubit.range(2)
|
|
318
318
|
circuit = cirq.Circuit(
|
|
319
319
|
cirq.measure(q0, key='a'),
|
|
@@ -332,7 +332,7 @@ def test_repeated_measurement_unset(sim):
|
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
335
|
-
def test_repeated_measurement_set(sim):
|
|
335
|
+
def test_repeated_measurement_set(sim) -> None:
|
|
336
336
|
q0, q1 = cirq.LineQubit.range(2)
|
|
337
337
|
circuit = cirq.Circuit(
|
|
338
338
|
cirq.X(q0),
|
|
@@ -352,7 +352,7 @@ def test_repeated_measurement_set(sim):
|
|
|
352
352
|
|
|
353
353
|
|
|
354
354
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
355
|
-
def test_subcircuit_key_unset(sim):
|
|
355
|
+
def test_subcircuit_key_unset(sim) -> None:
|
|
356
356
|
q0, q1 = cirq.LineQubit.range(2)
|
|
357
357
|
inner = cirq.Circuit(
|
|
358
358
|
cirq.measure(q0, key='c'),
|
|
@@ -372,7 +372,7 @@ def test_subcircuit_key_unset(sim):
|
|
|
372
372
|
|
|
373
373
|
|
|
374
374
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
|
375
|
-
def test_subcircuit_key_set(sim):
|
|
375
|
+
def test_subcircuit_key_set(sim) -> None:
|
|
376
376
|
q0, q1 = cirq.LineQubit.range(2)
|
|
377
377
|
inner = cirq.Circuit(
|
|
378
378
|
cirq.X(q0),
|
|
@@ -396,7 +396,7 @@ def test_subcircuit_key_set(sim):
|
|
|
396
396
|
assert result.measurements['3:b'] == 0
|
|
397
397
|
|
|
398
398
|
|
|
399
|
-
def test_key_unset_in_subcircuit_outer_scope():
|
|
399
|
+
def test_key_unset_in_subcircuit_outer_scope() -> None:
|
|
400
400
|
q0, q1 = cirq.LineQubit.range(2)
|
|
401
401
|
circuit = cirq.Circuit(
|
|
402
402
|
cirq.measure(q0, key='a'),
|
|
@@ -408,7 +408,7 @@ def test_key_unset_in_subcircuit_outer_scope():
|
|
|
408
408
|
assert result.measurements['b'] == 0
|
|
409
409
|
|
|
410
410
|
|
|
411
|
-
def test_key_set_in_subcircuit_outer_scope():
|
|
411
|
+
def test_key_set_in_subcircuit_outer_scope() -> None:
|
|
412
412
|
q0, q1 = cirq.LineQubit.range(2)
|
|
413
413
|
circuit = cirq.Circuit(
|
|
414
414
|
cirq.X(q0),
|
|
@@ -421,21 +421,21 @@ def test_key_set_in_subcircuit_outer_scope():
|
|
|
421
421
|
assert result.measurements['b'] == 1
|
|
422
422
|
|
|
423
423
|
|
|
424
|
-
def test_condition_types():
|
|
424
|
+
def test_condition_types() -> None:
|
|
425
425
|
q0 = cirq.LineQubit(0)
|
|
426
426
|
sympy_cond = sympy_parser.parse_expr('a >= 2')
|
|
427
427
|
op = cirq.X(q0).with_classical_controls(cirq.MeasurementKey('a'), 'b', 'a > b', sympy_cond)
|
|
428
428
|
assert set(map(str, op.classical_controls)) == {'a', 'b', 'a > b', 'a >= 2'}
|
|
429
429
|
|
|
430
430
|
|
|
431
|
-
def test_condition_flattening():
|
|
431
|
+
def test_condition_flattening() -> None:
|
|
432
432
|
q0 = cirq.LineQubit(0)
|
|
433
433
|
op = cirq.X(q0).with_classical_controls('a').with_classical_controls('b')
|
|
434
434
|
assert set(map(str, op.classical_controls)) == {'a', 'b'}
|
|
435
435
|
assert isinstance(op._sub_operation, cirq.GateOperation)
|
|
436
436
|
|
|
437
437
|
|
|
438
|
-
def test_condition_stacking():
|
|
438
|
+
def test_condition_stacking() -> None:
|
|
439
439
|
q0 = cirq.LineQubit(0)
|
|
440
440
|
op = cirq.X(q0).with_classical_controls('a').with_tags('t').with_classical_controls('b')
|
|
441
441
|
assert set(map(str, cirq.control_keys(op))) == {'a', 'b'}
|
|
@@ -443,7 +443,7 @@ def test_condition_stacking():
|
|
|
443
443
|
assert not op.tags
|
|
444
444
|
|
|
445
445
|
|
|
446
|
-
def test_condition_removal():
|
|
446
|
+
def test_condition_removal() -> None:
|
|
447
447
|
q0 = cirq.LineQubit(0)
|
|
448
448
|
op = (
|
|
449
449
|
cirq.X(q0)
|
|
@@ -458,13 +458,13 @@ def test_condition_removal():
|
|
|
458
458
|
assert not op.tags
|
|
459
459
|
|
|
460
460
|
|
|
461
|
-
def test_qubit_mapping():
|
|
461
|
+
def test_qubit_mapping() -> None:
|
|
462
462
|
q0, q1 = cirq.LineQubit.range(2)
|
|
463
463
|
op = cirq.X(q0).with_classical_controls('a')
|
|
464
464
|
assert op.with_qubits(q1).qubits == (q1,)
|
|
465
465
|
|
|
466
466
|
|
|
467
|
-
def test_parameterizable():
|
|
467
|
+
def test_parameterizable() -> None:
|
|
468
468
|
s = sympy.Symbol('s')
|
|
469
469
|
q0 = cirq.LineQubit(0)
|
|
470
470
|
op = cirq.X(q0).with_classical_controls('a')
|
|
@@ -474,7 +474,7 @@ def test_parameterizable():
|
|
|
474
474
|
assert cirq.resolve_parameters(opa, cirq.ParamResolver({'s': 1})) == op
|
|
475
475
|
|
|
476
476
|
|
|
477
|
-
def test_decompose():
|
|
477
|
+
def test_decompose() -> None:
|
|
478
478
|
q0 = cirq.LineQubit(0)
|
|
479
479
|
op = cirq.H(q0).with_classical_controls('a')
|
|
480
480
|
assert cirq.decompose(op) == [
|
|
@@ -483,13 +483,13 @@ def test_decompose():
|
|
|
483
483
|
]
|
|
484
484
|
|
|
485
485
|
|
|
486
|
-
def test_str():
|
|
486
|
+
def test_str() -> None:
|
|
487
487
|
q0 = cirq.LineQubit(0)
|
|
488
488
|
op = cirq.X(q0).with_classical_controls('a')
|
|
489
489
|
assert str(op) == 'X(q(0)).with_classical_controls(a)'
|
|
490
490
|
|
|
491
491
|
|
|
492
|
-
def test_scope_local():
|
|
492
|
+
def test_scope_local() -> None:
|
|
493
493
|
q = cirq.LineQubit(0)
|
|
494
494
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('a'))
|
|
495
495
|
middle = cirq.Circuit(
|
|
@@ -534,7 +534,7 @@ def test_scope_local():
|
|
|
534
534
|
assert circuit == cirq.Circuit(cirq.decompose(outer_subcircuit))
|
|
535
535
|
|
|
536
536
|
|
|
537
|
-
def test_scope_flatten_both():
|
|
537
|
+
def test_scope_flatten_both() -> None:
|
|
538
538
|
q = cirq.LineQubit(0)
|
|
539
539
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('a'))
|
|
540
540
|
middle = cirq.Circuit(
|
|
@@ -570,7 +570,7 @@ a: ═══@═══^═══@═══^═══@═══^═══@══
|
|
|
570
570
|
)
|
|
571
571
|
|
|
572
572
|
|
|
573
|
-
def test_scope_flatten_inner():
|
|
573
|
+
def test_scope_flatten_inner() -> None:
|
|
574
574
|
q = cirq.LineQubit(0)
|
|
575
575
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('a'))
|
|
576
576
|
middle = cirq.Circuit(cirq.CircuitOperation(inner.freeze(), repetitions=2))
|
|
@@ -606,7 +606,7 @@ def test_scope_flatten_inner():
|
|
|
606
606
|
)
|
|
607
607
|
|
|
608
608
|
|
|
609
|
-
def test_scope_flatten_outer():
|
|
609
|
+
def test_scope_flatten_outer() -> None:
|
|
610
610
|
q = cirq.LineQubit(0)
|
|
611
611
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('a'))
|
|
612
612
|
middle = cirq.Circuit(
|
|
@@ -642,7 +642,7 @@ def test_scope_flatten_outer():
|
|
|
642
642
|
)
|
|
643
643
|
|
|
644
644
|
|
|
645
|
-
def test_scope_extern():
|
|
645
|
+
def test_scope_extern() -> None:
|
|
646
646
|
q = cirq.LineQubit(0)
|
|
647
647
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('b'))
|
|
648
648
|
middle = cirq.Circuit(
|
|
@@ -686,7 +686,7 @@ def test_scope_extern():
|
|
|
686
686
|
assert circuit == cirq.Circuit(cirq.decompose(outer_subcircuit))
|
|
687
687
|
|
|
688
688
|
|
|
689
|
-
def test_scope_extern_wrapping_with_non_repeating_subcircuits():
|
|
689
|
+
def test_scope_extern_wrapping_with_non_repeating_subcircuits() -> None:
|
|
690
690
|
def wrap(*ops):
|
|
691
691
|
return cirq.CircuitOperation(cirq.FrozenCircuit(*ops))
|
|
692
692
|
|
|
@@ -723,7 +723,7 @@ def test_scope_extern_wrapping_with_non_repeating_subcircuits():
|
|
|
723
723
|
assert circuit == cirq.Circuit(cirq.decompose(outer_subcircuit))
|
|
724
724
|
|
|
725
725
|
|
|
726
|
-
def test_scope_root():
|
|
726
|
+
def test_scope_root() -> None:
|
|
727
727
|
q = cirq.LineQubit(0)
|
|
728
728
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('b'))
|
|
729
729
|
middle = cirq.Circuit(
|
|
@@ -763,7 +763,7 @@ b: ═════════════════════^════
|
|
|
763
763
|
assert circuit == cirq.Circuit(cirq.decompose(outer_subcircuit))
|
|
764
764
|
|
|
765
765
|
|
|
766
|
-
def test_scope_extern_mismatch():
|
|
766
|
+
def test_scope_extern_mismatch() -> None:
|
|
767
767
|
q = cirq.LineQubit(0)
|
|
768
768
|
inner = cirq.Circuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('b'))
|
|
769
769
|
middle = cirq.Circuit(
|
|
@@ -807,7 +807,7 @@ b: ═════════════════════════
|
|
|
807
807
|
assert circuit == cirq.Circuit(cirq.decompose(outer_subcircuit))
|
|
808
808
|
|
|
809
809
|
|
|
810
|
-
def test_repr():
|
|
810
|
+
def test_repr() -> None:
|
|
811
811
|
q0 = cirq.LineQubit(0)
|
|
812
812
|
op = cirq.X(q0).with_classical_controls('a')
|
|
813
813
|
assert repr(op) == (
|
|
@@ -817,13 +817,13 @@ def test_repr():
|
|
|
817
817
|
)
|
|
818
818
|
|
|
819
819
|
|
|
820
|
-
def test_no_measurement_gates():
|
|
820
|
+
def test_no_measurement_gates() -> None:
|
|
821
821
|
q0 = cirq.LineQubit(0)
|
|
822
822
|
with pytest.raises(ValueError, match='with measurements'):
|
|
823
823
|
_ = cirq.measure(q0).with_classical_controls('a')
|
|
824
824
|
|
|
825
825
|
|
|
826
|
-
def test_unmeasured_condition():
|
|
826
|
+
def test_unmeasured_condition() -> None:
|
|
827
827
|
q0 = cirq.LineQubit(0)
|
|
828
828
|
bad_circuit = cirq.Circuit(cirq.X(q0).with_classical_controls('a'))
|
|
829
829
|
with pytest.raises(
|
|
@@ -832,7 +832,7 @@ def test_unmeasured_condition():
|
|
|
832
832
|
_ = cirq.Simulator().simulate(bad_circuit)
|
|
833
833
|
|
|
834
834
|
|
|
835
|
-
def test_layered_circuit_operations_with_controls_in_between():
|
|
835
|
+
def test_layered_circuit_operations_with_controls_in_between() -> None:
|
|
836
836
|
q = cirq.LineQubit(0)
|
|
837
837
|
outer_subcircuit = cirq.CircuitOperation(
|
|
838
838
|
cirq.Circuit(
|
|
@@ -873,7 +873,7 @@ m: ═══^═══^═══
|
|
|
873
873
|
)
|
|
874
874
|
|
|
875
875
|
|
|
876
|
-
def test_sympy():
|
|
876
|
+
def test_sympy() -> None:
|
|
877
877
|
q0, q1, q2, q3, q_result = cirq.LineQubit.range(5)
|
|
878
878
|
for i in range(4):
|
|
879
879
|
for j in range(4):
|
|
@@ -898,7 +898,7 @@ def test_sympy():
|
|
|
898
898
|
assert result.measurements['m_result'][0][0] == (j > i)
|
|
899
899
|
|
|
900
900
|
|
|
901
|
-
def test_sympy_qudits():
|
|
901
|
+
def test_sympy_qudits() -> None:
|
|
902
902
|
q0 = cirq.LineQid(0, 3)
|
|
903
903
|
q1 = cirq.LineQid(1, 5)
|
|
904
904
|
q_result = cirq.LineQubit(2)
|
|
@@ -932,14 +932,14 @@ def test_sympy_qudits():
|
|
|
932
932
|
assert result.measurements['m_result'][0][0] == (i % 4 <= 1)
|
|
933
933
|
|
|
934
934
|
|
|
935
|
-
def test_sympy_path_prefix():
|
|
935
|
+
def test_sympy_path_prefix() -> None:
|
|
936
936
|
q = cirq.LineQubit(0)
|
|
937
937
|
op = cirq.X(q).with_classical_controls(sympy.Symbol('b'))
|
|
938
938
|
prefixed = cirq.with_key_path_prefix(op, ('0',))
|
|
939
939
|
assert cirq.control_keys(prefixed) == {'0:b'}
|
|
940
940
|
|
|
941
941
|
|
|
942
|
-
def test_sympy_scope():
|
|
942
|
+
def test_sympy_scope() -> None:
|
|
943
943
|
q = cirq.LineQubit(0)
|
|
944
944
|
a, b, c, d = sympy.symbols('a b c d')
|
|
945
945
|
inner = cirq.Circuit(
|
|
@@ -1003,7 +1003,7 @@ d: ══════════════════════^═══
|
|
|
1003
1003
|
# pylint: enable=line-too-long
|
|
1004
1004
|
|
|
1005
1005
|
|
|
1006
|
-
def test_sympy_scope_simulation():
|
|
1006
|
+
def test_sympy_scope_simulation() -> None:
|
|
1007
1007
|
q0, q1, q2, q3, q_ignored, q_result = cirq.LineQubit.range(6)
|
|
1008
1008
|
condition = sympy_parser.parse_expr('a & b | c & d')
|
|
1009
1009
|
# We set up condition (a & b | c & d) plus an ignored measurement key, and run through the
|
|
@@ -1037,7 +1037,7 @@ def test_sympy_scope_simulation():
|
|
|
1037
1037
|
)
|
|
1038
1038
|
|
|
1039
1039
|
|
|
1040
|
-
def test_commutes():
|
|
1040
|
+
def test_commutes() -> None:
|
|
1041
1041
|
q0, q1 = cirq.LineQubit.range(2)
|
|
1042
1042
|
assert cirq.commutes(cirq.measure(q0, key='a'), cirq.X(q1).with_classical_controls('b'))
|
|
1043
1043
|
assert cirq.commutes(cirq.X(q1).with_classical_controls('b'), cirq.measure(q0, key='a'))
|
|
@@ -1054,7 +1054,7 @@ def test_commutes():
|
|
|
1054
1054
|
)
|
|
1055
1055
|
|
|
1056
1056
|
|
|
1057
|
-
def test_moment_diagram():
|
|
1057
|
+
def test_moment_diagram() -> None:
|
|
1058
1058
|
a, _, c, d = cirq.GridQubit.rect(2, 2)
|
|
1059
1059
|
m = cirq.Moment(cirq.CZ(a, d), cirq.X(c).with_classical_controls('m'))
|
|
1060
1060
|
assert (
|
|
@@ -1070,7 +1070,7 @@ def test_moment_diagram():
|
|
|
1070
1070
|
)
|
|
1071
1071
|
|
|
1072
1072
|
|
|
1073
|
-
def test_diagram_exponents():
|
|
1073
|
+
def test_diagram_exponents() -> None:
|
|
1074
1074
|
q0, q1 = cirq.LineQubit.range(2)
|
|
1075
1075
|
circuit = cirq.Circuit(
|
|
1076
1076
|
cirq.measure(q0, key='m'), (cirq.X(q1) ** 0.5).with_classical_controls('m')
|
|
@@ -1087,7 +1087,7 @@ m: ═══@═══^═══════
|
|
|
1087
1087
|
)
|
|
1088
1088
|
|
|
1089
1089
|
|
|
1090
|
-
def test_diagram_exponents_cx():
|
|
1090
|
+
def test_diagram_exponents_cx() -> None:
|
|
1091
1091
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
1092
1092
|
circuit = cirq.Circuit(
|
|
1093
1093
|
cirq.measure(q0, key='m'), (cirq.CX(q2, q1) ** 0.5).with_classical_controls('m')
|
|
@@ -1106,7 +1106,7 @@ m: ═══@═══^═══════
|
|
|
1106
1106
|
)
|
|
1107
1107
|
|
|
1108
1108
|
|
|
1109
|
-
def test_diagram_exponents_multiple_keys():
|
|
1109
|
+
def test_diagram_exponents_multiple_keys() -> None:
|
|
1110
1110
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
1111
1111
|
circuit = cirq.Circuit(
|
|
1112
1112
|
cirq.measure(q0, key='m0'),
|
|
@@ -1131,7 +1131,7 @@ m1: ═════@════^═══════
|
|
|
1131
1131
|
)
|
|
1132
1132
|
|
|
1133
1133
|
|
|
1134
|
-
def test_sympy_indexed_condition_circuit():
|
|
1134
|
+
def test_sympy_indexed_condition_circuit() -> None:
|
|
1135
1135
|
a = sympy.IndexedBase('a')
|
|
1136
1136
|
# XOR the 2nd and 3rd bits of the measurement (big-endian)
|
|
1137
1137
|
cond = cirq.SympyCondition(sympy.Xor(a[1], a[2]))
|