cirq-core 1.6.0.dev20250509215532__py3-none-any.whl → 1.6.0.dev20250512192405__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.dev20250512192405.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/RECORD +167 -167
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
|
@@ -54,7 +54,7 @@ def _curve_pieces_diagram(chars: BoxDrawCharacterSet) -> BlockDiagramDrawer:
|
|
|
54
54
|
return d
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_block_curve():
|
|
57
|
+
def test_block_curve() -> None:
|
|
58
58
|
d = _curve_pieces_diagram(NORMAL_BOX_CHARS)
|
|
59
59
|
actual = d.render(min_block_width=5, min_block_height=5)
|
|
60
60
|
expected = """
|
|
@@ -177,7 +177,7 @@ def test_block_curve():
|
|
|
177
177
|
_assert_same_diagram(actual, expected)
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
def test_mixed_block_curve():
|
|
180
|
+
def test_mixed_block_curve() -> None:
|
|
181
181
|
diagram = BlockDiagramDrawer()
|
|
182
182
|
for a, b, c, d in itertools.product(range(3), repeat=4):
|
|
183
183
|
x = (a * 3 + b) * 2
|
|
@@ -244,7 +244,7 @@ def test_mixed_block_curve():
|
|
|
244
244
|
_assert_same_diagram(actual, expected)
|
|
245
245
|
|
|
246
246
|
|
|
247
|
-
def test_lines_meet_content():
|
|
247
|
+
def test_lines_meet_content() -> None:
|
|
248
248
|
d = BlockDiagramDrawer()
|
|
249
249
|
b = d.mutable_block(0, 0)
|
|
250
250
|
b.content = 'long text\nwith multiple lines'
|
|
@@ -409,7 +409,7 @@ with multiple lines
|
|
|
409
409
|
)
|
|
410
410
|
|
|
411
411
|
|
|
412
|
-
def test_content_stretches_other_blocks():
|
|
412
|
+
def test_content_stretches_other_blocks() -> None:
|
|
413
413
|
d = BlockDiagramDrawer()
|
|
414
414
|
d.mutable_block(0, 0).horizontal_alignment = 0.5
|
|
415
415
|
d.mutable_block(1, 0).horizontal_alignment = 0.5
|
|
@@ -430,7 +430,7 @@ with multiple lines│
|
|
|
430
430
|
)
|
|
431
431
|
|
|
432
432
|
|
|
433
|
-
def test_lines_stretch_content():
|
|
433
|
+
def test_lines_stretch_content() -> None:
|
|
434
434
|
d = BlockDiagramDrawer()
|
|
435
435
|
d.mutable_block(0, 0).left = 'l'
|
|
436
436
|
d.mutable_block(2, 4).right = 'r'
|
|
@@ -449,7 +449,7 @@ def test_lines_stretch_content():
|
|
|
449
449
|
)
|
|
450
450
|
|
|
451
451
|
|
|
452
|
-
def test_indices():
|
|
452
|
+
def test_indices() -> None:
|
|
453
453
|
d = BlockDiagramDrawer()
|
|
454
454
|
with pytest.raises(IndexError):
|
|
455
455
|
d.mutable_block(-1, -1)
|
|
@@ -21,7 +21,7 @@ from cirq.circuits._box_drawing_character_data import (
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def test_chars():
|
|
24
|
+
def test_chars() -> None:
|
|
25
25
|
assert NORMAL_BOX_CHARS.char() is None
|
|
26
26
|
assert NORMAL_BOX_CHARS.char(top=True, bottom=True) == '│'
|
|
27
27
|
assert NORMAL_THEN_BOLD_MIXED_BOX_CHARS.char() is None
|
|
@@ -19,7 +19,7 @@ import pytest
|
|
|
19
19
|
import cirq
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def test_repr():
|
|
22
|
+
def test_repr() -> None:
|
|
23
23
|
assert repr(cirq.InsertStrategy.NEW) == 'cirq.InsertStrategy.NEW'
|
|
24
24
|
assert str(cirq.InsertStrategy.NEW) == 'NEW'
|
|
25
25
|
|
|
@@ -34,6 +34,6 @@ def test_repr():
|
|
|
34
34
|
],
|
|
35
35
|
ids=lambda strategy: strategy.name,
|
|
36
36
|
)
|
|
37
|
-
def test_identity_after_pickling(strategy: cirq.InsertStrategy):
|
|
37
|
+
def test_identity_after_pickling(strategy: cirq.InsertStrategy) -> None:
|
|
38
38
|
unpickled_strategy = pickle.loads(pickle.dumps(strategy))
|
|
39
39
|
assert unpickled_strategy is strategy
|
|
@@ -21,7 +21,7 @@ from cirq import Operation, PointOptimizationSummary, PointOptimizer
|
|
|
21
21
|
from cirq.testing import EqualsTester
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def test_equality():
|
|
24
|
+
def test_equality() -> None:
|
|
25
25
|
a = cirq.NamedQubit('a')
|
|
26
26
|
b = cirq.NamedQubit('b')
|
|
27
27
|
xa = cirq.X(a)
|
|
@@ -86,7 +86,7 @@ class ReplaceWithXGates(PointOptimizer):
|
|
|
86
86
|
)
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
def test_point_optimizer_can_write_new_gates_inline():
|
|
89
|
+
def test_point_optimizer_can_write_new_gates_inline() -> None:
|
|
90
90
|
x = cirq.NamedQubit('x')
|
|
91
91
|
y = cirq.NamedQubit('y')
|
|
92
92
|
z = cirq.NamedQubit('z')
|
|
@@ -116,7 +116,7 @@ z: ───────────────────X───X───
|
|
|
116
116
|
assert actual_text_diagram == expected_text_diagram
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
def test_point_optimizer_post_clean_up():
|
|
119
|
+
def test_point_optimizer_post_clean_up() -> None:
|
|
120
120
|
x = cirq.NamedQubit('x')
|
|
121
121
|
y = cirq.NamedQubit('y')
|
|
122
122
|
z = cirq.NamedQubit('z')
|
|
@@ -150,7 +150,7 @@ z: ─────────────────────────
|
|
|
150
150
|
assert actual_text_diagram == expected_text_diagram
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def test_point_optimizer_raises_on_gates_changing_qubits():
|
|
153
|
+
def test_point_optimizer_raises_on_gates_changing_qubits() -> None:
|
|
154
154
|
class EverythingIs42(cirq.PointOptimizer):
|
|
155
155
|
"""Changes all single qubit operations to act on LineQubit(42)"""
|
|
156
156
|
|
|
@@ -171,7 +171,7 @@ def test_point_optimizer_raises_on_gates_changing_qubits():
|
|
|
171
171
|
EverythingIs42().optimize_circuit(c)
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def test_repr():
|
|
174
|
+
def test_repr() -> None:
|
|
175
175
|
assert (
|
|
176
176
|
repr(cirq.PointOptimizationSummary(clear_span=0, clear_qubits=[], new_operations=[]))
|
|
177
177
|
== 'cirq.PointOptimizationSummary(0, (), ())'
|
|
@@ -22,7 +22,7 @@ import cirq.contrib.acquaintance.inspection_utils as inspection_utils
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@pytest.mark.parametrize('n_qubits, acquaintance_size', product(range(2, 6), range(2, 5)))
|
|
25
|
-
def test_get_logical_acquaintance_opportunities(n_qubits, acquaintance_size):
|
|
25
|
+
def test_get_logical_acquaintance_opportunities(n_qubits, acquaintance_size) -> None:
|
|
26
26
|
qubits = cirq.LineQubit.range(n_qubits)
|
|
27
27
|
acquaintance_strategy = cca.complete_acquaintance_strategy(qubits, acquaintance_size)
|
|
28
28
|
initial_mapping = {q: i for i, q in enumerate(qubits)}
|
|
@@ -30,5 +30,5 @@ def test_get_logical_acquaintance_opportunities(n_qubits, acquaintance_size):
|
|
|
30
30
|
assert opps == set(frozenset(s) for s in combinations(range(n_qubits), acquaintance_size))
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def test_device():
|
|
33
|
+
def test_device() -> None:
|
|
34
34
|
assert inspection_utils.LogicalAnnotator({}).device == cirq.UNCONSTRAINED_DEVICE
|
|
@@ -20,7 +20,7 @@ import cirq
|
|
|
20
20
|
import cirq.contrib.acquaintance as cca
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def test_complete_acquaintance_strategy():
|
|
23
|
+
def test_complete_acquaintance_strategy() -> None:
|
|
24
24
|
qubits = [cirq.NamedQubit(s) for s in alphabet]
|
|
25
25
|
|
|
26
26
|
with pytest.raises(ValueError):
|
|
@@ -136,7 +136,7 @@ a b c d
|
|
|
136
136
|
assert cca.get_acquaintance_size(cubic_strategy) == 3
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
def test_rectification():
|
|
139
|
+
def test_rectification() -> None:
|
|
140
140
|
qubits = cirq.LineQubit.range(4)
|
|
141
141
|
|
|
142
142
|
perm_gate = cca.SwapPermutationGate()
|
|
@@ -16,7 +16,7 @@ import cirq.contrib.acquaintance as cca
|
|
|
16
16
|
import cirq.testing as ct
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_remove_redundant_acquaintance_opportunities():
|
|
19
|
+
def test_remove_redundant_acquaintance_opportunities() -> None:
|
|
20
20
|
a, b, c, d, e = cirq.LineQubit.range(5)
|
|
21
21
|
swap = cca.SwapPermutationGate()
|
|
22
22
|
|
|
@@ -16,7 +16,7 @@ import cirq
|
|
|
16
16
|
import cirq.contrib.acquaintance as cca
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_circular_shift_gate_init():
|
|
19
|
+
def test_circular_shift_gate_init() -> None:
|
|
20
20
|
g = cca.CircularShiftGate(4, 2)
|
|
21
21
|
assert g.num_qubits() == 4
|
|
22
22
|
assert g.shift == 2
|
|
@@ -25,7 +25,7 @@ def test_circular_shift_gate_init():
|
|
|
25
25
|
assert g.swap_gate == cirq.CZ
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_circular_shift_gate_eq():
|
|
28
|
+
def test_circular_shift_gate_eq() -> None:
|
|
29
29
|
equals_tester = cirq.testing.EqualsTester()
|
|
30
30
|
equals_tester.add_equality_group(cca.CircularShiftGate(4, 1), cca.CircularShiftGate(4, 1))
|
|
31
31
|
equals_tester.add_equality_group(cca.CircularShiftGate(4, 1, swap_gate=cirq.CZ))
|
|
@@ -34,19 +34,19 @@ def test_circular_shift_gate_eq():
|
|
|
34
34
|
equals_tester.add_equality_group(cca.CircularShiftGate(3, 2, swap_gate=cirq.CZ))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_circular_shift_gate_permutation():
|
|
37
|
+
def test_circular_shift_gate_permutation() -> None:
|
|
38
38
|
assert cca.CircularShiftGate(3, 4).permutation() == {0: 2, 1: 0, 2: 1}
|
|
39
39
|
assert cca.CircularShiftGate(4, 0).permutation() == {0: 0, 1: 1, 2: 2, 3: 3}
|
|
40
40
|
|
|
41
41
|
assert cca.CircularShiftGate(5, 2).permutation() == {0: 3, 1: 4, 2: 0, 3: 1, 4: 2}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
def test_circular_shift_gate_repr():
|
|
44
|
+
def test_circular_shift_gate_repr() -> None:
|
|
45
45
|
g = cca.CircularShiftGate(3, 2)
|
|
46
46
|
cirq.testing.assert_equivalent_repr(g)
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def test_circular_shift_gate_decomposition():
|
|
49
|
+
def test_circular_shift_gate_decomposition() -> None:
|
|
50
50
|
qubits = [cirq.NamedQubit(q) for q in 'abcdef']
|
|
51
51
|
|
|
52
52
|
circular_shift = cca.CircularShiftGate(2, 1, cirq.CZ)(*qubits[:2])
|
|
@@ -92,7 +92,7 @@ f: ───────────────×───────
|
|
|
92
92
|
assert actual_text_diagram == expected_text_diagram
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def test_circular_shift_gate_wire_symbols():
|
|
95
|
+
def test_circular_shift_gate_wire_symbols() -> None:
|
|
96
96
|
qubits = [cirq.NamedQubit(q) for q in 'xyz']
|
|
97
97
|
circuit = cirq.Circuit(cca.CircularShiftGate(3, 2)(*qubits))
|
|
98
98
|
actual_text_diagram = circuit.to_text_diagram().strip()
|
|
@@ -21,7 +21,7 @@ import cirq.contrib.acquaintance as cca
|
|
|
21
21
|
import cirq.contrib.acquaintance.strategies.cubic as ccasc
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def test_skip_and_wrap_around():
|
|
24
|
+
def test_skip_and_wrap_around() -> None:
|
|
25
25
|
assert ccasc.skip_and_wrap_around(range(3)) == (0, 2, 1)
|
|
26
26
|
assert ccasc.skip_and_wrap_around(range(4)) == (0, 3, 1, 2)
|
|
27
27
|
assert ccasc.skip_and_wrap_around('abcde') == tuple('aebdc')
|
|
@@ -29,7 +29,7 @@ def test_skip_and_wrap_around():
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
@pytest.mark.parametrize('n_qubits', range(3, 9))
|
|
32
|
-
def test_cubic_acquaintance_strategy(n_qubits):
|
|
32
|
+
def test_cubic_acquaintance_strategy(n_qubits) -> None:
|
|
33
33
|
qubits = tuple(cirq.LineQubit.range(n_qubits))
|
|
34
34
|
strategy = cca.cubic_acquaintance_strategy(qubits)
|
|
35
35
|
initial_mapping = {q: i for i, q in enumerate(qubits)}
|
|
@@ -29,7 +29,7 @@ import cirq.contrib.acquaintance as cca
|
|
|
29
29
|
for _ in range(5)
|
|
30
30
|
],
|
|
31
31
|
)
|
|
32
|
-
def test_topological_sort(circuit_dag, sorted_nodes):
|
|
32
|
+
def test_topological_sort(circuit_dag, sorted_nodes) -> None:
|
|
33
33
|
sorted_nodes = list(sorted_nodes)
|
|
34
34
|
assert cca.is_topologically_sorted(circuit_dag, (node.val for node in sorted_nodes))
|
|
35
35
|
|
cirq/contrib/json_test.py
CHANGED
|
@@ -7,14 +7,14 @@ from cirq.contrib.quantum_volume import QuantumVolumeResult
|
|
|
7
7
|
from cirq.testing import assert_json_roundtrip_works
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def test_bayesian_network_gate():
|
|
10
|
+
def test_bayesian_network_gate() -> None:
|
|
11
11
|
gate = BayesianNetworkGate(
|
|
12
12
|
init_probs=[('q0', 0.125), ('q1', None)], arc_probs=[('q1', ('q0',), [0.25, 0.5])]
|
|
13
13
|
)
|
|
14
14
|
assert_json_roundtrip_works(gate, resolvers=DEFAULT_CONTRIB_RESOLVERS)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def test_quantum_volume():
|
|
17
|
+
def test_quantum_volume() -> None:
|
|
18
18
|
qubits = cirq.LineQubit.range(5)
|
|
19
19
|
qvr = QuantumVolumeResult(
|
|
20
20
|
model_circuit=cirq.Circuit(cirq.H.on_each(qubits)),
|
|
@@ -25,6 +25,6 @@ def test_quantum_volume():
|
|
|
25
25
|
assert_json_roundtrip_works(qvr, resolvers=DEFAULT_CONTRIB_RESOLVERS)
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_swap_permutation_gate():
|
|
28
|
+
def test_swap_permutation_gate() -> None:
|
|
29
29
|
gate = SwapPermutationGate(swap_gate=cirq.SWAP)
|
|
30
30
|
assert_json_roundtrip_works(gate, resolvers=DEFAULT_CONTRIB_RESOLVERS)
|
|
@@ -18,7 +18,7 @@ from cirq import ops
|
|
|
18
18
|
from cirq.testing import assert_equivalent_op_tree
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_depol_noise():
|
|
21
|
+
def test_depol_noise() -> None:
|
|
22
22
|
noise_model = ccn.DepolarizingNoiseModel(depol_prob=0.005)
|
|
23
23
|
qubits = cirq.LineQubit.range(2)
|
|
24
24
|
moment = cirq.Moment([cirq.X(qubits[0]), cirq.Y(qubits[1])])
|
|
@@ -29,7 +29,7 @@ def test_depol_noise():
|
|
|
29
29
|
assert isinstance(g.gate, cirq.DepolarizingChannel)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def test_depol_noise_prepend():
|
|
32
|
+
def test_depol_noise_prepend() -> None:
|
|
33
33
|
noise_model = ccn.DepolarizingNoiseModel(depol_prob=0.005, prepend=True)
|
|
34
34
|
qubits = cirq.LineQubit.range(2)
|
|
35
35
|
moment = cirq.Moment([cirq.X(qubits[0]), cirq.Y(qubits[1])])
|
|
@@ -41,7 +41,7 @@ def test_depol_noise_prepend():
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
# Composes depolarization noise with readout noise.
|
|
44
|
-
def test_readout_noise_after_moment():
|
|
44
|
+
def test_readout_noise_after_moment() -> None:
|
|
45
45
|
program = cirq.Circuit()
|
|
46
46
|
qubits = cirq.LineQubit.range(3)
|
|
47
47
|
program.append(
|
|
@@ -92,7 +92,7 @@ def test_readout_noise_after_moment():
|
|
|
92
92
|
assert_equivalent_op_tree(true_noisy_program, noisy_circuit)
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def test_readout_noise_no_prepend():
|
|
95
|
+
def test_readout_noise_no_prepend() -> None:
|
|
96
96
|
noise_model = ccn.ReadoutNoiseModel(bitflip_prob=0.005, prepend=False)
|
|
97
97
|
qubits = cirq.LineQubit.range(2)
|
|
98
98
|
moment = cirq.Moment([cirq.measure(*qubits, key="meas")])
|
|
@@ -104,7 +104,7 @@ def test_readout_noise_no_prepend():
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
# Composes depolarization, damping, and readout noise (in that order).
|
|
107
|
-
def test_decay_noise_after_moment():
|
|
107
|
+
def test_decay_noise_after_moment() -> None:
|
|
108
108
|
program = cirq.Circuit()
|
|
109
109
|
qubits = cirq.LineQubit.range(3)
|
|
110
110
|
program.append(
|
|
@@ -160,7 +160,7 @@ def test_decay_noise_after_moment():
|
|
|
160
160
|
assert_equivalent_op_tree(true_noisy_program, noisy_circuit)
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
def test_damped_readout_noise_no_prepend():
|
|
163
|
+
def test_damped_readout_noise_no_prepend() -> None:
|
|
164
164
|
noise_model = ccn.DampedReadoutNoiseModel(decay_prob=0.005, prepend=False)
|
|
165
165
|
qubits = cirq.LineQubit.range(2)
|
|
166
166
|
moment = cirq.Moment([cirq.measure(*qubits, key="meas")])
|
|
@@ -172,7 +172,7 @@ def test_damped_readout_noise_no_prepend():
|
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
# Test the aggregate noise models.
|
|
175
|
-
def test_aggregate_readout_noise_after_moment():
|
|
175
|
+
def test_aggregate_readout_noise_after_moment() -> None:
|
|
176
176
|
program = cirq.Circuit()
|
|
177
177
|
qubits = cirq.LineQubit.range(3)
|
|
178
178
|
program.append(
|
|
@@ -219,7 +219,7 @@ def test_aggregate_readout_noise_after_moment():
|
|
|
219
219
|
assert_equivalent_op_tree(true_noisy_program, noisy_circuit)
|
|
220
220
|
|
|
221
221
|
|
|
222
|
-
def test_aggregate_decay_noise_after_moment():
|
|
222
|
+
def test_aggregate_decay_noise_after_moment() -> None:
|
|
223
223
|
program = cirq.Circuit()
|
|
224
224
|
qubits = cirq.LineQubit.range(3)
|
|
225
225
|
program.append(
|
|
@@ -17,7 +17,7 @@ import cirq
|
|
|
17
17
|
from cirq.contrib.paulistring import clifford_optimized_circuit, CliffordTargetGateset
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_optimize():
|
|
20
|
+
def test_optimize() -> None:
|
|
21
21
|
q0, q1 = cirq.LineQubit.range(2)
|
|
22
22
|
c_orig = cirq.Circuit(
|
|
23
23
|
cirq.X(q1) ** 0.5,
|
|
@@ -49,7 +49,7 @@ def test_optimize():
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def test_remove_czs():
|
|
52
|
+
def test_remove_czs() -> None:
|
|
53
53
|
q0, q1 = cirq.LineQubit.range(2)
|
|
54
54
|
c_orig = cirq.Circuit(cirq.CZ(q0, q1), cirq.Z(q0) ** 0.5, cirq.CZ(q0, q1))
|
|
55
55
|
c_expected = cirq.optimize_for_target_gateset(
|
|
@@ -72,7 +72,7 @@ def test_remove_czs():
|
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def test_remove_staggered_czs():
|
|
75
|
+
def test_remove_staggered_czs() -> None:
|
|
76
76
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
77
77
|
c_orig = cirq.Circuit(cirq.CZ(q0, q1), cirq.CZ(q1, q2), cirq.CZ(q0, q1))
|
|
78
78
|
c_expected = cirq.optimize_for_target_gateset(
|
|
@@ -97,7 +97,7 @@ def test_remove_staggered_czs():
|
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
def test_with_measurements():
|
|
100
|
+
def test_with_measurements() -> None:
|
|
101
101
|
q0, q1 = cirq.LineQubit.range(2)
|
|
102
102
|
c_orig = cirq.Circuit(cirq.X(q0), cirq.CZ(q0, q1), cirq.measure(q0, q1, key='m'))
|
|
103
103
|
c_expected = cirq.optimize_for_target_gateset(
|
|
@@ -121,7 +121,7 @@ def test_with_measurements():
|
|
|
121
121
|
)
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
def test_optimize_large_circuit():
|
|
124
|
+
def test_optimize_large_circuit() -> None:
|
|
125
125
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
126
126
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
127
127
|
|
|
@@ -41,7 +41,7 @@ from cirq.contrib.paulistring.clifford_target_gateset import CliffordTargetGates
|
|
|
41
41
|
)
|
|
42
42
|
)(cirq.LineQubit(0), cirq.LineQubit(1)),
|
|
43
43
|
)
|
|
44
|
-
def test_converts_various_ops(op, expected_ops):
|
|
44
|
+
def test_converts_various_ops(op, expected_ops) -> None:
|
|
45
45
|
before = cirq.Circuit(op)
|
|
46
46
|
expected = cirq.Circuit(expected_ops, strategy=cirq.InsertStrategy.EARLIEST)
|
|
47
47
|
after = cirq.optimize_for_target_gateset(
|
|
@@ -58,7 +58,7 @@ def test_converts_various_ops(op, expected_ops):
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def test_degenerate_single_qubit_decompose():
|
|
61
|
+
def test_degenerate_single_qubit_decompose() -> None:
|
|
62
62
|
q0 = cirq.LineQubit(0)
|
|
63
63
|
|
|
64
64
|
before = cirq.Circuit(cirq.Z(q0) ** 0.1, cirq.X(q0) ** 1.0000000001, cirq.Z(q0) ** 0.1)
|
|
@@ -72,7 +72,7 @@ def test_degenerate_single_qubit_decompose():
|
|
|
72
72
|
cirq.testing.assert_allclose_up_to_global_phase(after.unitary(), expected.unitary(), atol=1e-7)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def test_converts_single_qubit_series():
|
|
75
|
+
def test_converts_single_qubit_series() -> None:
|
|
76
76
|
q0 = cirq.LineQubit(0)
|
|
77
77
|
|
|
78
78
|
before = cirq.Circuit(
|
|
@@ -96,7 +96,7 @@ def test_converts_single_qubit_series():
|
|
|
96
96
|
cirq.testing.assert_allclose_up_to_global_phase(before.unitary(), after.unitary(), atol=1e-7)
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
def test_converts_single_qubit_then_two():
|
|
99
|
+
def test_converts_single_qubit_then_two() -> None:
|
|
100
100
|
q0, q1 = cirq.LineQubit.range(2)
|
|
101
101
|
|
|
102
102
|
before = cirq.Circuit(cirq.X(q0), cirq.Y(q0), cirq.CZ(q0, q1))
|
|
@@ -107,7 +107,7 @@ def test_converts_single_qubit_then_two():
|
|
|
107
107
|
cirq.testing.assert_allclose_up_to_global_phase(before.unitary(), after.unitary(), atol=1e-7)
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
def test_converts_large_circuit():
|
|
110
|
+
def test_converts_large_circuit() -> None:
|
|
111
111
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
112
112
|
|
|
113
113
|
before = cirq.Circuit(
|
|
@@ -147,7 +147,7 @@ def test_converts_large_circuit():
|
|
|
147
147
|
)
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
def test_convert_to_pauli_string_phasors():
|
|
150
|
+
def test_convert_to_pauli_string_phasors() -> None:
|
|
151
151
|
q0, q1 = cirq.LineQubit.range(2)
|
|
152
152
|
c_orig = cirq.Circuit(cirq.X(q0), cirq.Y(q1) ** 0.25, cirq.Z(q0) ** 0.125, cirq.H(q1))
|
|
153
153
|
c_new = cirq.optimize_for_target_gateset(
|
|
@@ -168,7 +168,7 @@ def test_convert_to_pauli_string_phasors():
|
|
|
168
168
|
)
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
def test_already_converted():
|
|
171
|
+
def test_already_converted() -> None:
|
|
172
172
|
q0 = cirq.LineQubit(0)
|
|
173
173
|
c_orig = cirq.Circuit(cirq.PauliStringPhasor(cirq.X.on(q0)))
|
|
174
174
|
c_new = cirq.optimize_for_target_gateset(
|
|
@@ -181,7 +181,7 @@ def test_already_converted():
|
|
|
181
181
|
assert c_new == c_orig
|
|
182
182
|
|
|
183
183
|
|
|
184
|
-
def test_ignore_unsupported_gate():
|
|
184
|
+
def test_ignore_unsupported_gate() -> None:
|
|
185
185
|
class UnsupportedGate(cirq.testing.TwoQubitGate):
|
|
186
186
|
pass
|
|
187
187
|
|
|
@@ -193,7 +193,7 @@ def test_ignore_unsupported_gate():
|
|
|
193
193
|
assert c_new == c_orig
|
|
194
194
|
|
|
195
195
|
|
|
196
|
-
def test_fail_unsupported_gate():
|
|
196
|
+
def test_fail_unsupported_gate() -> None:
|
|
197
197
|
class UnsupportedGate(cirq.testing.TwoQubitGate):
|
|
198
198
|
pass
|
|
199
199
|
|
|
@@ -205,7 +205,7 @@ def test_fail_unsupported_gate():
|
|
|
205
205
|
)
|
|
206
206
|
|
|
207
207
|
|
|
208
|
-
def test_convert_to_single_qubit_cliffords():
|
|
208
|
+
def test_convert_to_single_qubit_cliffords() -> None:
|
|
209
209
|
q0, q1 = cirq.LineQubit.range(2)
|
|
210
210
|
c_orig = cirq.Circuit(
|
|
211
211
|
cirq.X(q0), cirq.Y(q1) ** 0.5, cirq.Z(q0) ** -0.5, cirq.Z(q1) ** 0, cirq.H(q0)
|
|
@@ -232,7 +232,7 @@ def test_convert_to_single_qubit_cliffords():
|
|
|
232
232
|
)
|
|
233
233
|
|
|
234
234
|
|
|
235
|
-
def test_convert_to_single_qubit_cliffords_ignores_non_clifford():
|
|
235
|
+
def test_convert_to_single_qubit_cliffords_ignores_non_clifford() -> None:
|
|
236
236
|
q0 = cirq.LineQubit(0)
|
|
237
237
|
c_orig = cirq.Circuit(cirq.Z(q0) ** 0.25)
|
|
238
238
|
c_new = cirq.optimize_for_target_gateset(
|
|
@@ -17,7 +17,7 @@ import cirq
|
|
|
17
17
|
from cirq.contrib.paulistring import optimized_circuit
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_optimize():
|
|
20
|
+
def test_optimize() -> None:
|
|
21
21
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
22
22
|
c_orig = cirq.Circuit(
|
|
23
23
|
cirq.X(q0) ** 0.5,
|
|
@@ -61,7 +61,7 @@ def test_optimize():
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def test_optimize_large_circuit():
|
|
64
|
+
def test_optimize_large_circuit() -> None:
|
|
65
65
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
66
66
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
67
67
|
|
|
@@ -79,7 +79,7 @@ def test_optimize_large_circuit():
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_repeat_limit():
|
|
82
|
+
def test_repeat_limit() -> None:
|
|
83
83
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
84
84
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
85
85
|
|
|
@@ -16,7 +16,7 @@ import cirq
|
|
|
16
16
|
from cirq.contrib.paulistring import convert_and_separate_circuit, pauli_string_dag_from_circuit
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_pauli_string_dag_from_circuit():
|
|
19
|
+
def test_pauli_string_dag_from_circuit() -> None:
|
|
20
20
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
21
21
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
22
22
|
c_left, _ = convert_and_separate_circuit(c_orig)
|
|
@@ -16,7 +16,7 @@ import cirq
|
|
|
16
16
|
from cirq.contrib.paulistring import CliffordTargetGateset, pauli_string_optimized_circuit
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_optimize():
|
|
19
|
+
def test_optimize() -> None:
|
|
20
20
|
q0, q1 = cirq.LineQubit.range(2)
|
|
21
21
|
c_orig = cirq.Circuit(
|
|
22
22
|
cirq.X(q0) ** 0.25, cirq.H(q0), cirq.CZ(q0, q1), cirq.H(q0), cirq.X(q0) ** 0.125
|
|
@@ -50,7 +50,7 @@ def test_optimize():
|
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def test_handles_measurement_gate():
|
|
53
|
+
def test_handles_measurement_gate() -> None:
|
|
54
54
|
q0, q1 = cirq.LineQubit.range(2)
|
|
55
55
|
c_orig = cirq.Circuit(
|
|
56
56
|
cirq.X(q0) ** 0.25,
|
|
@@ -75,7 +75,7 @@ def test_handles_measurement_gate():
|
|
|
75
75
|
)
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def test_optimize_large_circuit():
|
|
78
|
+
def test_optimize_large_circuit() -> None:
|
|
79
79
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
80
80
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
81
81
|
|
|
@@ -26,7 +26,7 @@ def _assert_no_multi_qubit_pauli_strings(circuit: cirq.Circuit) -> None:
|
|
|
26
26
|
assert len(op.pauli_string) == 1 # pragma: no cover
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def test_move_non_clifford_into_clifford():
|
|
29
|
+
def test_move_non_clifford_into_clifford() -> None:
|
|
30
30
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
31
31
|
c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
32
32
|
|
|
@@ -16,7 +16,7 @@ import cirq
|
|
|
16
16
|
from cirq.contrib.paulistring import convert_and_separate_circuit
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_toffoli_separate():
|
|
19
|
+
def test_toffoli_separate() -> None:
|
|
20
20
|
q0, q1, q2 = cirq.LineQubit.range(3)
|
|
21
21
|
circuit = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
|
|
22
22
|
|