cirq-core 1.6.0.dev20250509215532__py3-none-any.whl → 1.6.0.dev20250514001158__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 +2 -2
- cirq/circuits/_block_diagram_drawer_test.py +6 -6
- cirq/circuits/_box_drawing_character_data_test.py +1 -1
- cirq/circuits/insert_strategy_test.py +2 -2
- cirq/circuits/optimization_pass_test.py +5 -5
- cirq/contrib/acquaintance/inspection_utils_test.py +2 -2
- cirq/contrib/acquaintance/mutation_utils_test.py +2 -2
- cirq/contrib/acquaintance/optimizers_test.py +1 -1
- cirq/contrib/acquaintance/shift_test.py +6 -6
- cirq/contrib/acquaintance/strategies/cubic_test.py +2 -2
- cirq/contrib/acquaintance/topological_sort_test.py +1 -1
- cirq/contrib/hacks/disable_validation_test.py +1 -1
- cirq/contrib/json_test.py +3 -3
- cirq/contrib/noise_models/noise_models_test.py +8 -8
- cirq/contrib/paulistring/clifford_optimize_test.py +5 -5
- cirq/contrib/paulistring/clifford_target_gateset_test.py +11 -11
- cirq/contrib/paulistring/optimize_test.py +3 -3
- cirq/contrib/paulistring/pauli_string_dag_test.py +1 -1
- cirq/contrib/paulistring/pauli_string_optimize_test.py +3 -3
- cirq/contrib/paulistring/recombine_test.py +1 -1
- cirq/contrib/paulistring/separate_test.py +1 -1
- cirq/contrib/qasm_import/_parser_test.py +67 -67
- cirq/contrib/qcircuit/qcircuit_pdf_test.py +1 -1
- cirq/contrib/qcircuit/qcircuit_test.py +6 -6
- cirq/contrib/routing/greedy_test.py +2 -2
- cirq/contrib/routing/initialization_test.py +3 -3
- cirq/contrib/svg/svg_test.py +5 -5
- cirq/devices/device_test.py +4 -4
- cirq/devices/insertion_noise_model_test.py +5 -5
- cirq/devices/named_topologies_test.py +10 -10
- cirq/devices/noise_properties_test.py +1 -1
- cirq/experiments/n_qubit_tomography_test.py +5 -5
- cirq/experiments/t1_decay_experiment_test.py +11 -11
- cirq/interop/quirk/cells/arithmetic_cells_test.py +14 -14
- cirq/interop/quirk/cells/control_cells_test.py +5 -5
- cirq/interop/quirk/cells/frequency_space_cells_test.py +1 -1
- cirq/interop/quirk/cells/ignored_cells_test.py +1 -1
- cirq/interop/quirk/cells/input_cells_test.py +5 -5
- cirq/interop/quirk/cells/input_rotation_cells_test.py +7 -7
- cirq/interop/quirk/cells/measurement_cells_test.py +1 -1
- cirq/interop/quirk/cells/qubit_permutation_cells_test.py +7 -7
- cirq/interop/quirk/cells/scalar_cells_test.py +1 -1
- cirq/interop/quirk/cells/single_qubit_rotation_cells_test.py +3 -3
- cirq/interop/quirk/cells/swap_cell_test.py +4 -4
- cirq/interop/quirk/cells/testing_test.py +6 -6
- cirq/interop/quirk/cells/unsupported_cells_test.py +2 -2
- cirq/linalg/combinators_test.py +7 -7
- cirq/linalg/diagonalize_test.py +10 -10
- cirq/linalg/operator_spaces_test.py +11 -11
- cirq/linalg/tolerance_test.py +4 -4
- cirq/neutral_atoms/convert_to_neutral_atom_gates_test.py +1 -1
- cirq/ops/arithmetic_operation_test.py +2 -2
- cirq/ops/common_channels_test.py +80 -80
- cirq/ops/fsim_gate_test.py +26 -26
- cirq/ops/gate_features_test.py +3 -3
- cirq/ops/greedy_qubit_manager_test.py +3 -3
- cirq/ops/mixed_unitary_channel_test.py +11 -11
- cirq/ops/parallel_gate_test.py +16 -16
- cirq/ops/parity_gates_test.py +34 -32
- cirq/ops/pauli_gates_test.py +20 -20
- cirq/ops/pauli_interaction_gate_test.py +8 -8
- cirq/ops/pauli_sum_exponential_test.py +10 -10
- cirq/ops/permutation_gate_test.py +8 -8
- cirq/ops/phased_iswap_gate_test.py +15 -15
- cirq/ops/qubit_manager_test.py +4 -4
- cirq/ops/random_gate_channel_test.py +11 -11
- cirq/ops/state_preparation_channel_test.py +8 -8
- cirq/ops/swap_gates_test.py +17 -17
- cirq/ops/tags_test.py +2 -2
- cirq/ops/three_qubit_gates_test.py +17 -17
- cirq/ops/two_qubit_diagonal_gate_test.py +8 -8
- cirq/ops/uniform_superposition_gate_test.py +3 -3
- cirq/protocols/act_on_protocol_test.py +6 -6
- cirq/protocols/circuit_diagram_info_protocol_test.py +13 -13
- cirq/protocols/control_key_protocol_test.py +1 -1
- cirq/protocols/decompose_protocol_test.py +12 -12
- cirq/protocols/equal_up_to_global_phase_protocol_test.py +6 -6
- cirq/protocols/has_stabilizer_effect_protocol_test.py +5 -5
- cirq/protocols/has_unitary_protocol_test.py +8 -8
- cirq/protocols/hash_from_pickle_test.py +1 -1
- cirq/protocols/inverse_protocol_test.py +2 -2
- cirq/protocols/kraus_protocol_test.py +9 -9
- cirq/protocols/measurement_key_protocol_test.py +10 -10
- cirq/protocols/pauli_expansion_protocol_test.py +2 -2
- cirq/protocols/phase_protocol_test.py +1 -1
- cirq/protocols/qasm_test.py +3 -3
- cirq/protocols/qid_shape_protocol_test.py +1 -1
- cirq/protocols/resolve_parameters_test.py +5 -5
- cirq/protocols/trace_distance_bound_test.py +1 -1
- cirq/qis/channels_test.py +16 -16
- cirq/qis/measures_test.py +16 -14
- cirq/qis/noise_utils_test.py +7 -7
- cirq/sim/clifford/clifford_tableau_simulation_state_test.py +3 -3
- cirq/sim/clifford/stabilizer_ch_form_simulation_state_test.py +6 -6
- cirq/sim/clifford/stabilizer_sampler_test.py +2 -2
- cirq/sim/clifford/stabilizer_simulation_state_test.py +4 -4
- cirq/sim/clifford/stabilizer_state_ch_form_test.py +2 -2
- cirq/sim/density_matrix_simulation_state_test.py +8 -8
- cirq/sim/density_matrix_utils_test.py +36 -36
- cirq/sim/simulation_product_state_test.py +22 -22
- cirq/sim/simulation_state_test.py +12 -12
- cirq/sim/simulation_utils_test.py +1 -1
- cirq/sim/state_vector_simulation_state_test.py +12 -12
- cirq/study/flatten_expressions_test.py +11 -11
- cirq/study/resolver_test.py +20 -20
- cirq/testing/consistent_act_on_test.py +1 -1
- cirq/testing/consistent_channels_test.py +8 -8
- cirq/testing/consistent_controlled_gate_op_test.py +2 -2
- cirq/testing/consistent_decomposition_test.py +2 -2
- cirq/testing/consistent_pauli_expansion_test.py +1 -1
- cirq/testing/consistent_phase_by_test.py +1 -1
- cirq/testing/consistent_qasm_test.py +1 -1
- cirq/testing/consistent_specified_has_unitary_test.py +4 -4
- cirq/testing/consistent_unitary_test.py +2 -2
- cirq/testing/deprecation_test.py +2 -2
- cirq/testing/devices_test.py +4 -4
- cirq/testing/equivalent_basis_map_test.py +2 -2
- cirq/testing/equivalent_repr_eval_test.py +3 -3
- cirq/testing/gate_features_test.py +5 -5
- cirq/testing/json_test.py +3 -3
- cirq/testing/lin_alg_utils_test.py +12 -12
- cirq/testing/logs_test.py +7 -7
- cirq/testing/no_identifier_qubit_test.py +3 -3
- cirq/testing/op_tree_test.py +1 -1
- cirq/testing/order_tester_test.py +6 -6
- cirq/testing/pytest_utils_test.py +2 -2
- cirq/testing/random_circuit_test.py +5 -5
- cirq/testing/repr_pretty_tester_test.py +3 -3
- cirq/testing/routing_devices_test.py +6 -6
- cirq/testing/sample_circuits_test.py +1 -1
- cirq/testing/sample_gates_test.py +2 -2
- cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py +3 -3
- cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +7 -7
- cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +6 -6
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim_test.py +5 -5
- cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py +1 -1
- cirq/transformers/drop_empty_moments_test.py +2 -2
- cirq/transformers/eject_phased_paulis_test.py +9 -9
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation_test.py +7 -7
- cirq/transformers/insertion_sort_test.py +1 -1
- cirq/transformers/merge_k_qubit_gates_test.py +9 -9
- cirq/transformers/qubit_management_transformers_test.py +3 -3
- cirq/transformers/randomized_measurements_test.py +8 -4
- cirq/transformers/routing/line_initial_mapper_test.py +5 -5
- cirq/transformers/routing/route_circuit_cqc_test.py +13 -13
- cirq/transformers/routing/visualize_routed_circuit_test.py +2 -2
- cirq/transformers/synchronize_terminal_measurements_test.py +10 -10
- cirq/transformers/target_gatesets/compilation_target_gateset_test.py +8 -8
- cirq/transformers/target_gatesets/cz_gateset_test.py +17 -17
- cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +23 -23
- cirq/value/angle_test.py +3 -3
- cirq/value/classical_data_test.py +8 -8
- cirq/value/periodic_value_test.py +9 -7
- cirq/value/probability_test.py +2 -2
- cirq/value/value_equality_attr_test.py +11 -11
- cirq/vis/histogram_test.py +2 -2
- cirq/vis/state_histogram_test.py +5 -5
- cirq/vis/vis_utils_test.py +1 -1
- cirq/work/observable_grouping_test.py +8 -8
- cirq/work/observable_readout_calibration_test.py +1 -1
- cirq/work/zeros_sampler_test.py +4 -4
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/METADATA +2 -1
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/RECORD +167 -167
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/top_level.txt +0 -0
|
@@ -130,7 +130,7 @@ def assert_ms_depth_below(operations, threshold):
|
|
|
130
130
|
(2, _random_double_MS_effect()) for _ in range(10)
|
|
131
131
|
])
|
|
132
132
|
# yapf: enable
|
|
133
|
-
def test_two_to_ops(max_ms_depth: int, effect: np.ndarray):
|
|
133
|
+
def test_two_to_ops(max_ms_depth: int, effect: np.ndarray) -> None:
|
|
134
134
|
q0 = cirq.NamedQubit('q0')
|
|
135
135
|
q1 = cirq.NamedQubit('q1')
|
|
136
136
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import cirq
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def test_drop():
|
|
18
|
+
def test_drop() -> None:
|
|
19
19
|
q1 = cirq.NamedQubit('q1')
|
|
20
20
|
q2 = cirq.NamedQubit('q2')
|
|
21
21
|
cirq.testing.assert_same_circuits(
|
|
@@ -28,7 +28,7 @@ def test_drop():
|
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def test_drop_empty_moments():
|
|
31
|
+
def test_drop_empty_moments() -> None:
|
|
32
32
|
q1, q2 = cirq.LineQubit.range(2)
|
|
33
33
|
c_nested = cirq.FrozenCircuit(
|
|
34
34
|
cirq.Moment(), cirq.Moment(), cirq.Moment([cirq.CNOT(q1, q2)]), cirq.Moment()
|
|
@@ -98,7 +98,7 @@ def quick_circuit(*moments: Iterable[cirq.OP_TREE]) -> cirq.Circuit:
|
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_absorbs_z():
|
|
101
|
+
def test_absorbs_z() -> None:
|
|
102
102
|
q = cirq.NamedQubit('q')
|
|
103
103
|
x = sympy.Symbol('x')
|
|
104
104
|
|
|
@@ -165,7 +165,7 @@ def test_absorbs_z():
|
|
|
165
165
|
)
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
def test_crosses_czs():
|
|
168
|
+
def test_crosses_czs() -> None:
|
|
169
169
|
a = cirq.NamedQubit('a')
|
|
170
170
|
b = cirq.NamedQubit('b')
|
|
171
171
|
x = sympy.Symbol('x')
|
|
@@ -232,7 +232,7 @@ def test_crosses_czs():
|
|
|
232
232
|
)
|
|
233
233
|
|
|
234
234
|
|
|
235
|
-
def test_toggles_measurements():
|
|
235
|
+
def test_toggles_measurements() -> None:
|
|
236
236
|
a = cirq.NamedQubit('a')
|
|
237
237
|
b = cirq.NamedQubit('b')
|
|
238
238
|
x = sympy.Symbol('x')
|
|
@@ -289,7 +289,7 @@ def test_toggles_measurements():
|
|
|
289
289
|
)
|
|
290
290
|
|
|
291
291
|
|
|
292
|
-
def test_eject_phased_xz():
|
|
292
|
+
def test_eject_phased_xz() -> None:
|
|
293
293
|
a = cirq.NamedQubit('a')
|
|
294
294
|
b = cirq.NamedQubit('b')
|
|
295
295
|
c = cirq.Circuit(
|
|
@@ -305,7 +305,7 @@ def test_eject_phased_xz():
|
|
|
305
305
|
cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent(c, c_expected, 1e-8)
|
|
306
306
|
|
|
307
307
|
|
|
308
|
-
def test_cancels_other_full_w():
|
|
308
|
+
def test_cancels_other_full_w() -> None:
|
|
309
309
|
q = cirq.NamedQubit('q')
|
|
310
310
|
x = sympy.Symbol('x')
|
|
311
311
|
y = sympy.Symbol('y')
|
|
@@ -365,7 +365,7 @@ def test_cancels_other_full_w():
|
|
|
365
365
|
)
|
|
366
366
|
|
|
367
367
|
|
|
368
|
-
def test_phases_partial_ws():
|
|
368
|
+
def test_phases_partial_ws() -> None:
|
|
369
369
|
q = cirq.NamedQubit('q')
|
|
370
370
|
x = sympy.Symbol('x')
|
|
371
371
|
y = sympy.Symbol('y')
|
|
@@ -420,7 +420,7 @@ def test_phases_partial_ws():
|
|
|
420
420
|
|
|
421
421
|
|
|
422
422
|
@pytest.mark.parametrize('sym', [sympy.Symbol('x'), sympy.Symbol('x') + 1])
|
|
423
|
-
def test_blocked_by_unknown_and_symbols(sym):
|
|
423
|
+
def test_blocked_by_unknown_and_symbols(sym) -> None:
|
|
424
424
|
a = cirq.NamedQubit('a')
|
|
425
425
|
b = cirq.NamedQubit('b')
|
|
426
426
|
|
|
@@ -442,7 +442,7 @@ def test_blocked_by_unknown_and_symbols(sym):
|
|
|
442
442
|
)
|
|
443
443
|
|
|
444
444
|
|
|
445
|
-
def test_blocked_by_nocompile_tag():
|
|
445
|
+
def test_blocked_by_nocompile_tag() -> None:
|
|
446
446
|
a = cirq.NamedQubit('a')
|
|
447
447
|
b = cirq.NamedQubit('b')
|
|
448
448
|
|
|
@@ -453,7 +453,7 @@ def test_blocked_by_nocompile_tag():
|
|
|
453
453
|
)
|
|
454
454
|
|
|
455
455
|
|
|
456
|
-
def test_zero_x_rotation():
|
|
456
|
+
def test_zero_x_rotation() -> None:
|
|
457
457
|
a = cirq.NamedQubit('a')
|
|
458
458
|
|
|
459
459
|
assert_optimizes(before=quick_circuit([cirq.rx(0)(a)]), expected=quick_circuit([cirq.rx(0)(a)]))
|
|
@@ -41,7 +41,7 @@ _random_2Q_unitaries = np.array([random_special_unitary(4, random_state=_rng) fo
|
|
|
41
41
|
|
|
42
42
|
@pytest.mark.parametrize('tabulation', [sycamore_tabulation, sqrt_iswap_tabulation])
|
|
43
43
|
@pytest.mark.parametrize('target', _random_2Q_unitaries)
|
|
44
|
-
def test_gate_compilation_matches_expected_max_infidelity(tabulation, target):
|
|
44
|
+
def test_gate_compilation_matches_expected_max_infidelity(tabulation, target) -> None:
|
|
45
45
|
result = tabulation.compile_two_qubit_gate(target)
|
|
46
46
|
|
|
47
47
|
assert result.success
|
|
@@ -50,7 +50,7 @@ def test_gate_compilation_matches_expected_max_infidelity(tabulation, target):
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@pytest.mark.parametrize('tabulation', [sycamore_tabulation, sqrt_iswap_tabulation])
|
|
53
|
-
def test_gate_compilation_on_base_gate_standard(tabulation):
|
|
53
|
+
def test_gate_compilation_on_base_gate_standard(tabulation) -> None:
|
|
54
54
|
base_gate = tabulation.base_gate
|
|
55
55
|
|
|
56
56
|
result = tabulation.compile_two_qubit_gate(base_gate)
|
|
@@ -61,7 +61,7 @@ def test_gate_compilation_on_base_gate_standard(tabulation):
|
|
|
61
61
|
assert fidelity > 0.99999
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def test_gate_compilation_on_base_gate_identity():
|
|
64
|
+
def test_gate_compilation_on_base_gate_identity() -> None:
|
|
65
65
|
tabulation = two_qubit_gate_product_tabulation(np.eye(4), 0.25)
|
|
66
66
|
base_gate = tabulation.base_gate
|
|
67
67
|
|
|
@@ -73,7 +73,7 @@ def test_gate_compilation_on_base_gate_identity():
|
|
|
73
73
|
assert fidelity > 0.99999
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def test_gate_compilation_missing_points_raises_error():
|
|
76
|
+
def test_gate_compilation_missing_points_raises_error() -> None:
|
|
77
77
|
with pytest.raises(ValueError, match='Failed to tabulate a'):
|
|
78
78
|
two_qubit_gate_product_tabulation(
|
|
79
79
|
np.eye(4), 0.4, allow_missed_points=False, random_state=_rng
|
|
@@ -81,7 +81,7 @@ def test_gate_compilation_missing_points_raises_error():
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
@pytest.mark.parametrize('seed', [0, 1])
|
|
84
|
-
def test_sycamore_gate_tabulation(seed):
|
|
84
|
+
def test_sycamore_gate_tabulation(seed) -> None:
|
|
85
85
|
base_gate = cirq.unitary(cirq.FSimGate(np.pi / 2, np.pi / 6))
|
|
86
86
|
tab = two_qubit_gate_product_tabulation(
|
|
87
87
|
base_gate, 0.1, sample_scaling=2, random_state=np.random.RandomState(seed)
|
|
@@ -90,7 +90,7 @@ def test_sycamore_gate_tabulation(seed):
|
|
|
90
90
|
assert result.success
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
def test_sycamore_gate_tabulation_repr():
|
|
93
|
+
def test_sycamore_gate_tabulation_repr() -> None:
|
|
94
94
|
simple_tabulation = TwoQubitGateTabulation(
|
|
95
95
|
np.array([[(1 + 0j), 0j, 0j, 0j]], dtype=np.complex128),
|
|
96
96
|
np.array([[(1 + 0j), 0j, 0j, 0j]], dtype=np.complex128),
|
|
@@ -102,7 +102,7 @@ def test_sycamore_gate_tabulation_repr():
|
|
|
102
102
|
assert_equivalent_repr(simple_tabulation)
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
def test_sycamore_gate_tabulation_eq():
|
|
105
|
+
def test_sycamore_gate_tabulation_eq() -> None:
|
|
106
106
|
assert sycamore_tabulation == sycamore_tabulation
|
|
107
107
|
assert sycamore_tabulation != sqrt_iswap_tabulation
|
|
108
108
|
assert sycamore_tabulation != 1
|
|
@@ -37,7 +37,7 @@ def assert_optimizes(optimized: cirq.AbstractCircuit, expected: cirq.AbstractCir
|
|
|
37
37
|
cirq.testing.assert_same_circuits(optimized, expected)
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def test_merge_1q_unitaries():
|
|
40
|
+
def test_merge_1q_unitaries() -> None:
|
|
41
41
|
q, q2 = cirq.LineQubit.range(2)
|
|
42
42
|
# 1. Combines trivial 1q sequence.
|
|
43
43
|
c = cirq.Circuit(cirq.X(q) ** 0.5, cirq.Z(q) ** 0.5, cirq.X(q) ** -0.5)
|
|
@@ -57,7 +57,7 @@ def test_merge_1q_unitaries():
|
|
|
57
57
|
assert isinstance(c[-1][q].gate, cirq.MatrixGate)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def test_respects_nocompile_tags():
|
|
60
|
+
def test_respects_nocompile_tags() -> None:
|
|
61
61
|
q = cirq.NamedQubit("q")
|
|
62
62
|
c = cirq.Circuit(
|
|
63
63
|
[cirq.Z(q), cirq.H(q), cirq.X(q), cirq.H(q), cirq.X(q).with_tags("nocompile"), cirq.H(q)]
|
|
@@ -70,12 +70,12 @@ def test_respects_nocompile_tags():
|
|
|
70
70
|
assert isinstance(c[-1][q].gate, cirq.MatrixGate)
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
def test_ignores_2qubit_target():
|
|
73
|
+
def test_ignores_2qubit_target() -> None:
|
|
74
74
|
c = cirq.Circuit(cirq.CZ(*cirq.LineQubit.range(2)))
|
|
75
75
|
assert_optimizes(optimized=cirq.merge_k_qubit_unitaries(c, k=1), expected=c)
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def test_ignore_unsupported_gate():
|
|
78
|
+
def test_ignore_unsupported_gate() -> None:
|
|
79
79
|
class UnsupportedExample(cirq.testing.SingleQubitGate):
|
|
80
80
|
pass
|
|
81
81
|
|
|
@@ -83,7 +83,7 @@ def test_ignore_unsupported_gate():
|
|
|
83
83
|
assert_optimizes(optimized=cirq.merge_k_qubit_unitaries(c, k=1), expected=c)
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def test_1q_rewrite():
|
|
86
|
+
def test_1q_rewrite() -> None:
|
|
87
87
|
q0, q1 = cirq.LineQubit.range(2)
|
|
88
88
|
circuit = cirq.Circuit(
|
|
89
89
|
cirq.X(q0), cirq.Y(q0), cirq.X(q1), cirq.CZ(q0, q1), cirq.Y(q1), cirq.measure(q0, q1)
|
|
@@ -98,12 +98,12 @@ def test_1q_rewrite():
|
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_merge_k_qubit_unitaries_raises():
|
|
101
|
+
def test_merge_k_qubit_unitaries_raises() -> None:
|
|
102
102
|
with pytest.raises(ValueError, match="k should be greater than or equal to 1"):
|
|
103
103
|
_ = cirq.merge_k_qubit_unitaries(cirq.Circuit())
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
def test_merge_complex_circuit_preserving_moment_structure():
|
|
106
|
+
def test_merge_complex_circuit_preserving_moment_structure() -> None:
|
|
107
107
|
q = cirq.LineQubit.range(3)
|
|
108
108
|
c_orig = cirq.Circuit(
|
|
109
109
|
cirq.Moment(cirq.H.on_each(*q)),
|
|
@@ -191,7 +191,7 @@ a: ═════════════════════════
|
|
|
191
191
|
)
|
|
192
192
|
|
|
193
193
|
|
|
194
|
-
def test_merge_k_qubit_unitaries_deep():
|
|
194
|
+
def test_merge_k_qubit_unitaries_deep() -> None:
|
|
195
195
|
q = cirq.LineQubit.range(2)
|
|
196
196
|
h_cz_y = [cirq.H(q[0]), cirq.CZ(*q), cirq.Y(q[1])]
|
|
197
197
|
c_orig = cirq.Circuit(
|
|
@@ -253,7 +253,7 @@ def test_merge_k_qubit_unitaries_deep():
|
|
|
253
253
|
cirq.testing.assert_same_circuits(c_new_matrix, c_expected_matrix)
|
|
254
254
|
|
|
255
255
|
|
|
256
|
-
def test_merge_k_qubit_unitaries_deep_recurses_on_large_circuit_op():
|
|
256
|
+
def test_merge_k_qubit_unitaries_deep_recurses_on_large_circuit_op() -> None:
|
|
257
257
|
q = cirq.LineQubit.range(2)
|
|
258
258
|
c_orig = cirq.Circuit(
|
|
259
259
|
cirq.CircuitOperation(cirq.FrozenCircuit(cirq.X(q[0]), cirq.H(q[0]), cirq.CNOT(*q)))
|
|
@@ -66,7 +66,7 @@ def get_decompose_func(gate_type, qm):
|
|
|
66
66
|
return decompose_func
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def test_map_clean_and_borrowable_qubits_greedy_types():
|
|
69
|
+
def test_map_clean_and_borrowable_qubits_greedy_types() -> None:
|
|
70
70
|
qm = cirq.ops.SimpleQubitManager()
|
|
71
71
|
q = cirq.LineQubit.range(2)
|
|
72
72
|
g = GateAllocInDecompose(1)
|
|
@@ -130,7 +130,7 @@ ancilla_1: ───X───X───
|
|
|
130
130
|
)
|
|
131
131
|
|
|
132
132
|
|
|
133
|
-
def test_map_clean_and_borrowable_qubits_borrows():
|
|
133
|
+
def test_map_clean_and_borrowable_qubits_borrows() -> None:
|
|
134
134
|
qm = cirq.ops.SimpleQubitManager()
|
|
135
135
|
op = GateAllocAndBorrowInDecompose(3).on(cirq.NamedQubit("original"))
|
|
136
136
|
extra = cirq.LineQubit.range(3)
|
|
@@ -233,7 +233,7 @@ original: ────@───@───@───@─────@───@
|
|
|
233
233
|
)
|
|
234
234
|
|
|
235
235
|
|
|
236
|
-
def test_map_clean_and_borrowable_qubits_deallocates_only_once():
|
|
236
|
+
def test_map_clean_and_borrowable_qubits_deallocates_only_once() -> None:
|
|
237
237
|
q = [cirq.ops.BorrowableQubit(i) for i in range(2)] + [cirq.q('q')]
|
|
238
238
|
circuit = cirq.Circuit(cirq.X.on_each(*q), cirq.Y(q[1]), cirq.Z(q[1]))
|
|
239
239
|
greedy_mm = cirq.GreedyQubitManager(prefix="a", size=2)
|
|
@@ -18,7 +18,7 @@ import cirq
|
|
|
18
18
|
import cirq.transformers.randomized_measurements as rand_meas
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_randomized_measurements_appends_two_moments_on_returned_circuit():
|
|
21
|
+
def test_randomized_measurements_appends_two_moments_on_returned_circuit() -> None:
|
|
22
22
|
# Create a 4-qubit circuit
|
|
23
23
|
q0, q1, q2, q3 = cirq.LineQubit.range(4)
|
|
24
24
|
circuit_pre = cirq.Circuit(
|
|
@@ -34,7 +34,9 @@ def test_randomized_measurements_appends_two_moments_on_returned_circuit():
|
|
|
34
34
|
assert num_moments_post == num_moments_pre + 2
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_append_randomized_measurements_leaves_qubits_not_in_specified_subsystem_unchanged()
|
|
37
|
+
def test_append_randomized_measurements_leaves_qubits_not_in_specified_subsystem_unchanged() -> (
|
|
38
|
+
None
|
|
39
|
+
):
|
|
38
40
|
# Create a 4-qubit circuit
|
|
39
41
|
q0, q1, q2, q3 = cirq.LineQubit.range(4)
|
|
40
42
|
circuit = cirq.Circuit([cirq.H(q0), cirq.CNOT(q0, q1), cirq.CNOT(q1, q2), cirq.CNOT(q2, q3)])
|
|
@@ -46,7 +48,9 @@ def test_append_randomized_measurements_leaves_qubits_not_in_specified_subsystem
|
|
|
46
48
|
assert circuit.operation_at(q3, 4) is None
|
|
47
49
|
|
|
48
50
|
|
|
49
|
-
def
|
|
51
|
+
def test_append_random_measurements_leaves_qubits_not_in_noncontinuous_subsystem_unchanged() -> (
|
|
52
|
+
None
|
|
53
|
+
):
|
|
50
54
|
# Create a 4-qubit circuit
|
|
51
55
|
q0, q1, q2, q3 = cirq.LineQubit.range(4)
|
|
52
56
|
circuit = cirq.Circuit([cirq.H(q0), cirq.CNOT(q0, q1), cirq.CNOT(q1, q2), cirq.CNOT(q2, q3)])
|
|
@@ -59,7 +63,7 @@ def test_append_randomized_measurements_leaves_qubits_not_in_noncontinuous_subsy
|
|
|
59
63
|
assert circuit.operation_at(q3, 4) is None
|
|
60
64
|
|
|
61
65
|
|
|
62
|
-
def test_exception():
|
|
66
|
+
def test_exception() -> None:
|
|
63
67
|
q0, q1, q2, q3 = cirq.LineQubit.range(4)
|
|
64
68
|
circuit = cirq.Circuit([cirq.H(q0), cirq.CNOT(q0, q1), cirq.CNOT(q1, q2), cirq.CNOT(q2, q3)])
|
|
65
69
|
|
|
@@ -66,7 +66,7 @@ def construct_valid_circuit():
|
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def test_valid_circuit():
|
|
69
|
+
def test_valid_circuit() -> None:
|
|
70
70
|
# Any circuit with a (full connectivity) graph of disjoint lines should be directly
|
|
71
71
|
# executable after mapping a a supporting device topology without the need for inserting
|
|
72
72
|
# any swaps.
|
|
@@ -79,7 +79,7 @@ def test_valid_circuit():
|
|
|
79
79
|
device.validate_circuit(mapped_circuit)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_long_line_on_grid_device():
|
|
82
|
+
def test_long_line_on_grid_device() -> None:
|
|
83
83
|
# tests
|
|
84
84
|
# -if strategy is able to map a single long line onto the device whenever the device topology
|
|
85
85
|
# supports it (i.e. is Hamiltonian)
|
|
@@ -106,7 +106,7 @@ def test_long_line_on_grid_device():
|
|
|
106
106
|
mapper.initial_mapping(step_circuit)
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def test_small_circuit_on_grid_device():
|
|
109
|
+
def test_small_circuit_on_grid_device() -> None:
|
|
110
110
|
circuit = construct_small_circuit()
|
|
111
111
|
device_graph = cirq.testing.construct_grid_device(7, 7).metadata.nx_graph
|
|
112
112
|
mapper = cirq.LineInitialMapper(device_graph)
|
|
@@ -126,7 +126,7 @@ def test_small_circuit_on_grid_device():
|
|
|
126
126
|
cirq.testing.assert_same_circuits(circuit.transform_qubits(mapping), expected_circuit)
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
def test_small_circuit_on_ring_device():
|
|
129
|
+
def test_small_circuit_on_ring_device() -> None:
|
|
130
130
|
circuit = construct_small_circuit()
|
|
131
131
|
device_graph = cirq.testing.construct_ring_device(10, directed=True).metadata.nx_graph
|
|
132
132
|
|
|
@@ -187,7 +187,7 @@ def test_large_random_circuits_grid_device(
|
|
|
187
187
|
assert nx.is_connected(nx.induced_subgraph(glob_device_graph, mapping.values()))
|
|
188
188
|
|
|
189
189
|
|
|
190
|
-
def test_repr():
|
|
190
|
+
def test_repr() -> None:
|
|
191
191
|
device_graph = cirq.testing.construct_grid_device(7, 7).metadata.nx_graph
|
|
192
192
|
mapper = cirq.LineInitialMapper(device_graph)
|
|
193
193
|
cirq.testing.assert_equivalent_repr(mapper, setup_code='import cirq\nimport networkx as nx')
|
|
@@ -17,7 +17,7 @@ import pytest
|
|
|
17
17
|
import cirq
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_directed_device():
|
|
20
|
+
def test_directed_device() -> None:
|
|
21
21
|
device = cirq.testing.construct_ring_device(10, directed=True)
|
|
22
22
|
device_graph = device.metadata.nx_graph
|
|
23
23
|
with pytest.raises(ValueError, match="Device graph must be undirected."):
|
|
@@ -33,7 +33,7 @@ def test_directed_device():
|
|
|
33
33
|
for op_density in [0.3, 0.5, 0.7]
|
|
34
34
|
],
|
|
35
35
|
)
|
|
36
|
-
def test_route_small_circuit_random(n_qubits, n_moments, op_density, seed):
|
|
36
|
+
def test_route_small_circuit_random(n_qubits, n_moments, op_density, seed) -> None:
|
|
37
37
|
c_orig = cirq.testing.random_circuit(
|
|
38
38
|
qubits=n_qubits, n_moments=n_moments, op_density=op_density, random_state=seed
|
|
39
39
|
)
|
|
@@ -47,7 +47,7 @@ def test_route_small_circuit_random(n_qubits, n_moments, op_density, seed):
|
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def test_high_qubit_count():
|
|
50
|
+
def test_high_qubit_count() -> None:
|
|
51
51
|
c_orig = cirq.testing.random_circuit(qubits=40, n_moments=350, op_density=0.4, random_state=0)
|
|
52
52
|
device = cirq.testing.construct_grid_device(7, 7)
|
|
53
53
|
device_graph = device.metadata.nx_graph
|
|
@@ -56,7 +56,7 @@ def test_high_qubit_count():
|
|
|
56
56
|
device.validate_circuit(c_routed)
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def test_multi_qubit_gate_inputs():
|
|
59
|
+
def test_multi_qubit_gate_inputs() -> None:
|
|
60
60
|
device = cirq.testing.construct_grid_device(4, 4)
|
|
61
61
|
device_graph = device.metadata.nx_graph
|
|
62
62
|
router = cirq.RouteCQC(device_graph)
|
|
@@ -97,7 +97,7 @@ def test_multi_qubit_gate_inputs():
|
|
|
97
97
|
device.validate_circuit(c_routed)
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
def test_circuit_with_measurement_gates():
|
|
100
|
+
def test_circuit_with_measurement_gates() -> None:
|
|
101
101
|
device = cirq.testing.construct_ring_device(3)
|
|
102
102
|
device_graph = device.metadata.nx_graph
|
|
103
103
|
q = cirq.LineQubit.range(3)
|
|
@@ -108,7 +108,7 @@ def test_circuit_with_measurement_gates():
|
|
|
108
108
|
cirq.testing.assert_same_circuits(routed_circuit, circuit)
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def test_circuit_with_two_qubit_intermediate_measurement_gate():
|
|
111
|
+
def test_circuit_with_two_qubit_intermediate_measurement_gate() -> None:
|
|
112
112
|
device = cirq.testing.construct_ring_device(2)
|
|
113
113
|
device_graph = device.metadata.nx_graph
|
|
114
114
|
router = cirq.RouteCQC(device_graph)
|
|
@@ -121,7 +121,7 @@ def test_circuit_with_two_qubit_intermediate_measurement_gate():
|
|
|
121
121
|
device.validate_circuit(routed_circuit)
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
def test_circuit_with_multi_qubit_intermediate_measurement_gate_and_with_default_key():
|
|
124
|
+
def test_circuit_with_multi_qubit_intermediate_measurement_gate_and_with_default_key() -> None:
|
|
125
125
|
device = cirq.testing.construct_ring_device(3)
|
|
126
126
|
device_graph = device.metadata.nx_graph
|
|
127
127
|
router = cirq.RouteCQC(device_graph)
|
|
@@ -135,7 +135,7 @@ def test_circuit_with_multi_qubit_intermediate_measurement_gate_and_with_default
|
|
|
135
135
|
cirq.testing.assert_same_circuits(routed_circuit, expected)
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
def test_circuit_with_multi_qubit_intermediate_measurement_gate_with_custom_key():
|
|
138
|
+
def test_circuit_with_multi_qubit_intermediate_measurement_gate_with_custom_key() -> None:
|
|
139
139
|
device = cirq.testing.construct_ring_device(3)
|
|
140
140
|
device_graph = device.metadata.nx_graph
|
|
141
141
|
router = cirq.RouteCQC(device_graph)
|
|
@@ -150,7 +150,7 @@ def test_circuit_with_multi_qubit_intermediate_measurement_gate_with_custom_key(
|
|
|
150
150
|
)
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def test_circuit_with_non_unitary_and_global_phase():
|
|
153
|
+
def test_circuit_with_non_unitary_and_global_phase() -> None:
|
|
154
154
|
device = cirq.testing.construct_ring_device(4)
|
|
155
155
|
device_graph = device.metadata.nx_graph
|
|
156
156
|
q = cirq.LineQubit.range(3)
|
|
@@ -176,7 +176,7 @@ def test_circuit_with_non_unitary_and_global_phase():
|
|
|
176
176
|
cirq.testing.assert_same_circuits(routed_circuit, expected)
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
def test_circuit_with_tagged_ops():
|
|
179
|
+
def test_circuit_with_tagged_ops() -> None:
|
|
180
180
|
device = cirq.testing.construct_ring_device(4)
|
|
181
181
|
device_graph = device.metadata.nx_graph
|
|
182
182
|
q = cirq.LineQubit.range(3)
|
|
@@ -205,7 +205,7 @@ def test_circuit_with_tagged_ops():
|
|
|
205
205
|
cirq.testing.assert_same_circuits(routed_circuit, expected)
|
|
206
206
|
|
|
207
207
|
|
|
208
|
-
def test_already_valid_circuit():
|
|
208
|
+
def test_already_valid_circuit() -> None:
|
|
209
209
|
device = cirq.testing.construct_ring_device(10)
|
|
210
210
|
device_graph = device.metadata.nx_graph
|
|
211
211
|
circuit = cirq.Circuit(
|
|
@@ -222,7 +222,7 @@ def test_already_valid_circuit():
|
|
|
222
222
|
cirq.testing.assert_same_circuits(routed_circuit, circuit)
|
|
223
223
|
|
|
224
224
|
|
|
225
|
-
def test_empty_circuit():
|
|
225
|
+
def test_empty_circuit() -> None:
|
|
226
226
|
device = cirq.testing.construct_grid_device(5, 5)
|
|
227
227
|
device_graph = device.metadata.nx_graph
|
|
228
228
|
empty_circuit = cirq.Circuit()
|
|
@@ -235,7 +235,7 @@ def test_empty_circuit():
|
|
|
235
235
|
)
|
|
236
236
|
|
|
237
237
|
|
|
238
|
-
def test_repr():
|
|
238
|
+
def test_repr() -> None:
|
|
239
239
|
device = cirq.testing.construct_ring_device(10)
|
|
240
240
|
device_graph = device.metadata.nx_graph
|
|
241
241
|
router = cirq.RouteCQC(device_graph)
|
|
@@ -17,7 +17,7 @@ import pytest
|
|
|
17
17
|
import cirq
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_routed_circuit_with_mapping_simple():
|
|
20
|
+
def test_routed_circuit_with_mapping_simple() -> None:
|
|
21
21
|
q = cirq.LineQubit.range(2)
|
|
22
22
|
circuit = cirq.Circuit([cirq.Moment(cirq.SWAP(q[0], q[1]).with_tags(cirq.RoutingSwapTag()))])
|
|
23
23
|
expected_diagram = """
|
|
@@ -57,7 +57,7 @@ def test_routed_circuit_with_mapping_simple():
|
|
|
57
57
|
cirq.routed_circuit_with_mapping(circuit)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def test_routed_circuit_with_mapping_multi_swaps():
|
|
60
|
+
def test_routed_circuit_with_mapping_multi_swaps() -> None:
|
|
61
61
|
q = cirq.LineQubit.range(6)
|
|
62
62
|
circuit = cirq.Circuit(
|
|
63
63
|
[
|
|
@@ -48,14 +48,14 @@ def assert_optimizes(before, after, measure_only_moment=True, with_context=False
|
|
|
48
48
|
cirq.testing.assert_same_circuits(transformed_circuit, c_expected)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
def test_no_move():
|
|
51
|
+
def test_no_move() -> None:
|
|
52
52
|
q1 = cirq.NamedQubit('q1')
|
|
53
53
|
before = cirq.Circuit([cirq.Moment([cirq.H(q1)])])
|
|
54
54
|
after = before
|
|
55
55
|
assert_optimizes(before=before, after=after)
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def test_simple_align():
|
|
58
|
+
def test_simple_align() -> None:
|
|
59
59
|
q1 = cirq.NamedQubit('q1')
|
|
60
60
|
q2 = cirq.NamedQubit('q2')
|
|
61
61
|
before = cirq.Circuit(
|
|
@@ -76,7 +76,7 @@ def test_simple_align():
|
|
|
76
76
|
assert_optimizes(before=before, after=before, with_context=True)
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
def test_simple_partial_align():
|
|
79
|
+
def test_simple_partial_align() -> None:
|
|
80
80
|
q1 = cirq.NamedQubit('q1')
|
|
81
81
|
q2 = cirq.NamedQubit('q2')
|
|
82
82
|
before = cirq.Circuit(
|
|
@@ -96,7 +96,7 @@ def test_simple_partial_align():
|
|
|
96
96
|
assert_optimizes(before=before, after=before, with_context=True)
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
def test_slide_forward_one():
|
|
99
|
+
def test_slide_forward_one() -> None:
|
|
100
100
|
q1 = cirq.NamedQubit('q1')
|
|
101
101
|
q2 = cirq.NamedQubit('q2')
|
|
102
102
|
q3 = cirq.NamedQubit('q3')
|
|
@@ -119,7 +119,7 @@ def test_slide_forward_one():
|
|
|
119
119
|
assert_optimizes(before=before, after=after_no_compile, with_context=True)
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def test_no_slide_forward_one():
|
|
122
|
+
def test_no_slide_forward_one() -> None:
|
|
123
123
|
q1 = cirq.NamedQubit('q1')
|
|
124
124
|
q2 = cirq.NamedQubit('q2')
|
|
125
125
|
q3 = cirq.NamedQubit('q3')
|
|
@@ -128,7 +128,7 @@ def test_no_slide_forward_one():
|
|
|
128
128
|
assert_optimizes(before=before, after=after, measure_only_moment=False)
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
def test_blocked_shift_one():
|
|
131
|
+
def test_blocked_shift_one() -> None:
|
|
132
132
|
q1 = cirq.NamedQubit('q1')
|
|
133
133
|
q2 = cirq.NamedQubit('q2')
|
|
134
134
|
before = cirq.Circuit(
|
|
@@ -150,7 +150,7 @@ def test_blocked_shift_one():
|
|
|
150
150
|
assert_optimizes(before=before, after=before, with_context=True)
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def test_complex_move():
|
|
153
|
+
def test_complex_move() -> None:
|
|
154
154
|
q1 = cirq.NamedQubit('q1')
|
|
155
155
|
q2 = cirq.NamedQubit('q2')
|
|
156
156
|
q3 = cirq.NamedQubit('q3')
|
|
@@ -182,7 +182,7 @@ def test_complex_move():
|
|
|
182
182
|
assert_optimizes(before=before, after=before, with_context=True)
|
|
183
183
|
|
|
184
184
|
|
|
185
|
-
def test_complex_move_no_slide():
|
|
185
|
+
def test_complex_move_no_slide() -> None:
|
|
186
186
|
q1 = cirq.NamedQubit('q1')
|
|
187
187
|
q2 = cirq.NamedQubit('q2')
|
|
188
188
|
q3 = cirq.NamedQubit('q3')
|
|
@@ -208,13 +208,13 @@ def test_complex_move_no_slide():
|
|
|
208
208
|
assert_optimizes(before=before, after=before, measure_only_moment=False, with_context=True)
|
|
209
209
|
|
|
210
210
|
|
|
211
|
-
def test_multi_qubit():
|
|
211
|
+
def test_multi_qubit() -> None:
|
|
212
212
|
q0, q1 = cirq.LineQubit.range(2)
|
|
213
213
|
circuit = cirq.Circuit(cirq.H(q1), cirq.measure(q0, q1, key='m'))
|
|
214
214
|
assert_optimizes(before=circuit, after=circuit)
|
|
215
215
|
|
|
216
216
|
|
|
217
|
-
def test_classically_controlled_op():
|
|
217
|
+
def test_classically_controlled_op() -> None:
|
|
218
218
|
q0, q1 = cirq.LineQubit.range(2)
|
|
219
219
|
circuit = cirq.Circuit(
|
|
220
220
|
cirq.H(q0), cirq.measure(q0, key='m'), cirq.X(q1).with_classical_controls('m')
|
|
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
|
|
|
24
24
|
from cirq.protocols.decompose_protocol import DecomposeResult
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def test_compilation_target_gateset():
|
|
27
|
+
def test_compilation_target_gateset() -> None:
|
|
28
28
|
class ExampleTargetGateset(cirq.CompilationTargetGateset):
|
|
29
29
|
def __init__(self):
|
|
30
30
|
super().__init__(cirq.AnyUnitaryGateFamily(2))
|
|
@@ -94,7 +94,7 @@ class ExampleCXTargetGateset(cirq.TwoQubitCompilationTargetGateset):
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
def test_two_qubit_compilation_leaves_single_gates_in_gateset():
|
|
97
|
+
def test_two_qubit_compilation_leaves_single_gates_in_gateset() -> None:
|
|
98
98
|
q = cirq.LineQubit.range(2)
|
|
99
99
|
gateset = ExampleCXTargetGateset()
|
|
100
100
|
|
|
@@ -105,7 +105,7 @@ def test_two_qubit_compilation_leaves_single_gates_in_gateset():
|
|
|
105
105
|
cirq.testing.assert_same_circuits(cirq.optimize_for_target_gateset(c, gateset=gateset), c)
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
def test_two_qubit_compilation_merges_runs_of_single_qubit_gates():
|
|
108
|
+
def test_two_qubit_compilation_merges_runs_of_single_qubit_gates() -> None:
|
|
109
109
|
q = cirq.LineQubit.range(2)
|
|
110
110
|
c = cirq.Circuit(cirq.CNOT(*q), cirq.X(q[0]), cirq.Y(q[0]), cirq.CNOT(*q))
|
|
111
111
|
cirq.testing.assert_same_circuits(
|
|
@@ -118,7 +118,7 @@ def test_two_qubit_compilation_merges_runs_of_single_qubit_gates():
|
|
|
118
118
|
)
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
def test_two_qubit_compilation_decompose_operation_not_implemented():
|
|
121
|
+
def test_two_qubit_compilation_decompose_operation_not_implemented() -> None:
|
|
122
122
|
gateset = ExampleCXTargetGateset()
|
|
123
123
|
q = cirq.LineQubit.range(3)
|
|
124
124
|
assert gateset.decompose_to_target_gateset(cirq.measure(q[0]), 1) is NotImplemented
|
|
@@ -130,7 +130,7 @@ def test_two_qubit_compilation_decompose_operation_not_implemented():
|
|
|
130
130
|
assert gateset.decompose_to_target_gateset(cirq.CCZ(*q), 1) is NotImplemented
|
|
131
131
|
|
|
132
132
|
|
|
133
|
-
def test_two_qubit_compilation_merge_and_replace_to_target_gateset():
|
|
133
|
+
def test_two_qubit_compilation_merge_and_replace_to_target_gateset() -> None:
|
|
134
134
|
q = cirq.LineQubit.range(2)
|
|
135
135
|
c_orig = cirq.Circuit(
|
|
136
136
|
cirq.Moment(cirq.Z(q[1]), cirq.X(q[0])),
|
|
@@ -164,7 +164,7 @@ def test_two_qubit_compilation_merge_and_replace_to_target_gateset():
|
|
|
164
164
|
)
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
def test_two_qubit_compilation_merge_and_replace_inefficient_component():
|
|
167
|
+
def test_two_qubit_compilation_merge_and_replace_inefficient_component() -> None:
|
|
168
168
|
q = cirq.LineQubit.range(2)
|
|
169
169
|
c_orig = cirq.Circuit(
|
|
170
170
|
cirq.Moment(cirq.X(q[0])),
|
|
@@ -208,7 +208,7 @@ m: ═════════════════════════
|
|
|
208
208
|
)
|
|
209
209
|
|
|
210
210
|
|
|
211
|
-
def test_two_qubit_compilation_replaces_only_if_2q_gate_count_is_less():
|
|
211
|
+
def test_two_qubit_compilation_replaces_only_if_2q_gate_count_is_less() -> None:
|
|
212
212
|
class ExampleTargetGateset(cirq.TwoQubitCompilationTargetGateset):
|
|
213
213
|
def __init__(self):
|
|
214
214
|
super().__init__(cirq.X, cirq.CNOT)
|
|
@@ -228,7 +228,7 @@ def test_two_qubit_compilation_replaces_only_if_2q_gate_count_is_less():
|
|
|
228
228
|
cirq.testing.assert_same_circuits(c_new, c_expected)
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
def test_create_transformer_with_kwargs_raises():
|
|
231
|
+
def test_create_transformer_with_kwargs_raises() -> None:
|
|
232
232
|
with pytest.raises(SyntaxError, match="must not contain `context`"):
|
|
233
233
|
cirq.create_transformer_with_kwargs(
|
|
234
234
|
cirq.merge_k_qubit_unitaries, k=2, context=cirq.TransformerContext()
|