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
|
@@ -56,7 +56,7 @@ def assert_optimization_not_broken(circuit: cirq.Circuit):
|
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def test_convert_to_cz_preserving_moment_structure():
|
|
59
|
+
def test_convert_to_cz_preserving_moment_structure() -> None:
|
|
60
60
|
q = cirq.LineQubit.range(5)
|
|
61
61
|
op = lambda q0, q1: cirq.H(q1).controlled_by(q0)
|
|
62
62
|
c_orig = cirq.Circuit(
|
|
@@ -100,7 +100,7 @@ def test_convert_to_cz_preserving_moment_structure():
|
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
def test_clears_paired_cnot():
|
|
103
|
+
def test_clears_paired_cnot() -> None:
|
|
104
104
|
a, b = cirq.LineQubit.range(2)
|
|
105
105
|
assert_optimizes(
|
|
106
106
|
before=cirq.Circuit(cirq.Moment(cirq.CNOT(a, b)), cirq.Moment(cirq.CNOT(a, b))),
|
|
@@ -108,7 +108,7 @@ def test_clears_paired_cnot():
|
|
|
108
108
|
)
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def test_ignores_czs_separated_by_parameterized():
|
|
111
|
+
def test_ignores_czs_separated_by_parameterized() -> None:
|
|
112
112
|
a, b = cirq.LineQubit.range(2)
|
|
113
113
|
assert_optimizes(
|
|
114
114
|
before=cirq.Circuit(
|
|
@@ -129,19 +129,19 @@ def test_ignores_czs_separated_by_parameterized():
|
|
|
129
129
|
)
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
def test_cnots_separated_by_single_gates_correct():
|
|
132
|
+
def test_cnots_separated_by_single_gates_correct() -> None:
|
|
133
133
|
a, b = cirq.LineQubit.range(2)
|
|
134
134
|
assert_optimization_not_broken(cirq.Circuit(cirq.CNOT(a, b), cirq.H(b), cirq.CNOT(a, b)))
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def test_czs_separated_by_single_gates_correct():
|
|
137
|
+
def test_czs_separated_by_single_gates_correct() -> None:
|
|
138
138
|
a, b = cirq.LineQubit.range(2)
|
|
139
139
|
assert_optimization_not_broken(
|
|
140
140
|
cirq.Circuit(cirq.CZ(a, b), cirq.X(b), cirq.X(b), cirq.X(b), cirq.CZ(a, b))
|
|
141
141
|
)
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
def test_inefficient_circuit_correct():
|
|
144
|
+
def test_inefficient_circuit_correct() -> None:
|
|
145
145
|
t = 0.1
|
|
146
146
|
v = 0.11
|
|
147
147
|
a, b = cirq.LineQubit.range(2)
|
|
@@ -166,7 +166,7 @@ def test_inefficient_circuit_correct():
|
|
|
166
166
|
)
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
def test_optimizes_single_iswap():
|
|
169
|
+
def test_optimizes_single_iswap() -> None:
|
|
170
170
|
a, b = cirq.LineQubit.range(2)
|
|
171
171
|
c = cirq.Circuit(cirq.ISWAP(a, b))
|
|
172
172
|
assert_optimization_not_broken(c)
|
|
@@ -174,7 +174,7 @@ def test_optimizes_single_iswap():
|
|
|
174
174
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 2
|
|
175
175
|
|
|
176
176
|
|
|
177
|
-
def test_optimizes_tagged_partial_cz():
|
|
177
|
+
def test_optimizes_tagged_partial_cz() -> None:
|
|
178
178
|
a, b = cirq.LineQubit.range(2)
|
|
179
179
|
c = cirq.Circuit((cirq.CZ**0.5)(a, b).with_tags('mytag'))
|
|
180
180
|
assert_optimization_not_broken(c)
|
|
@@ -184,7 +184,7 @@ def test_optimizes_tagged_partial_cz():
|
|
|
184
184
|
), 'It should take 2 CZ gates to decompose a CZ**0.5 gate'
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def test_not_decompose_czs():
|
|
187
|
+
def test_not_decompose_czs() -> None:
|
|
188
188
|
circuit = cirq.Circuit(
|
|
189
189
|
cirq.CZPowGate(exponent=1, global_shift=-0.5).on(*cirq.LineQubit.range(2))
|
|
190
190
|
)
|
|
@@ -201,7 +201,7 @@ def test_not_decompose_czs():
|
|
|
201
201
|
),
|
|
202
202
|
),
|
|
203
203
|
)
|
|
204
|
-
def test_decompose_partial_czs(circuit):
|
|
204
|
+
def test_decompose_partial_czs(circuit) -> None:
|
|
205
205
|
circuit = cirq.optimize_for_target_gateset(
|
|
206
206
|
circuit, gateset=cirq.CZTargetGateset(), ignore_failures=False
|
|
207
207
|
)
|
|
@@ -216,7 +216,7 @@ def test_decompose_partial_czs(circuit):
|
|
|
216
216
|
assert num_part_cz == 0
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
def test_not_decompose_partial_czs():
|
|
219
|
+
def test_not_decompose_partial_czs() -> None:
|
|
220
220
|
circuit = cirq.Circuit(
|
|
221
221
|
cirq.CZPowGate(exponent=0.1, global_shift=-0.5)(*cirq.LineQubit.range(2))
|
|
222
222
|
)
|
|
@@ -232,7 +232,7 @@ def test_not_decompose_partial_czs():
|
|
|
232
232
|
assert num_part_cz == 1
|
|
233
233
|
|
|
234
234
|
|
|
235
|
-
def test_avoids_decompose_when_matrix_available():
|
|
235
|
+
def test_avoids_decompose_when_matrix_available() -> None:
|
|
236
236
|
class OtherXX(cirq.testing.TwoQubitGate): # pragma: no cover
|
|
237
237
|
def _has_unitary_(self) -> bool:
|
|
238
238
|
return True
|
|
@@ -261,7 +261,7 @@ def test_avoids_decompose_when_matrix_available():
|
|
|
261
261
|
assert len(c) == 0
|
|
262
262
|
|
|
263
263
|
|
|
264
|
-
def test_composite_gates_without_matrix():
|
|
264
|
+
def test_composite_gates_without_matrix() -> None:
|
|
265
265
|
class CompositeExample(cirq.testing.SingleQubitGate):
|
|
266
266
|
def _decompose_(self, qubits):
|
|
267
267
|
yield cirq.X(qubits[0])
|
|
@@ -289,7 +289,7 @@ def test_composite_gates_without_matrix():
|
|
|
289
289
|
)
|
|
290
290
|
|
|
291
291
|
|
|
292
|
-
def test_unsupported_gate():
|
|
292
|
+
def test_unsupported_gate() -> None:
|
|
293
293
|
class UnsupportedExample(cirq.testing.TwoQubitGate):
|
|
294
294
|
pass
|
|
295
295
|
|
|
@@ -319,11 +319,11 @@ def test_unsupported_gate():
|
|
|
319
319
|
cirq.CZTargetGateset(additional_gates=()),
|
|
320
320
|
],
|
|
321
321
|
)
|
|
322
|
-
def test_repr(gateset):
|
|
322
|
+
def test_repr(gateset) -> None:
|
|
323
323
|
cirq.testing.assert_equivalent_repr(gateset)
|
|
324
324
|
|
|
325
325
|
|
|
326
|
-
def test_with_commutation():
|
|
326
|
+
def test_with_commutation() -> None:
|
|
327
327
|
c = cirq.Circuit(
|
|
328
328
|
cirq.CZ(cirq.q(0), cirq.q(1)), cirq.CZ(cirq.q(1), cirq.q(2)), cirq.CZ(cirq.q(0), cirq.q(1))
|
|
329
329
|
)
|
|
@@ -335,7 +335,7 @@ def test_with_commutation():
|
|
|
335
335
|
assert got == cirq.Circuit(cirq.CZ(cirq.q(1), cirq.q(2)))
|
|
336
336
|
|
|
337
337
|
|
|
338
|
-
def test_reorder_operations_and_preserve_moment_structure_raises():
|
|
338
|
+
def test_reorder_operations_and_preserve_moment_structure_raises() -> None:
|
|
339
339
|
with pytest.raises(
|
|
340
340
|
ValueError, match='reorder_operations and preserve_moment_structure can not both be True'
|
|
341
341
|
):
|
|
@@ -60,7 +60,7 @@ def assert_optimization_not_broken(
|
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def test_convert_to_sqrt_iswap_preserving_moment_structure():
|
|
63
|
+
def test_convert_to_sqrt_iswap_preserving_moment_structure() -> None:
|
|
64
64
|
q = cirq.LineQubit.range(5)
|
|
65
65
|
op = lambda q0, q1: cirq.H(q1).controlled_by(q0)
|
|
66
66
|
c_orig = cirq.Circuit(
|
|
@@ -112,7 +112,7 @@ def test_convert_to_sqrt_iswap_preserving_moment_structure():
|
|
|
112
112
|
],
|
|
113
113
|
)
|
|
114
114
|
@pytest.mark.parametrize('use_sqrt_iswap_inv', [True, False])
|
|
115
|
-
def test_two_qubit_gates_with_symbols(gate: cirq.Gate, use_sqrt_iswap_inv: bool):
|
|
115
|
+
def test_two_qubit_gates_with_symbols(gate: cirq.Gate, use_sqrt_iswap_inv: bool) -> None:
|
|
116
116
|
# Note that even though these gates are not natively supported by
|
|
117
117
|
# `cirq.parameterized_2q_op_to_sqrt_iswap_operations`, the transformation succeeds because
|
|
118
118
|
# `cirq.optimize_for_target_gateset` also relies on `cirq.decompose` as a fallback.
|
|
@@ -142,12 +142,12 @@ def test_two_qubit_gates_with_symbols(gate: cirq.Gate, use_sqrt_iswap_inv: bool)
|
|
|
142
142
|
)
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
def test_sqrt_iswap_gateset_raises():
|
|
145
|
+
def test_sqrt_iswap_gateset_raises() -> None:
|
|
146
146
|
with pytest.raises(ValueError, match="`required_sqrt_iswap_count` must be 0, 1, 2, or 3"):
|
|
147
147
|
_ = cirq.SqrtIswapTargetGateset(required_sqrt_iswap_count=4)
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
def test_sqrt_iswap_gateset_eq():
|
|
150
|
+
def test_sqrt_iswap_gateset_eq() -> None:
|
|
151
151
|
eq = cirq.testing.EqualsTester()
|
|
152
152
|
eq.add_equality_group(
|
|
153
153
|
cirq.SqrtIswapTargetGateset(), cirq.SqrtIswapTargetGateset(use_sqrt_iswap_inv=False)
|
|
@@ -179,11 +179,11 @@ def test_sqrt_iswap_gateset_eq():
|
|
|
179
179
|
cirq.SqrtIswapTargetGateset(additional_gates=()),
|
|
180
180
|
],
|
|
181
181
|
)
|
|
182
|
-
def test_sqrt_iswap_gateset_repr(gateset):
|
|
182
|
+
def test_sqrt_iswap_gateset_repr(gateset) -> None:
|
|
183
183
|
cirq.testing.assert_equivalent_repr(gateset)
|
|
184
184
|
|
|
185
185
|
|
|
186
|
-
def test_simplifies_sqrt_iswap():
|
|
186
|
+
def test_simplifies_sqrt_iswap() -> None:
|
|
187
187
|
a, b = cirq.LineQubit.range(2)
|
|
188
188
|
assert_optimizes(
|
|
189
189
|
before=cirq.Circuit(
|
|
@@ -204,7 +204,7 @@ def test_simplifies_sqrt_iswap():
|
|
|
204
204
|
)
|
|
205
205
|
|
|
206
206
|
|
|
207
|
-
def test_simplifies_sqrt_iswap_inv():
|
|
207
|
+
def test_simplifies_sqrt_iswap_inv() -> None:
|
|
208
208
|
a, b = cirq.LineQubit.range(2)
|
|
209
209
|
assert_optimizes(
|
|
210
210
|
use_sqrt_iswap_inv=True,
|
|
@@ -226,7 +226,7 @@ def test_simplifies_sqrt_iswap_inv():
|
|
|
226
226
|
)
|
|
227
227
|
|
|
228
228
|
|
|
229
|
-
def test_works_with_tags():
|
|
229
|
+
def test_works_with_tags() -> None:
|
|
230
230
|
a, b = cirq.LineQubit.range(2)
|
|
231
231
|
assert_optimizes(
|
|
232
232
|
before=cirq.Circuit(
|
|
@@ -240,7 +240,7 @@ def test_works_with_tags():
|
|
|
240
240
|
)
|
|
241
241
|
|
|
242
242
|
|
|
243
|
-
def test_no_touch_single_sqrt_iswap():
|
|
243
|
+
def test_no_touch_single_sqrt_iswap() -> None:
|
|
244
244
|
a, b = cirq.LineQubit.range(2)
|
|
245
245
|
circuit = cirq.Circuit(
|
|
246
246
|
[
|
|
@@ -252,7 +252,7 @@ def test_no_touch_single_sqrt_iswap():
|
|
|
252
252
|
assert_optimizes(before=circuit, expected=circuit)
|
|
253
253
|
|
|
254
254
|
|
|
255
|
-
def test_no_touch_single_sqrt_iswap_inv():
|
|
255
|
+
def test_no_touch_single_sqrt_iswap_inv() -> None:
|
|
256
256
|
a, b = cirq.LineQubit.range(2)
|
|
257
257
|
circuit = cirq.Circuit(
|
|
258
258
|
[
|
|
@@ -264,19 +264,19 @@ def test_no_touch_single_sqrt_iswap_inv():
|
|
|
264
264
|
assert_optimizes(before=circuit, expected=circuit, use_sqrt_iswap_inv=True)
|
|
265
265
|
|
|
266
266
|
|
|
267
|
-
def test_cnots_separated_by_single_gates_correct():
|
|
267
|
+
def test_cnots_separated_by_single_gates_correct() -> None:
|
|
268
268
|
a, b = cirq.LineQubit.range(2)
|
|
269
269
|
assert_optimization_not_broken(cirq.Circuit(cirq.CNOT(a, b), cirq.H(b), cirq.CNOT(a, b)))
|
|
270
270
|
|
|
271
271
|
|
|
272
|
-
def test_czs_separated_by_single_gates_correct():
|
|
272
|
+
def test_czs_separated_by_single_gates_correct() -> None:
|
|
273
273
|
a, b = cirq.LineQubit.range(2)
|
|
274
274
|
assert_optimization_not_broken(
|
|
275
275
|
cirq.Circuit(cirq.CZ(a, b), cirq.X(b), cirq.X(b), cirq.X(b), cirq.CZ(a, b))
|
|
276
276
|
)
|
|
277
277
|
|
|
278
278
|
|
|
279
|
-
def test_inefficient_circuit_correct():
|
|
279
|
+
def test_inefficient_circuit_correct() -> None:
|
|
280
280
|
t = 0.1
|
|
281
281
|
v = 0.11
|
|
282
282
|
a, b = cirq.LineQubit.range(2)
|
|
@@ -301,7 +301,7 @@ def test_inefficient_circuit_correct():
|
|
|
301
301
|
)
|
|
302
302
|
|
|
303
303
|
|
|
304
|
-
def test_optimizes_single_iswap():
|
|
304
|
+
def test_optimizes_single_iswap() -> None:
|
|
305
305
|
a, b = cirq.LineQubit.range(2)
|
|
306
306
|
c = cirq.Circuit(cirq.ISWAP(a, b))
|
|
307
307
|
assert_optimization_not_broken(c)
|
|
@@ -311,7 +311,7 @@ def test_optimizes_single_iswap():
|
|
|
311
311
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 2
|
|
312
312
|
|
|
313
313
|
|
|
314
|
-
def test_optimizes_single_inv_sqrt_iswap():
|
|
314
|
+
def test_optimizes_single_inv_sqrt_iswap() -> None:
|
|
315
315
|
a, b = cirq.LineQubit.range(2)
|
|
316
316
|
c = cirq.Circuit(cirq.SQRT_ISWAP_INV(a, b))
|
|
317
317
|
assert_optimization_not_broken(c)
|
|
@@ -321,7 +321,7 @@ def test_optimizes_single_inv_sqrt_iswap():
|
|
|
321
321
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 1
|
|
322
322
|
|
|
323
323
|
|
|
324
|
-
def test_optimizes_single_iswap_require0():
|
|
324
|
+
def test_optimizes_single_iswap_require0() -> None:
|
|
325
325
|
a, b = cirq.LineQubit.range(2)
|
|
326
326
|
c = cirq.Circuit(cirq.CNOT(a, b), cirq.CNOT(a, b)) # Minimum 0 sqrt-iSWAP
|
|
327
327
|
assert_optimization_not_broken(c, required_sqrt_iswap_count=0)
|
|
@@ -331,7 +331,7 @@ def test_optimizes_single_iswap_require0():
|
|
|
331
331
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 0
|
|
332
332
|
|
|
333
333
|
|
|
334
|
-
def test_optimizes_single_iswap_require0_raises():
|
|
334
|
+
def test_optimizes_single_iswap_require0_raises() -> None:
|
|
335
335
|
a, b = cirq.LineQubit.range(2)
|
|
336
336
|
c = cirq.Circuit(cirq.CNOT(a, b)) # Minimum 2 sqrt-iSWAP
|
|
337
337
|
with pytest.raises(ValueError, match='cannot be decomposed into exactly 0 sqrt-iSWAP gates'):
|
|
@@ -342,7 +342,7 @@ def test_optimizes_single_iswap_require0_raises():
|
|
|
342
342
|
)
|
|
343
343
|
|
|
344
344
|
|
|
345
|
-
def test_optimizes_single_iswap_require1():
|
|
345
|
+
def test_optimizes_single_iswap_require1() -> None:
|
|
346
346
|
a, b = cirq.LineQubit.range(2)
|
|
347
347
|
c = cirq.Circuit(cirq.SQRT_ISWAP_INV(a, b)) # Minimum 1 sqrt-iSWAP
|
|
348
348
|
assert_optimization_not_broken(c, required_sqrt_iswap_count=1)
|
|
@@ -352,7 +352,7 @@ def test_optimizes_single_iswap_require1():
|
|
|
352
352
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 1
|
|
353
353
|
|
|
354
354
|
|
|
355
|
-
def test_optimizes_single_iswap_require1_raises():
|
|
355
|
+
def test_optimizes_single_iswap_require1_raises() -> None:
|
|
356
356
|
a, b = cirq.LineQubit.range(2)
|
|
357
357
|
c = cirq.Circuit(cirq.CNOT(a, b)) # Minimum 2 sqrt-iSWAP
|
|
358
358
|
with pytest.raises(ValueError, match='cannot be decomposed into exactly 1 sqrt-iSWAP gates'):
|
|
@@ -363,7 +363,7 @@ def test_optimizes_single_iswap_require1_raises():
|
|
|
363
363
|
)
|
|
364
364
|
|
|
365
365
|
|
|
366
|
-
def test_optimizes_single_iswap_require2():
|
|
366
|
+
def test_optimizes_single_iswap_require2() -> None:
|
|
367
367
|
a, b = cirq.LineQubit.range(2)
|
|
368
368
|
c = cirq.Circuit(cirq.SQRT_ISWAP_INV(a, b)) # Minimum 1 sqrt-iSWAP but 2 possible
|
|
369
369
|
assert_optimization_not_broken(c, required_sqrt_iswap_count=2)
|
|
@@ -373,7 +373,7 @@ def test_optimizes_single_iswap_require2():
|
|
|
373
373
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 2
|
|
374
374
|
|
|
375
375
|
|
|
376
|
-
def test_optimizes_single_iswap_require2_raises():
|
|
376
|
+
def test_optimizes_single_iswap_require2_raises() -> None:
|
|
377
377
|
a, b = cirq.LineQubit.range(2)
|
|
378
378
|
c = cirq.Circuit(cirq.SWAP(a, b)) # Minimum 3 sqrt-iSWAP
|
|
379
379
|
with pytest.raises(ValueError, match='cannot be decomposed into exactly 2 sqrt-iSWAP gates'):
|
|
@@ -384,7 +384,7 @@ def test_optimizes_single_iswap_require2_raises():
|
|
|
384
384
|
)
|
|
385
385
|
|
|
386
386
|
|
|
387
|
-
def test_optimizes_single_iswap_require3():
|
|
387
|
+
def test_optimizes_single_iswap_require3() -> None:
|
|
388
388
|
a, b = cirq.LineQubit.range(2)
|
|
389
389
|
c = cirq.Circuit(cirq.ISWAP(a, b)) # Minimum 2 sqrt-iSWAP but 3 possible
|
|
390
390
|
assert_optimization_not_broken(c, required_sqrt_iswap_count=3)
|
|
@@ -394,7 +394,7 @@ def test_optimizes_single_iswap_require3():
|
|
|
394
394
|
assert len([1 for op in c.all_operations() if len(op.qubits) == 2]) == 3
|
|
395
395
|
|
|
396
396
|
|
|
397
|
-
def test_optimizes_single_inv_sqrt_iswap_require3():
|
|
397
|
+
def test_optimizes_single_inv_sqrt_iswap_require3() -> None:
|
|
398
398
|
a, b = cirq.LineQubit.range(2)
|
|
399
399
|
c = cirq.Circuit(cirq.SQRT_ISWAP_INV(a, b))
|
|
400
400
|
assert_optimization_not_broken(c, required_sqrt_iswap_count=3)
|
cirq/value/angle_test.py
CHANGED
|
@@ -19,7 +19,7 @@ import sympy
|
|
|
19
19
|
import cirq
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def test_canonicalize_half_turns():
|
|
22
|
+
def test_canonicalize_half_turns() -> None:
|
|
23
23
|
assert cirq.canonicalize_half_turns(0) == 0
|
|
24
24
|
assert cirq.canonicalize_half_turns(1) == +1
|
|
25
25
|
assert cirq.canonicalize_half_turns(-1) == +1
|
|
@@ -34,7 +34,7 @@ def test_canonicalize_half_turns():
|
|
|
34
34
|
assert cirq.canonicalize_half_turns(sympy.Symbol('a') * 0 + 3) == 1
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_chosen_angle_to_half_turns():
|
|
37
|
+
def test_chosen_angle_to_half_turns() -> None:
|
|
38
38
|
assert cirq.chosen_angle_to_half_turns() == 1
|
|
39
39
|
assert cirq.chosen_angle_to_half_turns(default=0.5) == 0.5
|
|
40
40
|
assert cirq.chosen_angle_to_half_turns(half_turns=0.25, default=0.75) == 0.25
|
|
@@ -54,7 +54,7 @@ def test_chosen_angle_to_half_turns():
|
|
|
54
54
|
_ = cirq.chosen_angle_to_half_turns(half_turns=0, rads=0, degs=0)
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_chosen_angle_to_canonical_half_turns():
|
|
57
|
+
def test_chosen_angle_to_canonical_half_turns() -> None:
|
|
58
58
|
assert cirq.chosen_angle_to_canonical_half_turns() == 1
|
|
59
59
|
assert cirq.chosen_angle_to_canonical_half_turns(default=0.5) == 0.5
|
|
60
60
|
assert cirq.chosen_angle_to_canonical_half_turns(half_turns=0.25, default=0.75) == 0.25
|
|
@@ -22,7 +22,7 @@ mkey_c = cirq.MeasurementKey('c')
|
|
|
22
22
|
two_qubits = tuple(cirq.LineQubit.range(2))
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def test_init():
|
|
25
|
+
def test_init() -> None:
|
|
26
26
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
27
27
|
assert cd.records == {}
|
|
28
28
|
assert cd.keys() == ()
|
|
@@ -44,7 +44,7 @@ def test_init():
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
def test_record_measurement():
|
|
47
|
+
def test_record_measurement() -> None:
|
|
48
48
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
49
49
|
cd.record_measurement(mkey_m, (0, 1), two_qubits)
|
|
50
50
|
assert cd.records == {mkey_m: [(0, 1)]}
|
|
@@ -52,7 +52,7 @@ def test_record_measurement():
|
|
|
52
52
|
assert cd.measured_qubits == {mkey_m: [two_qubits]}
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def test_record_measurement_errors():
|
|
55
|
+
def test_record_measurement_errors() -> None:
|
|
56
56
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
57
57
|
with pytest.raises(ValueError, match='3 measurements but 2 qubits'):
|
|
58
58
|
cd.record_measurement(mkey_m, (0, 1, 2), two_qubits)
|
|
@@ -68,14 +68,14 @@ def test_record_measurement_errors():
|
|
|
68
68
|
cd.record_measurement(mkey_m, (1, 0), tuple(cirq.LineQid.range(2, dimension=3)))
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def test_record_channel_measurement():
|
|
71
|
+
def test_record_channel_measurement() -> None:
|
|
72
72
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
73
73
|
cd.record_channel_measurement(mkey_m, 1)
|
|
74
74
|
assert cd.channel_records == {mkey_m: [1]}
|
|
75
75
|
assert cd.keys() == (mkey_m,)
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def test_record_channel_measurement_errors():
|
|
78
|
+
def test_record_channel_measurement_errors() -> None:
|
|
79
79
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
80
80
|
cd.record_channel_measurement(mkey_m, 1)
|
|
81
81
|
cd.record_channel_measurement(mkey_m, 1)
|
|
@@ -88,7 +88,7 @@ def test_record_channel_measurement_errors():
|
|
|
88
88
|
cd.record_channel_measurement(mkey_m, 1)
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def test_get_int():
|
|
91
|
+
def test_get_int() -> None:
|
|
92
92
|
cd = cirq.ClassicalDataDictionaryStore()
|
|
93
93
|
cd.record_measurement(mkey_m, (0, 1), two_qubits)
|
|
94
94
|
assert cd.get_int(mkey_m) == 1
|
|
@@ -106,7 +106,7 @@ def test_get_int():
|
|
|
106
106
|
cd.get_int(mkey_m)
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def test_copy():
|
|
109
|
+
def test_copy() -> None:
|
|
110
110
|
cd = cirq.ClassicalDataDictionaryStore(
|
|
111
111
|
_records={mkey_m: [(0, 1)]},
|
|
112
112
|
_measured_qubits={mkey_m: [two_qubits]},
|
|
@@ -129,7 +129,7 @@ def test_copy():
|
|
|
129
129
|
assert cd1.measurement_types == cd.measurement_types
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
def test_repr():
|
|
132
|
+
def test_repr() -> None:
|
|
133
133
|
cd = cirq.ClassicalDataDictionaryStore(
|
|
134
134
|
_records={mkey_m: [(0, 1)]},
|
|
135
135
|
_measured_qubits={mkey_m: [two_qubits]},
|
|
@@ -18,7 +18,7 @@ import sympy
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_periodic_value_equality():
|
|
21
|
+
def test_periodic_value_equality() -> None:
|
|
22
22
|
eq = cirq.testing.EqualsTester()
|
|
23
23
|
eq.add_equality_group(
|
|
24
24
|
cirq.PeriodicValue(1, 2),
|
|
@@ -34,7 +34,7 @@ def test_periodic_value_equality():
|
|
|
34
34
|
eq.add_equality_group(cirq.PeriodicValue(2, 4))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_periodic_value_approx_eq_basic():
|
|
37
|
+
def test_periodic_value_approx_eq_basic() -> None:
|
|
38
38
|
assert cirq.approx_eq(cirq.PeriodicValue(1.0, 2.0), cirq.PeriodicValue(1.0, 2.0), atol=0.1)
|
|
39
39
|
assert cirq.approx_eq(cirq.PeriodicValue(1.0, 2.0), cirq.PeriodicValue(1.2, 2.0), atol=0.3)
|
|
40
40
|
assert not cirq.approx_eq(cirq.PeriodicValue(1.0, 2.0), cirq.PeriodicValue(1.2, 2.0), atol=0.1)
|
|
@@ -49,12 +49,12 @@ def test_periodic_value_approx_eq_basic():
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def test_periodic_value_approx_eq_normalized():
|
|
52
|
+
def test_periodic_value_approx_eq_normalized() -> None:
|
|
53
53
|
assert cirq.approx_eq(cirq.PeriodicValue(1.0, 3.0), cirq.PeriodicValue(4.1, 3.0), atol=0.2)
|
|
54
54
|
assert cirq.approx_eq(cirq.PeriodicValue(1.0, 3.0), cirq.PeriodicValue(-2.1, 3.0), atol=0.2)
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_periodic_value_approx_eq_boundary():
|
|
57
|
+
def test_periodic_value_approx_eq_boundary() -> None:
|
|
58
58
|
assert cirq.approx_eq(cirq.PeriodicValue(0.0, 2.0), cirq.PeriodicValue(1.9, 2.0), atol=0.2)
|
|
59
59
|
assert cirq.approx_eq(cirq.PeriodicValue(0.1, 2.0), cirq.PeriodicValue(1.9, 2.0), atol=0.3)
|
|
60
60
|
assert cirq.approx_eq(cirq.PeriodicValue(1.9, 2.0), cirq.PeriodicValue(0.1, 2.0), atol=0.3)
|
|
@@ -64,7 +64,7 @@ def test_periodic_value_approx_eq_boundary():
|
|
|
64
64
|
assert cirq.approx_eq(cirq.PeriodicValue(0.4, 1.0), cirq.PeriodicValue(0.6, 1.0), atol=0.3)
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
def test_periodic_value_types_mismatch():
|
|
67
|
+
def test_periodic_value_types_mismatch() -> None:
|
|
68
68
|
assert not cirq.approx_eq(cirq.PeriodicValue(0.0, 2.0), 0.0, atol=0.2)
|
|
69
69
|
assert not cirq.approx_eq(0.0, cirq.PeriodicValue(0.0, 2.0), atol=0.2)
|
|
70
70
|
|
|
@@ -79,7 +79,9 @@ def test_periodic_value_types_mismatch():
|
|
|
79
79
|
],
|
|
80
80
|
)
|
|
81
81
|
@pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
|
|
82
|
-
def test_periodic_value_is_parameterized(
|
|
82
|
+
def test_periodic_value_is_parameterized(
|
|
83
|
+
value, is_parameterized, parameter_names, resolve_fn
|
|
84
|
+
) -> None:
|
|
83
85
|
assert cirq.is_parameterized(value) == is_parameterized
|
|
84
86
|
assert cirq.parameter_names(value) == parameter_names
|
|
85
87
|
resolved = resolve_fn(value, {p: 1 for p in parameter_names})
|
|
@@ -98,5 +100,5 @@ def test_periodic_value_is_parameterized(value, is_parameterized, parameter_name
|
|
|
98
100
|
cirq.PeriodicValue(sympy.Symbol('v'), 3),
|
|
99
101
|
],
|
|
100
102
|
)
|
|
101
|
-
def test_periodic_value_repr(val):
|
|
103
|
+
def test_periodic_value_repr(val) -> None:
|
|
102
104
|
cirq.testing.assert_equivalent_repr(val)
|
cirq/value/probability_test.py
CHANGED
|
@@ -18,11 +18,11 @@ import cirq
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@pytest.mark.parametrize('p', [0.0, 0.1, 0.6, 1.0])
|
|
21
|
-
def test_validate_probability_valid(p):
|
|
21
|
+
def test_validate_probability_valid(p) -> None:
|
|
22
22
|
assert p == cirq.validate_probability(p, 'p')
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
@pytest.mark.parametrize('p', [-0.1, 1.1])
|
|
26
|
-
def test_validate_probability_invalid(p):
|
|
26
|
+
def test_validate_probability_invalid(p) -> None:
|
|
27
27
|
with pytest.raises(ValueError, match='p'):
|
|
28
28
|
cirq.validate_probability(p, 'p')
|
|
@@ -54,7 +54,7 @@ class BasicCb(BasicC):
|
|
|
54
54
|
pass
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_value_equality_basic():
|
|
57
|
+
def test_value_equality_basic() -> None:
|
|
58
58
|
|
|
59
59
|
# Lookup works across equivalent types.
|
|
60
60
|
v = {BasicC(1): 4, BasicCa(2): 5}
|
|
@@ -69,7 +69,7 @@ def test_value_equality_basic():
|
|
|
69
69
|
eq.add_equality_group(BasicCa(3))
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def test_value_equality_manual():
|
|
72
|
+
def test_value_equality_manual() -> None:
|
|
73
73
|
eq = cirq.testing.EqualsTester()
|
|
74
74
|
eq.add_equality_group(MasqueradePositiveD(3), BasicD(3))
|
|
75
75
|
eq.add_equality_group(MasqueradePositiveD(4), MasqueradePositiveD(4), BasicD(4))
|
|
@@ -105,7 +105,7 @@ class UnhashableCb(UnhashableC):
|
|
|
105
105
|
pass
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
def test_value_equality_unhashable():
|
|
108
|
+
def test_value_equality_unhashable() -> None:
|
|
109
109
|
# Not possible to use as a dictionary key.
|
|
110
110
|
with pytest.raises(TypeError, match='unhashable'):
|
|
111
111
|
_ = {UnhashableC(1): 4}
|
|
@@ -143,7 +143,7 @@ class DistinctCb(DistinctC):
|
|
|
143
143
|
pass
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
def test_value_equality_distinct_child_types():
|
|
146
|
+
def test_value_equality_distinct_child_types() -> None:
|
|
147
147
|
# Lookup is distinct across child types.
|
|
148
148
|
v = {DistinctC(1): 4, DistinctCa(1): 5, DistinctCb(1): 6}
|
|
149
149
|
assert v[DistinctC(1)] == 4
|
|
@@ -168,7 +168,7 @@ class ApproxE:
|
|
|
168
168
|
return self.x
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
def test_value_equality_approximate():
|
|
171
|
+
def test_value_equality_approximate() -> None:
|
|
172
172
|
assert cirq.approx_eq(ApproxE(0.0), ApproxE(0.0), atol=0.1)
|
|
173
173
|
assert cirq.approx_eq(ApproxE(0.0), ApproxE(0.2), atol=0.3)
|
|
174
174
|
assert not cirq.approx_eq(ApproxE(0.0), ApproxE(0.2), atol=0.1)
|
|
@@ -187,13 +187,13 @@ class PeriodicF:
|
|
|
187
187
|
return self.x % self.n
|
|
188
188
|
|
|
189
189
|
|
|
190
|
-
def test_value_equality_approximate_specialized():
|
|
190
|
+
def test_value_equality_approximate_specialized() -> None:
|
|
191
191
|
assert PeriodicF(1, 4) != PeriodicF(5, 4)
|
|
192
192
|
assert cirq.approx_eq(PeriodicF(1, 4), PeriodicF(5, 4), atol=0.1)
|
|
193
193
|
assert not cirq.approx_eq(PeriodicF(1, 4), PeriodicF(6, 4), atol=0.1)
|
|
194
194
|
|
|
195
195
|
|
|
196
|
-
def test_value_equality_approximate_not_supported():
|
|
196
|
+
def test_value_equality_approximate_not_supported() -> None:
|
|
197
197
|
assert not cirq.approx_eq(BasicC(0.0), BasicC(0.1), atol=0.2)
|
|
198
198
|
|
|
199
199
|
|
|
@@ -222,7 +222,7 @@ class ApproxGb(ApproxG):
|
|
|
222
222
|
pass
|
|
223
223
|
|
|
224
224
|
|
|
225
|
-
def test_value_equality_approximate_typing():
|
|
225
|
+
def test_value_equality_approximate_typing() -> None:
|
|
226
226
|
assert not cirq.approx_eq(ApproxE(0.0), PeriodicF(0.0, 1.0), atol=0.1)
|
|
227
227
|
assert cirq.approx_eq(ApproxEa(0.0), ApproxEb(0.0), atol=0.1)
|
|
228
228
|
assert cirq.approx_eq(ApproxG(0.0), ApproxG(0.0), atol=0.1)
|
|
@@ -230,7 +230,7 @@ def test_value_equality_approximate_typing():
|
|
|
230
230
|
assert not cirq.approx_eq(ApproxG(0.0), ApproxGb(0.0), atol=0.1)
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
def test_value_equality_forgot_method():
|
|
233
|
+
def test_value_equality_forgot_method() -> None:
|
|
234
234
|
with pytest.raises(TypeError, match='_value_equality_values_'):
|
|
235
235
|
|
|
236
236
|
@cirq.value_equality
|
|
@@ -238,7 +238,7 @@ def test_value_equality_forgot_method():
|
|
|
238
238
|
pass
|
|
239
239
|
|
|
240
240
|
|
|
241
|
-
def test_bad_manual_cls_incompatible_args():
|
|
241
|
+
def test_bad_manual_cls_incompatible_args() -> None:
|
|
242
242
|
with pytest.raises(ValueError, match='incompatible'):
|
|
243
243
|
|
|
244
244
|
@cirq.value_equality(manual_cls=True, distinct_child_types=True)
|
|
@@ -246,7 +246,7 @@ def test_bad_manual_cls_incompatible_args():
|
|
|
246
246
|
pass
|
|
247
247
|
|
|
248
248
|
|
|
249
|
-
def test_bad_manual_cls_forgot_method():
|
|
249
|
+
def test_bad_manual_cls_forgot_method() -> None:
|
|
250
250
|
with pytest.raises(TypeError, match='_value_equality_values_cls_'):
|
|
251
251
|
|
|
252
252
|
@cirq.value_equality(manual_cls=True)
|
cirq/vis/histogram_test.py
CHANGED
|
@@ -22,7 +22,7 @@ from cirq.vis import integrated_histogram
|
|
|
22
22
|
|
|
23
23
|
@pytest.mark.usefixtures('closefigures')
|
|
24
24
|
@pytest.mark.parametrize('data', [range(10), {f'key_{i}': i for i in range(10)}])
|
|
25
|
-
def test_integrated_histogram(data):
|
|
25
|
+
def test_integrated_histogram(data) -> None:
|
|
26
26
|
ax = integrated_histogram(
|
|
27
27
|
data,
|
|
28
28
|
title='Test Plot',
|
|
@@ -40,7 +40,7 @@ def test_integrated_histogram(data):
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
@pytest.mark.usefixtures('closefigures')
|
|
43
|
-
def test_multiple_plots():
|
|
43
|
+
def test_multiple_plots() -> None:
|
|
44
44
|
_, ax = plt.subplots(1, 1)
|
|
45
45
|
n = 53
|
|
46
46
|
data = np.random.random_sample((2, n))
|
cirq/vis/state_histogram_test.py
CHANGED
|
@@ -24,7 +24,7 @@ from cirq.devices import GridQubit
|
|
|
24
24
|
from cirq.vis import state_histogram
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def test_get_state_histogram():
|
|
27
|
+
def test_get_state_histogram() -> None:
|
|
28
28
|
simulator = cirq.Simulator()
|
|
29
29
|
|
|
30
30
|
q0 = GridQubit(0, 0)
|
|
@@ -40,7 +40,7 @@ def test_get_state_histogram():
|
|
|
40
40
|
np.testing.assert_equal(values_to_plot, expected_values)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def test_get_state_histogram_multi_1():
|
|
43
|
+
def test_get_state_histogram_multi_1() -> None:
|
|
44
44
|
qubits = cirq.LineQubit.range(4)
|
|
45
45
|
c = cirq.Circuit(
|
|
46
46
|
cirq.X.on_each(*qubits[1:]), cirq.measure(*qubits) # One multi-qubit measurement
|
|
@@ -51,7 +51,7 @@ def test_get_state_histogram_multi_1():
|
|
|
51
51
|
np.testing.assert_equal(values_to_plot, expected_values)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def test_get_state_histogram_multi_2():
|
|
54
|
+
def test_get_state_histogram_multi_2() -> None:
|
|
55
55
|
qubits = cirq.LineQubit.range(4)
|
|
56
56
|
c = cirq.Circuit(
|
|
57
57
|
cirq.X.on_each(*qubits[1:]),
|
|
@@ -65,7 +65,7 @@ def test_get_state_histogram_multi_2():
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
@pytest.mark.usefixtures('closefigures')
|
|
68
|
-
def test_plot_state_histogram_result():
|
|
68
|
+
def test_plot_state_histogram_result() -> None:
|
|
69
69
|
qubits = cirq.LineQubit.range(4)
|
|
70
70
|
c = cirq.Circuit(
|
|
71
71
|
cirq.X.on_each(*qubits[1:]), cirq.measure(*qubits) # One multi-qubit measurement
|
|
@@ -83,7 +83,7 @@ def test_plot_state_histogram_result():
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
@pytest.mark.usefixtures('closefigures')
|
|
86
|
-
def test_plot_state_histogram_collection():
|
|
86
|
+
def test_plot_state_histogram_collection() -> None:
|
|
87
87
|
qubits = cirq.LineQubit.range(4)
|
|
88
88
|
c = cirq.Circuit(
|
|
89
89
|
cirq.X.on_each(*qubits[1:]), cirq.measure(*qubits) # One multi-qubit measurement
|
cirq/vis/vis_utils_test.py
CHANGED