cirq-core 1.6.0.dev20250508231110__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.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/RECORD +167 -167
- {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/WHEEL +1 -1
- {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/top_level.txt +0 -0
|
@@ -21,7 +21,7 @@ import pytest
|
|
|
21
21
|
import cirq
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def test_default_parameter():
|
|
24
|
+
def test_default_parameter() -> None:
|
|
25
25
|
dtype = np.complex64
|
|
26
26
|
tensor = cirq.one_hot(shape=(2, 2, 2), dtype=np.complex64)
|
|
27
27
|
qubits = cirq.LineQubit.range(3)
|
|
@@ -33,7 +33,7 @@ def test_default_parameter():
|
|
|
33
33
|
assert args.available_buffer.dtype == tensor.dtype
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def test_infer_target_tensor():
|
|
36
|
+
def test_infer_target_tensor() -> None:
|
|
37
37
|
dtype = np.complex64
|
|
38
38
|
args = cirq.StateVectorSimulationState(
|
|
39
39
|
qubits=cirq.LineQubit.range(2),
|
|
@@ -54,13 +54,13 @@ def test_infer_target_tensor():
|
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_shallow_copy_buffers():
|
|
57
|
+
def test_shallow_copy_buffers() -> None:
|
|
58
58
|
args = cirq.StateVectorSimulationState(qubits=cirq.LineQubit.range(1), initial_state=0)
|
|
59
59
|
copy = args.copy(deep_copy_buffers=False)
|
|
60
60
|
assert copy.available_buffer is args.available_buffer
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def test_decomposed_fallback():
|
|
63
|
+
def test_decomposed_fallback() -> None:
|
|
64
64
|
class Composite(cirq.Gate):
|
|
65
65
|
def num_qubits(self) -> int:
|
|
66
66
|
return 1 # pragma: no cover
|
|
@@ -82,7 +82,7 @@ def test_decomposed_fallback():
|
|
|
82
82
|
)
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
def test_cannot_act():
|
|
85
|
+
def test_cannot_act() -> None:
|
|
86
86
|
class NoDetails:
|
|
87
87
|
pass
|
|
88
88
|
|
|
@@ -98,7 +98,7 @@ def test_cannot_act():
|
|
|
98
98
|
cirq.act_on(NoDetails(), args, qubits=())
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_act_using_probabilistic_single_qubit_channel():
|
|
101
|
+
def test_act_using_probabilistic_single_qubit_channel() -> None:
|
|
102
102
|
class ProbabilisticSorX(cirq.Gate):
|
|
103
103
|
def num_qubits(self) -> int:
|
|
104
104
|
return 1
|
|
@@ -148,7 +148,7 @@ def test_act_using_probabilistic_single_qubit_channel():
|
|
|
148
148
|
)
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
def test_act_using_adaptive_two_qubit_channel():
|
|
151
|
+
def test_act_using_adaptive_two_qubit_channel() -> None:
|
|
152
152
|
class Decay11(cirq.Gate):
|
|
153
153
|
def num_qubits(self) -> int:
|
|
154
154
|
return 2
|
|
@@ -210,7 +210,7 @@ def test_act_using_adaptive_two_qubit_channel():
|
|
|
210
210
|
assert_not_affected(projected_state, sample=3 / 4 + 1e-8)
|
|
211
211
|
|
|
212
212
|
|
|
213
|
-
def test_probability_comes_up_short_results_in_fallback():
|
|
213
|
+
def test_probability_comes_up_short_results_in_fallback() -> None:
|
|
214
214
|
class Short(cirq.Gate):
|
|
215
215
|
def num_qubits(self) -> int:
|
|
216
216
|
return 1
|
|
@@ -234,7 +234,7 @@ def test_probability_comes_up_short_results_in_fallback():
|
|
|
234
234
|
np.testing.assert_allclose(args.target_tensor, np.array([0, 1]))
|
|
235
235
|
|
|
236
236
|
|
|
237
|
-
def test_random_channel_has_random_behavior():
|
|
237
|
+
def test_random_channel_has_random_behavior() -> None:
|
|
238
238
|
q = cirq.LineQubit(0)
|
|
239
239
|
s = cirq.Simulator().sample(
|
|
240
240
|
cirq.Circuit(cirq.X(q), cirq.amplitude_damp(0.4).on(q), cirq.measure(q, key='out')),
|
|
@@ -245,7 +245,7 @@ def test_random_channel_has_random_behavior():
|
|
|
245
245
|
assert v[1] > 1
|
|
246
246
|
|
|
247
247
|
|
|
248
|
-
def test_measured_channel():
|
|
248
|
+
def test_measured_channel() -> None:
|
|
249
249
|
# This behaves like an X-basis measurement.
|
|
250
250
|
kc = cirq.KrausChannel(
|
|
251
251
|
kraus_ops=(np.array([[1, 1], [1, 1]]) * 0.5, np.array([[1, -1], [-1, 1]]) * 0.5), key='m'
|
|
@@ -257,7 +257,7 @@ def test_measured_channel():
|
|
|
257
257
|
assert results.histogram(key='m') == {0: 100}
|
|
258
258
|
|
|
259
259
|
|
|
260
|
-
def test_measured_mixture():
|
|
260
|
+
def test_measured_mixture() -> None:
|
|
261
261
|
# This behaves like an X-basis measurement.
|
|
262
262
|
mm = cirq.MixedUnitaryChannel(
|
|
263
263
|
mixture=((0.5, np.array([[1, 0], [0, 1]])), (0.5, np.array([[0, 1], [1, 0]]))), key='flip'
|
|
@@ -269,6 +269,6 @@ def test_measured_mixture():
|
|
|
269
269
|
assert results.histogram(key='flip') == results.histogram(key='m')
|
|
270
270
|
|
|
271
271
|
|
|
272
|
-
def test_qid_shape_error():
|
|
272
|
+
def test_qid_shape_error() -> None:
|
|
273
273
|
with pytest.raises(ValueError, match="qid_shape must be provided"):
|
|
274
274
|
cirq.sim.state_vector_simulation_state._BufferedStateVector.create(initial_state=0)
|
|
@@ -23,14 +23,14 @@ from cirq.study import flatten_expressions
|
|
|
23
23
|
# factor, is not consistent between sympy versions <1.4 and >=1.4.
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
def test_expr_map_names():
|
|
26
|
+
def test_expr_map_names() -> None:
|
|
27
27
|
flattener = flatten_expressions._ParamFlattener({'collision': '<x + 2>'})
|
|
28
28
|
expressions = [sympy.Symbol('x') + i for i in range(3)]
|
|
29
29
|
syms = flattener.flatten(expressions)
|
|
30
30
|
assert syms == [sympy.Symbol(name) for name in ('x', '<x + 1>', '<x + 2>_1')]
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def test_flattener_value_of():
|
|
33
|
+
def test_flattener_value_of() -> None:
|
|
34
34
|
flattener = flatten_expressions._ParamFlattener({'c': 5, 'x1': 'x1'})
|
|
35
35
|
assert flattener.value_of(9) == 9
|
|
36
36
|
assert flattener.value_of('c') == 5
|
|
@@ -54,18 +54,18 @@ def test_flattener_value_of():
|
|
|
54
54
|
]
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def test_flattener_repr():
|
|
57
|
+
def test_flattener_repr() -> None:
|
|
58
58
|
assert repr(flatten_expressions._ParamFlattener({'a': 1})) == ("_ParamFlattener({a: 1})")
|
|
59
59
|
assert repr(
|
|
60
60
|
flatten_expressions._ParamFlattener({'a': 1}, get_param_name=lambda expr: 'x')
|
|
61
61
|
).startswith("_ParamFlattener({a: 1}, get_param_name=<function ")
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def test_expression_map_repr():
|
|
64
|
+
def test_expression_map_repr() -> None:
|
|
65
65
|
cirq.testing.assert_equivalent_repr(cirq.ExpressionMap({'a': 'b'}))
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def test_flatten_circuit():
|
|
68
|
+
def test_flatten_circuit() -> None:
|
|
69
69
|
qubit = cirq.LineQubit(0)
|
|
70
70
|
a = sympy.Symbol('a')
|
|
71
71
|
circuit = cirq.Circuit(cirq.X(qubit) ** a, cirq.X(qubit) ** (1 + a / 2))
|
|
@@ -78,7 +78,7 @@ def test_flatten_circuit():
|
|
|
78
78
|
assert expr_map == {a: a, 1 + a / 2: sympy.Symbol('<a/2 + 1>')}
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
def test_transform_params():
|
|
81
|
+
def test_transform_params() -> None:
|
|
82
82
|
qubit = cirq.LineQubit(0)
|
|
83
83
|
a = sympy.Symbol('a')
|
|
84
84
|
circuit = cirq.Circuit(cirq.X(qubit) ** (a / 4), cirq.X(qubit) ** (1 + a / 2))
|
|
@@ -90,7 +90,7 @@ def test_transform_params():
|
|
|
90
90
|
assert new_params == expected_params
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
def test_transform_sweep():
|
|
93
|
+
def test_transform_sweep() -> None:
|
|
94
94
|
qubit = cirq.LineQubit(0)
|
|
95
95
|
a = sympy.Symbol('a')
|
|
96
96
|
circuit = cirq.Circuit(cirq.X(qubit) ** (a / 4), cirq.X(qubit) ** (1 + a / 2))
|
|
@@ -109,20 +109,20 @@ def test_transform_sweep():
|
|
|
109
109
|
assert resolvers == expected_resolvers
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
def test_flattener_new():
|
|
112
|
+
def test_flattener_new() -> None:
|
|
113
113
|
flattener = flatten_expressions._ParamFlattener({'a': 'b'})
|
|
114
114
|
flattener2 = flatten_expressions._ParamFlattener(flattener)
|
|
115
115
|
assert isinstance(flattener2, flatten_expressions._ParamFlattener)
|
|
116
116
|
assert flattener2.param_dict == flattener.param_dict
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
def test_resolver_new():
|
|
119
|
+
def test_resolver_new() -> None:
|
|
120
120
|
flattener = flatten_expressions._ParamFlattener({'a': 'b'})
|
|
121
121
|
flattener2 = cirq.ParamResolver(flattener)
|
|
122
122
|
assert flattener2 is flattener
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
def test_transformed_sweep():
|
|
125
|
+
def test_transformed_sweep() -> None:
|
|
126
126
|
a = sympy.Symbol('a')
|
|
127
127
|
sweep = cirq.Linspace('a', start=0, stop=3, length=4)
|
|
128
128
|
expr_map = cirq.ExpressionMap({a / 4: 'x0', 1 - a / 2: 'x1'})
|
|
@@ -134,7 +134,7 @@ def test_transformed_sweep():
|
|
|
134
134
|
assert params[1] == (('x0', 1 / 4), ('x1', 1 - 1 / 2))
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def test_transformed_sweep_equality():
|
|
137
|
+
def test_transformed_sweep_equality() -> None:
|
|
138
138
|
a = sympy.Symbol('a')
|
|
139
139
|
sweep = cirq.Linspace('a', start=0, stop=3, length=4)
|
|
140
140
|
expr_map = cirq.ExpressionMap({a / 4: 'x0', 1 - a / 4: 'x1'})
|
cirq/study/resolver_test.py
CHANGED
|
@@ -39,7 +39,7 @@ import cirq
|
|
|
39
39
|
fractions.Fraction(3, 2),
|
|
40
40
|
],
|
|
41
41
|
)
|
|
42
|
-
def test_value_of_pass_through_types(val):
|
|
42
|
+
def test_value_of_pass_through_types(val) -> None:
|
|
43
43
|
_assert_consistent_resolution(val, val)
|
|
44
44
|
|
|
45
45
|
|
|
@@ -47,12 +47,12 @@ def test_value_of_pass_through_types(val):
|
|
|
47
47
|
'val,resolved',
|
|
48
48
|
[(sympy.pi, np.pi), (sympy.S.NegativeOne, -1), (sympy.S.Half, 0.5), (sympy.S.One, 1)],
|
|
49
49
|
)
|
|
50
|
-
def test_value_of_transformed_types(val, resolved):
|
|
50
|
+
def test_value_of_transformed_types(val, resolved) -> None:
|
|
51
51
|
_assert_consistent_resolution(val, resolved)
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
@pytest.mark.parametrize('val,resolved', [(sympy.I, 1j)])
|
|
55
|
-
def test_value_of_substituted_types(val, resolved):
|
|
55
|
+
def test_value_of_substituted_types(val, resolved) -> None:
|
|
56
56
|
_assert_consistent_resolution(val, resolved)
|
|
57
57
|
|
|
58
58
|
|
|
@@ -112,11 +112,11 @@ def _assert_consistent_resolution(v, resolved):
|
|
|
112
112
|
), f"expected {type(resolved)} got {type(r.value_of(v))}"
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
def test_value_of_strings():
|
|
115
|
+
def test_value_of_strings() -> None:
|
|
116
116
|
assert cirq.ParamResolver().value_of('x') == sympy.Symbol('x')
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
def test_value_of_calculations():
|
|
119
|
+
def test_value_of_calculations() -> None:
|
|
120
120
|
assert not bool(cirq.ParamResolver())
|
|
121
121
|
|
|
122
122
|
r = cirq.ParamResolver({'a': 0.5, 'b': 0.1, 'c': 1 + 1j})
|
|
@@ -129,34 +129,34 @@ def test_value_of_calculations():
|
|
|
129
129
|
assert r.value_of(sympy.Symbol('b') / 0.1 - sympy.Symbol('a')) == 0.5
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
def test_resolve_integer_division():
|
|
132
|
+
def test_resolve_integer_division() -> None:
|
|
133
133
|
r = cirq.ParamResolver({'a': 1, 'b': 2})
|
|
134
134
|
resolved = r.value_of(sympy.Symbol('a') / sympy.Symbol('b'))
|
|
135
135
|
assert resolved == 0.5
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
def test_resolve_symbol_division():
|
|
138
|
+
def test_resolve_symbol_division() -> None:
|
|
139
139
|
B = sympy.Symbol('B')
|
|
140
140
|
r = cirq.ParamResolver({'a': 1, 'b': B})
|
|
141
141
|
resolved = r.value_of(sympy.Symbol('a') / sympy.Symbol('b'))
|
|
142
142
|
assert resolved == sympy.core.power.Pow(B, -1)
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
def test_param_dict():
|
|
145
|
+
def test_param_dict() -> None:
|
|
146
146
|
r = cirq.ParamResolver({'a': 0.5, 'b': 0.1})
|
|
147
147
|
r2 = cirq.ParamResolver(r)
|
|
148
148
|
assert r2 is r
|
|
149
149
|
assert r.param_dict == {'a': 0.5, 'b': 0.1}
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
def test_param_dict_iter():
|
|
152
|
+
def test_param_dict_iter() -> None:
|
|
153
153
|
r = cirq.ParamResolver({'a': 0.5, 'b': 0.1})
|
|
154
154
|
assert [key for key in r] == ['a', 'b']
|
|
155
155
|
assert [r.value_of(key) for key in r] == [0.5, 0.1]
|
|
156
156
|
assert list(r) == ['a', 'b']
|
|
157
157
|
|
|
158
158
|
|
|
159
|
-
def test_formulas_in_param_dict():
|
|
159
|
+
def test_formulas_in_param_dict() -> None:
|
|
160
160
|
"""Tests that formula keys are rejected in a `param_dict`."""
|
|
161
161
|
a = sympy.Symbol('a')
|
|
162
162
|
b = sympy.Symbol('b')
|
|
@@ -166,7 +166,7 @@ def test_formulas_in_param_dict():
|
|
|
166
166
|
_ = cirq.ParamResolver({a: b + 1, b: 2, b + c: 101, 'd': 2 * e})
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
def test_recursive_evaluation():
|
|
169
|
+
def test_recursive_evaluation() -> None:
|
|
170
170
|
a = sympy.Symbol('a')
|
|
171
171
|
b = sympy.Symbol('b')
|
|
172
172
|
c = sympy.Symbol('c')
|
|
@@ -184,7 +184,7 @@ def test_recursive_evaluation():
|
|
|
184
184
|
assert sympy.Eq(r.value_of(e), 0)
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def test_resolution_of_unknown_formulas():
|
|
187
|
+
def test_resolution_of_unknown_formulas() -> None:
|
|
188
188
|
a = sympy.Symbol('a')
|
|
189
189
|
b = sympy.Symbol('b')
|
|
190
190
|
|
|
@@ -192,7 +192,7 @@ def test_resolution_of_unknown_formulas():
|
|
|
192
192
|
assert r.value_of(sympy.sin(a), recursive=False) == sympy.sin(b - 2)
|
|
193
193
|
|
|
194
194
|
|
|
195
|
-
def test_unbound_recursion_halted():
|
|
195
|
+
def test_unbound_recursion_halted() -> None:
|
|
196
196
|
a = sympy.Symbol('a')
|
|
197
197
|
b = sympy.Symbol('b')
|
|
198
198
|
c = sympy.Symbol('c')
|
|
@@ -223,14 +223,14 @@ def test_unbound_recursion_halted():
|
|
|
223
223
|
_ = r.value_of(a)
|
|
224
224
|
|
|
225
225
|
|
|
226
|
-
def test_resolve_unknown_type():
|
|
226
|
+
def test_resolve_unknown_type() -> None:
|
|
227
227
|
a = sympy.Symbol('a')
|
|
228
228
|
b = sympy.Symbol('b')
|
|
229
229
|
r = cirq.ParamResolver({a: b})
|
|
230
230
|
assert r.value_of(cirq.X) == cirq.X
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
def test_custom_resolved_value():
|
|
233
|
+
def test_custom_resolved_value() -> None:
|
|
234
234
|
class Foo:
|
|
235
235
|
def _resolved_value_(self):
|
|
236
236
|
return self
|
|
@@ -249,7 +249,7 @@ def test_custom_resolved_value():
|
|
|
249
249
|
assert r.value_of(b) == 'Baz'
|
|
250
250
|
|
|
251
251
|
|
|
252
|
-
def test_custom_value_not_implemented():
|
|
252
|
+
def test_custom_value_not_implemented() -> None:
|
|
253
253
|
class BarImplicit:
|
|
254
254
|
pass
|
|
255
255
|
|
|
@@ -264,7 +264,7 @@ def test_custom_value_not_implemented():
|
|
|
264
264
|
assert r.value_of(b) == b
|
|
265
265
|
|
|
266
266
|
|
|
267
|
-
def test_compose():
|
|
267
|
+
def test_compose() -> None:
|
|
268
268
|
"""Tests that cirq.resolve_parameters on a ParamResolver composes."""
|
|
269
269
|
a = sympy.Symbol('a')
|
|
270
270
|
b = sympy.Symbol('b')
|
|
@@ -301,7 +301,7 @@ def test_compose():
|
|
|
301
301
|
],
|
|
302
302
|
)
|
|
303
303
|
@pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
|
|
304
|
-
def test_compose_associative(p1, p2, p3, resolve_fn):
|
|
304
|
+
def test_compose_associative(p1, p2, p3, resolve_fn) -> None:
|
|
305
305
|
r1, r2, r3 = [
|
|
306
306
|
cirq.ParamResolver(
|
|
307
307
|
{sympy.Symbol(k): (sympy.Symbol(v) if isinstance(v, str) else v) for k, v in pd.items()}
|
|
@@ -313,7 +313,7 @@ def test_compose_associative(p1, p2, p3, resolve_fn):
|
|
|
313
313
|
)
|
|
314
314
|
|
|
315
315
|
|
|
316
|
-
def test_equals():
|
|
316
|
+
def test_equals() -> None:
|
|
317
317
|
et = cirq.testing.EqualsTester()
|
|
318
318
|
et.add_equality_group(
|
|
319
319
|
cirq.ParamResolver(),
|
|
@@ -329,7 +329,7 @@ def test_equals():
|
|
|
329
329
|
et.add_equality_group(cirq.ParamResolver({'c': 0.1}))
|
|
330
330
|
|
|
331
331
|
|
|
332
|
-
def test_repr():
|
|
332
|
+
def test_repr() -> None:
|
|
333
333
|
cirq.testing.assert_equivalent_repr(cirq.ParamResolver())
|
|
334
334
|
cirq.testing.assert_equivalent_repr(cirq.ParamResolver({'a': 2.0}))
|
|
335
335
|
cirq.testing.assert_equivalent_repr(cirq.ParamResolver({'a': sympy.Symbol('a')}))
|
|
@@ -55,7 +55,7 @@ class UnimplementedUnitaryGate(cirq.testing.TwoQubitGate):
|
|
|
55
55
|
return np.array([[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]])
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def test_assert_act_on_clifford_tableau_effect_matches_unitary():
|
|
58
|
+
def test_assert_act_on_clifford_tableau_effect_matches_unitary() -> None:
|
|
59
59
|
cirq.testing.assert_all_implemented_act_on_effects_match_unitary(GoodGate())
|
|
60
60
|
cirq.testing.assert_all_implemented_act_on_effects_match_unitary(
|
|
61
61
|
GoodGate().on(cirq.LineQubit(1))
|
|
@@ -18,12 +18,12 @@ import pytest
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_assert_consistent_channel_valid():
|
|
21
|
+
def test_assert_consistent_channel_valid() -> None:
|
|
22
22
|
channel = cirq.KrausChannel(kraus_ops=(np.array([[0, 1], [0, 0]]), np.array([[1, 0], [0, 0]])))
|
|
23
23
|
cirq.testing.assert_consistent_channel(channel)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
def test_assert_consistent_channel_tolerances():
|
|
26
|
+
def test_assert_consistent_channel_tolerances() -> None:
|
|
27
27
|
# This channel is off by 1e-5 from the identity matrix in the consistency condition.
|
|
28
28
|
channel = cirq.KrausChannel(
|
|
29
29
|
kraus_ops=(np.array([[0, np.sqrt(1 - 1e-5)], [0, 0]]), np.array([[1, 0], [0, 0]]))
|
|
@@ -37,23 +37,23 @@ def test_assert_consistent_channel_tolerances():
|
|
|
37
37
|
cirq.testing.assert_consistent_channel(channel, rtol=0, atol=1e-6)
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def test_assert_consistent_channel_invalid():
|
|
40
|
+
def test_assert_consistent_channel_invalid() -> None:
|
|
41
41
|
channel = cirq.KrausChannel(kraus_ops=(np.array([[1, 1], [0, 0]]), np.array([[1, 0], [0, 0]])))
|
|
42
42
|
with pytest.raises(AssertionError, match=r"cirq.KrausChannel.*2 1"):
|
|
43
43
|
cirq.testing.assert_consistent_channel(channel)
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
def test_assert_consistent_channel_not_kraus():
|
|
46
|
+
def test_assert_consistent_channel_not_kraus() -> None:
|
|
47
47
|
with pytest.raises(AssertionError, match="12.*has_kraus"):
|
|
48
48
|
cirq.testing.assert_consistent_channel(12)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
def test_assert_consistent_mixture_valid():
|
|
51
|
+
def test_assert_consistent_mixture_valid() -> None:
|
|
52
52
|
mixture = cirq.X.with_probability(0.1)
|
|
53
53
|
cirq.testing.assert_consistent_mixture(mixture)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def test_assert_consistent_mixture_not_mixture():
|
|
56
|
+
def test_assert_consistent_mixture_not_mixture() -> None:
|
|
57
57
|
not_mixture = cirq.amplitude_damp(0.1)
|
|
58
58
|
with pytest.raises(AssertionError, match="has_mixture"):
|
|
59
59
|
cirq.testing.assert_consistent_mixture(not_mixture)
|
|
@@ -69,7 +69,7 @@ class _MixtureGate(cirq.testing.SingleQubitGate):
|
|
|
69
69
|
return (self._p, cirq.unitary(cirq.I)), (self._q, cirq.unitary(cirq.X))
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def test_assert_consistent_mixture_not_normalized():
|
|
72
|
+
def test_assert_consistent_mixture_not_normalized() -> None:
|
|
73
73
|
mixture = _MixtureGate(0.1, 0.85)
|
|
74
74
|
with pytest.raises(AssertionError, match="sum to 1"):
|
|
75
75
|
cirq.testing.assert_consistent_mixture(mixture)
|
|
@@ -79,7 +79,7 @@ def test_assert_consistent_mixture_not_normalized():
|
|
|
79
79
|
cirq.testing.assert_consistent_mixture(mixture)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_assert_consistent_mixture_tolerances():
|
|
82
|
+
def test_assert_consistent_mixture_tolerances() -> None:
|
|
83
83
|
|
|
84
84
|
# This gate is 1e-5 off being properly normalized.
|
|
85
85
|
mixture = _MixtureGate(0.1, 0.9 - 1e-5)
|
|
@@ -62,7 +62,7 @@ class BadGate(cirq.EigenGate, cirq.testing.SingleQubitGate):
|
|
|
62
62
|
return ret
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def test_assert_controlled_and_controlled_by_identical():
|
|
65
|
+
def test_assert_controlled_and_controlled_by_identical() -> None:
|
|
66
66
|
cirq.testing.assert_controlled_and_controlled_by_identical(GoodGate())
|
|
67
67
|
|
|
68
68
|
with pytest.raises(AssertionError):
|
|
@@ -79,7 +79,7 @@ def test_assert_controlled_and_controlled_by_identical():
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_assert_controlled_unitary_consistent():
|
|
82
|
+
def test_assert_controlled_unitary_consistent() -> None:
|
|
83
83
|
cirq.testing.assert_controlled_and_controlled_by_identical(
|
|
84
84
|
GoodGate(exponent=0.5, global_shift=1 / 3)
|
|
85
85
|
)
|
|
@@ -35,7 +35,7 @@ class BadGateDecompose(cirq.testing.SingleQubitGate):
|
|
|
35
35
|
return np.array([[0, 1], [1, 0]])
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def test_assert_decompose_is_consistent_with_unitary():
|
|
38
|
+
def test_assert_decompose_is_consistent_with_unitary() -> None:
|
|
39
39
|
cirq.testing.assert_decompose_is_consistent_with_unitary(GoodGateDecompose())
|
|
40
40
|
|
|
41
41
|
cirq.testing.assert_decompose_is_consistent_with_unitary(
|
|
@@ -89,7 +89,7 @@ class ParameterizedGate(cirq.Gate):
|
|
|
89
89
|
yield cirq.Y(qubits[1]) ** sympy.Symbol("y")
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def test_assert_decompose_ends_at_default_gateset():
|
|
92
|
+
def test_assert_decompose_ends_at_default_gateset() -> None:
|
|
93
93
|
cirq.testing.assert_decompose_ends_at_default_gateset(GateDecomposesToDefaultGateset())
|
|
94
94
|
cirq.testing.assert_decompose_ends_at_default_gateset(
|
|
95
95
|
GateDecomposesToDefaultGateset().on(*cirq.LineQubit.range(2))
|
|
@@ -52,7 +52,7 @@ class BadGateInconsistentPauliExpansion(cirq.testing.SingleQubitGate):
|
|
|
52
52
|
return cirq.LinearDict({'X': np.sqrt(1 / 6), 'Y': np.sqrt(1 / 3), 'Z': np.sqrt(1 / 2)})
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def test_assert_pauli_expansion_is_consistent_with_unitary():
|
|
55
|
+
def test_assert_pauli_expansion_is_consistent_with_unitary() -> None:
|
|
56
56
|
cirq.testing.assert_pauli_expansion_is_consistent_with_unitary(GoodGateExplicitPauliExpansion())
|
|
57
57
|
cirq.testing.assert_pauli_expansion_is_consistent_with_unitary(GoodGateNoPauliExpansion())
|
|
58
58
|
cirq.testing.assert_pauli_expansion_is_consistent_with_unitary(GoodGateNoUnitary())
|
|
@@ -89,7 +89,7 @@ class SemiBadPhaser:
|
|
|
89
89
|
return SemiBadPhaser([resolver.value_of(val, recursive) for val in self.e])
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def test_assert_phase_by_is_consistent_with_unitary():
|
|
92
|
+
def test_assert_phase_by_is_consistent_with_unitary() -> None:
|
|
93
93
|
cirq.testing.assert_phase_by_is_consistent_with_unitary(GoodPhaser(0.5))
|
|
94
94
|
|
|
95
95
|
cirq.testing.assert_phase_by_is_consistent_with_unitary(GoodQuditPhaser(0.5))
|
|
@@ -18,7 +18,7 @@ import pytest
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_assert_specifies_has_unitary_if_unitary_from_matrix():
|
|
21
|
+
def test_assert_specifies_has_unitary_if_unitary_from_matrix() -> None:
|
|
22
22
|
class Bad:
|
|
23
23
|
def _unitary_(self):
|
|
24
24
|
return np.array([[1]])
|
|
@@ -28,7 +28,7 @@ def test_assert_specifies_has_unitary_if_unitary_from_matrix():
|
|
|
28
28
|
cirq.testing.assert_specifies_has_unitary_if_unitary(Bad())
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def test_assert_specifies_has_unitary_if_unitary_from_apply():
|
|
31
|
+
def test_assert_specifies_has_unitary_if_unitary_from_apply() -> None:
|
|
32
32
|
class Bad(cirq.Operation):
|
|
33
33
|
@property
|
|
34
34
|
def qubits(self):
|
|
@@ -45,7 +45,7 @@ def test_assert_specifies_has_unitary_if_unitary_from_apply():
|
|
|
45
45
|
cirq.testing.assert_specifies_has_unitary_if_unitary(Bad())
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def test_assert_specifies_has_unitary_if_unitary_from_decompose():
|
|
48
|
+
def test_assert_specifies_has_unitary_if_unitary_from_decompose() -> None:
|
|
49
49
|
class Bad:
|
|
50
50
|
def _decompose_(self):
|
|
51
51
|
return []
|
|
@@ -70,7 +70,7 @@ def test_assert_specifies_has_unitary_if_unitary_from_decompose():
|
|
|
70
70
|
cirq.testing.assert_specifies_has_unitary_if_unitary(Okay())
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
def test_assert_specifies_has_unitary_if_unitary_pass():
|
|
73
|
+
def test_assert_specifies_has_unitary_if_unitary_pass() -> None:
|
|
74
74
|
class Good:
|
|
75
75
|
def _has_unitary_(self):
|
|
76
76
|
return True
|
|
@@ -78,7 +78,7 @@ class CleanCorrectButBorrowableIncorrectGate(cirq.Gate):
|
|
|
78
78
|
(CleanCorrectButBorrowableIncorrectGate(use_clean_ancilla=False), False),
|
|
79
79
|
],
|
|
80
80
|
)
|
|
81
|
-
def test_assert_unitary_is_consistent(g, ignore_phase, is_consistent):
|
|
81
|
+
def test_assert_unitary_is_consistent(g, ignore_phase, is_consistent) -> None:
|
|
82
82
|
if is_consistent:
|
|
83
83
|
cirq.testing.assert_unitary_is_consistent(g, ignore_phase)
|
|
84
84
|
cirq.testing.assert_unitary_is_consistent(g.on(*cirq.LineQid.for_gate(g)), ignore_phase)
|
|
@@ -89,7 +89,7 @@ def test_assert_unitary_is_consistent(g, ignore_phase, is_consistent):
|
|
|
89
89
|
cirq.testing.assert_unitary_is_consistent(g.on(*cirq.LineQid.for_gate(g)), ignore_phase)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def test_failed_decomposition():
|
|
92
|
+
def test_failed_decomposition() -> None:
|
|
93
93
|
with pytest.raises(ValueError):
|
|
94
94
|
cirq.testing.assert_unitary_is_consistent(FailsOnDecompostion())
|
|
95
95
|
|
cirq/testing/deprecation_test.py
CHANGED
|
@@ -18,14 +18,14 @@ import pytest
|
|
|
18
18
|
from cirq.testing import assert_deprecated
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_nested_assert_deprecation():
|
|
21
|
+
def test_nested_assert_deprecation() -> None:
|
|
22
22
|
with assert_deprecated(deadline="v1.2", count=1):
|
|
23
23
|
with assert_deprecated(deadline="v1.2", count=1):
|
|
24
24
|
with assert_deprecated(deadline="v1.2", count=1):
|
|
25
25
|
warnings.warn("hello, this is deprecated in v1.2")
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_assert_deprecated_log_handling():
|
|
28
|
+
def test_assert_deprecated_log_handling() -> None:
|
|
29
29
|
# correct deprecation message
|
|
30
30
|
with assert_deprecated("hello", deadline="v1.2"):
|
|
31
31
|
warnings.warn("hello, this is deprecated in v1.2")
|
cirq/testing/devices_test.py
CHANGED
|
@@ -17,7 +17,7 @@ import cirq
|
|
|
17
17
|
from cirq.testing.devices import ValidatingTestDevice
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_validating_types_and_qubits():
|
|
20
|
+
def test_validating_types_and_qubits() -> None:
|
|
21
21
|
dev = ValidatingTestDevice(
|
|
22
22
|
allowed_qubit_types=(cirq.GridQubit,),
|
|
23
23
|
allowed_gates=(cirq.XPowGate,),
|
|
@@ -37,7 +37,7 @@ def test_validating_types_and_qubits():
|
|
|
37
37
|
dev.validate_operation(cirq.Y(cirq.GridQubit(0, 0)))
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def test_validating_locality():
|
|
40
|
+
def test_validating_locality() -> None:
|
|
41
41
|
dev = ValidatingTestDevice(
|
|
42
42
|
allowed_qubit_types=(cirq.GridQubit,),
|
|
43
43
|
allowed_gates=(cirq.CZPowGate, cirq.MeasurementGate),
|
|
@@ -62,7 +62,7 @@ def test_validating_locality():
|
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def test_repr():
|
|
65
|
+
def test_repr() -> None:
|
|
66
66
|
dev = ValidatingTestDevice(
|
|
67
67
|
allowed_qubit_types=(cirq.GridQubit,),
|
|
68
68
|
allowed_gates=(cirq.CZPowGate, cirq.MeasurementGate),
|
|
@@ -73,7 +73,7 @@ def test_repr():
|
|
|
73
73
|
assert repr(dev) == 'test'
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def test_defaults():
|
|
76
|
+
def test_defaults() -> None:
|
|
77
77
|
dev = ValidatingTestDevice(qubits={cirq.GridQubit(0, 0)})
|
|
78
78
|
assert repr(dev) == 'ValidatingTestDevice'
|
|
79
79
|
assert dev.allowed_qubit_types == (cirq.GridQubit,)
|
|
@@ -17,7 +17,7 @@ import cirq
|
|
|
17
17
|
from cirq import circuits
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_correct_mappings():
|
|
20
|
+
def test_correct_mappings() -> None:
|
|
21
21
|
a, b, c = cirq.LineQubit.range(3)
|
|
22
22
|
cirq.testing.assert_equivalent_computational_basis_map(
|
|
23
23
|
maps={0b01: 0b01, 0b10: 0b10},
|
|
@@ -30,7 +30,7 @@ def test_correct_mappings():
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def test_incorrect_mappings():
|
|
33
|
+
def test_incorrect_mappings() -> None:
|
|
34
34
|
a, b, c = cirq.LineQubit.range(3)
|
|
35
35
|
with pytest.raises(
|
|
36
36
|
AssertionError,
|
|
@@ -18,7 +18,7 @@ import pytest
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_external():
|
|
21
|
+
def test_external() -> None:
|
|
22
22
|
for t in ['a', 1j]:
|
|
23
23
|
cirq.testing.assert_equivalent_repr(t)
|
|
24
24
|
cirq.testing.assert_equivalent_repr(t, setup_code='')
|
|
@@ -29,7 +29,7 @@ def test_external():
|
|
|
29
29
|
cirq.testing.assert_equivalent_repr(np.array([5]))
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def test_custom_class_repr():
|
|
32
|
+
def test_custom_class_repr() -> None:
|
|
33
33
|
class CustomRepr: # pragma: no cover
|
|
34
34
|
setup_code = """class CustomRepr:
|
|
35
35
|
def __init__(self, eq_val):
|
|
@@ -81,5 +81,5 @@ def test_custom_class_repr():
|
|
|
81
81
|
)
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
def test_imports_cirq_by_default():
|
|
84
|
+
def test_imports_cirq_by_default() -> None:
|
|
85
85
|
cirq.testing.assert_equivalent_repr(cirq.NamedQubit('a'))
|