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
|
@@ -65,18 +65,18 @@ def test_incompatible_m_value_and_qubit_args(m: int, n: int) -> None:
|
|
|
65
65
|
cirq.UniformSuperpositionGate(m, n)
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def test_repr():
|
|
68
|
+
def test_repr() -> None:
|
|
69
69
|
assert (
|
|
70
70
|
repr(cirq.UniformSuperpositionGate(7, 3))
|
|
71
71
|
== 'UniformSuperpositionGate(m_value=7, num_qubits=3)'
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def test_uniform_superposition_gate_json_dict():
|
|
75
|
+
def test_uniform_superposition_gate_json_dict() -> None:
|
|
76
76
|
assert cirq.UniformSuperpositionGate(7, 3)._json_dict_() == {'m_value': 7, 'num_qubits': 3}
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
def test_str():
|
|
79
|
+
def test_str() -> None:
|
|
80
80
|
assert (
|
|
81
81
|
str(cirq.UniformSuperpositionGate(7, 3))
|
|
82
82
|
== 'UniformSuperpositionGate(m_value=7, num_qubits=3)'
|
|
@@ -45,24 +45,24 @@ class ExampleSimulationState(cirq.SimulationState):
|
|
|
45
45
|
op = cirq.X(cirq.LineQubit(0))
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def test_act_on_fallback_succeeds():
|
|
48
|
+
def test_act_on_fallback_succeeds() -> None:
|
|
49
49
|
state = ExampleSimulationState(fallback_result=True)
|
|
50
50
|
cirq.act_on(op, state)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def test_act_on_fallback_fails():
|
|
53
|
+
def test_act_on_fallback_fails() -> None:
|
|
54
54
|
state = ExampleSimulationState(fallback_result=NotImplemented)
|
|
55
55
|
with pytest.raises(TypeError, match='Failed to act'):
|
|
56
56
|
cirq.act_on(op, state)
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def test_act_on_fallback_errors():
|
|
59
|
+
def test_act_on_fallback_errors() -> None:
|
|
60
60
|
state = ExampleSimulationState(fallback_result=False)
|
|
61
61
|
with pytest.raises(ValueError, match='_act_on_fallback_ must return True or NotImplemented'):
|
|
62
62
|
cirq.act_on(op, state)
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def test_act_on_errors():
|
|
65
|
+
def test_act_on_errors() -> None:
|
|
66
66
|
class Op(cirq.Operation):
|
|
67
67
|
@property
|
|
68
68
|
def qubits(self) -> Tuple[cirq.Qid, ...]: # type: ignore[empty-body]
|
|
@@ -79,7 +79,7 @@ def test_act_on_errors():
|
|
|
79
79
|
cirq.act_on(Op(), state)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_qubits_not_allowed_for_operations():
|
|
82
|
+
def test_qubits_not_allowed_for_operations() -> None:
|
|
83
83
|
class Op(cirq.Operation):
|
|
84
84
|
@property
|
|
85
85
|
def qubits(self) -> Tuple[cirq.Qid, ...]: # type: ignore[empty-body]
|
|
@@ -95,7 +95,7 @@ def test_qubits_not_allowed_for_operations():
|
|
|
95
95
|
cirq.act_on(Op(), state, qubits=[])
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def test_qubits_should_be_defined_for_operations():
|
|
98
|
+
def test_qubits_should_be_defined_for_operations() -> None:
|
|
99
99
|
state = ExampleSimulationState()
|
|
100
100
|
with pytest.raises(ValueError, match='Calls to act_on should'):
|
|
101
101
|
cirq.act_on(cirq.KrausChannel([np.array([[1, 0], [0, 0]])]), state, qubits=None)
|
|
@@ -18,7 +18,7 @@ import sympy
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_circuit_diagram_info_value_wrapping():
|
|
21
|
+
def test_circuit_diagram_info_value_wrapping() -> None:
|
|
22
22
|
single_info = cirq.CircuitDiagramInfo(('Single',))
|
|
23
23
|
|
|
24
24
|
class ReturnInfo:
|
|
@@ -67,20 +67,20 @@ def test_circuit_diagram_info_value_wrapping():
|
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def test_circuit_diagram_info_init():
|
|
70
|
+
def test_circuit_diagram_info_init() -> None:
|
|
71
71
|
assert cirq.CircuitDiagramInfo(['a', 'b']).wire_symbols == ('a', 'b')
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
def test_circuit_diagram_info_validate():
|
|
74
|
+
def test_circuit_diagram_info_validate() -> None:
|
|
75
75
|
with pytest.raises(ValueError):
|
|
76
76
|
_ = cirq.CircuitDiagramInfo('X')
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
def test_circuit_diagram_info_repr():
|
|
79
|
+
def test_circuit_diagram_info_repr() -> None:
|
|
80
80
|
cirq.testing.assert_equivalent_repr(cirq.CircuitDiagramInfo(('X', 'Y'), 2))
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
def test_circuit_diagram_info_eq():
|
|
83
|
+
def test_circuit_diagram_info_eq() -> None:
|
|
84
84
|
eq = cirq.testing.EqualsTester()
|
|
85
85
|
eq.make_equality_group(lambda: cirq.CircuitDiagramInfo(('X',)))
|
|
86
86
|
eq.add_equality_group(
|
|
@@ -92,7 +92,7 @@ def test_circuit_diagram_info_eq():
|
|
|
92
92
|
eq.add_equality_group(cirq.CircuitDiagramInfo(('Z',), 3, auto_exponent_parens=False))
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def test_circuit_diagram_info_pass_fail():
|
|
95
|
+
def test_circuit_diagram_info_pass_fail() -> None:
|
|
96
96
|
class C:
|
|
97
97
|
pass
|
|
98
98
|
|
|
@@ -115,14 +115,14 @@ def test_circuit_diagram_info_pass_fail():
|
|
|
115
115
|
assert cirq.circuit_diagram_info(E()) == cirq.CircuitDiagramInfo(('X',))
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
def test_controlled_1x1_matrixgate_diagram_error():
|
|
118
|
+
def test_controlled_1x1_matrixgate_diagram_error() -> None:
|
|
119
119
|
q = cirq.LineQubit(0)
|
|
120
120
|
g = cirq.MatrixGate(np.array([[1j]])).controlled()
|
|
121
121
|
c = cirq.Circuit(g(q))
|
|
122
122
|
assert str(c) == "0: ───C[[0.+1.j]]───"
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
def test_circuit_diagram_info_args_eq():
|
|
125
|
+
def test_circuit_diagram_info_args_eq() -> None:
|
|
126
126
|
eq = cirq.testing.EqualsTester()
|
|
127
127
|
eq.add_equality_group(cirq.CircuitDiagramInfoArgs.UNINFORMED_DEFAULT)
|
|
128
128
|
eq.add_equality_group(
|
|
@@ -192,7 +192,7 @@ def test_circuit_diagram_info_args_eq():
|
|
|
192
192
|
)
|
|
193
193
|
|
|
194
194
|
|
|
195
|
-
def test_circuit_diagram_info_args_repr():
|
|
195
|
+
def test_circuit_diagram_info_args_repr() -> None:
|
|
196
196
|
cirq.testing.assert_equivalent_repr(
|
|
197
197
|
cirq.CircuitDiagramInfoArgs(
|
|
198
198
|
known_qubits=cirq.LineQubit.range(2),
|
|
@@ -206,7 +206,7 @@ def test_circuit_diagram_info_args_repr():
|
|
|
206
206
|
)
|
|
207
207
|
|
|
208
208
|
|
|
209
|
-
def test_format_real():
|
|
209
|
+
def test_format_real() -> None:
|
|
210
210
|
args = cirq.CircuitDiagramInfoArgs.UNINFORMED_DEFAULT.copy()
|
|
211
211
|
assert args.format_real(1) == '1'
|
|
212
212
|
assert args.format_real(1.1) == '1.1'
|
|
@@ -227,7 +227,7 @@ def test_format_real():
|
|
|
227
227
|
assert args.format_real(sympy.Symbol('t') * 2 + 1) == '2*t + 1'
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
def test_format_complex():
|
|
230
|
+
def test_format_complex() -> None:
|
|
231
231
|
args = cirq.CircuitDiagramInfoArgs.UNINFORMED_DEFAULT.copy()
|
|
232
232
|
assert args.format_complex(1) == '1+0i'
|
|
233
233
|
assert args.format_complex(1.1) == '1.1+0i'
|
|
@@ -250,7 +250,7 @@ def test_format_complex():
|
|
|
250
250
|
assert args.format_complex(sympy.Symbol('t') * 2 + 1) == '2*t + 1'
|
|
251
251
|
|
|
252
252
|
|
|
253
|
-
def test_format_radians_without_precision():
|
|
253
|
+
def test_format_radians_without_precision() -> None:
|
|
254
254
|
args = cirq.CircuitDiagramInfoArgs(
|
|
255
255
|
known_qubits=None,
|
|
256
256
|
known_qubit_count=None,
|
|
@@ -278,7 +278,7 @@ def test_format_radians_without_precision():
|
|
|
278
278
|
assert args.format_radians(sympy.Symbol('t') * 2 + 1) == '2*t + 1'
|
|
279
279
|
|
|
280
280
|
|
|
281
|
-
def test_format_radians_with_precision():
|
|
281
|
+
def test_format_radians_with_precision() -> None:
|
|
282
282
|
args = cirq.CircuitDiagramInfoArgs(
|
|
283
283
|
known_qubits=None,
|
|
284
284
|
known_qubit_count=None,
|
|
@@ -64,7 +64,7 @@ class DecomposeQuditGate:
|
|
|
64
64
|
yield cirq.identity_each(*qids)
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
def test_decompose_once():
|
|
67
|
+
def test_decompose_once() -> None:
|
|
68
68
|
# No default value results in descriptive error.
|
|
69
69
|
with pytest.raises(TypeError, match='no _decompose_with_context_ or _decompose_ method'):
|
|
70
70
|
_ = cirq.decompose_once(NoMethod())
|
|
@@ -91,7 +91,7 @@ def test_decompose_once():
|
|
|
91
91
|
]
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
def test_decompose_once_with_qubits():
|
|
94
|
+
def test_decompose_once_with_qubits() -> None:
|
|
95
95
|
qs = cirq.LineQubit.range(3)
|
|
96
96
|
|
|
97
97
|
# No default value results in descriptive error.
|
|
@@ -137,7 +137,7 @@ def test_decompose_once_with_qubits():
|
|
|
137
137
|
) == list(cirq.X.on_each(*qs)) + list(cirq.Y.on_each(*qs))
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
def test_decompose_general():
|
|
140
|
+
def test_decompose_general() -> None:
|
|
141
141
|
a, b, c = cirq.LineQubit.range(3)
|
|
142
142
|
no_method = NoMethod()
|
|
143
143
|
assert cirq.decompose(no_method) == [no_method]
|
|
@@ -152,7 +152,7 @@ def test_decompose_general():
|
|
|
152
152
|
)
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
def test_decompose_keep():
|
|
155
|
+
def test_decompose_keep() -> None:
|
|
156
156
|
a, b = cirq.LineQubit.range(2)
|
|
157
157
|
|
|
158
158
|
# Recursion can be stopped.
|
|
@@ -180,7 +180,7 @@ def test_decompose_keep():
|
|
|
180
180
|
assert cirq.decompose([[[cirq.SWAP(a, b)]]], keep=lambda _: True) == [cirq.SWAP(a, b)]
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
def test_decompose_on_stuck_raise():
|
|
183
|
+
def test_decompose_on_stuck_raise() -> None:
|
|
184
184
|
a, b = cirq.LineQubit.range(2)
|
|
185
185
|
no_method = NoMethod()
|
|
186
186
|
|
|
@@ -210,7 +210,7 @@ def test_decompose_on_stuck_raise():
|
|
|
210
210
|
assert cirq.decompose([], on_stuck_raise=TypeError('x'))
|
|
211
211
|
|
|
212
212
|
|
|
213
|
-
def test_decompose_intercept():
|
|
213
|
+
def test_decompose_intercept() -> None:
|
|
214
214
|
a = cirq.NamedQubit('a')
|
|
215
215
|
b = cirq.NamedQubit('b')
|
|
216
216
|
|
|
@@ -247,7 +247,7 @@ def test_decompose_intercept():
|
|
|
247
247
|
assert actual == [cirq.X(a), cirq.X(cirq.ops.CleanQubit(0)), cirq.X(b)]
|
|
248
248
|
|
|
249
249
|
|
|
250
|
-
def test_decompose_preserving_structure():
|
|
250
|
+
def test_decompose_preserving_structure() -> None:
|
|
251
251
|
a, b = cirq.LineQubit.range(2)
|
|
252
252
|
fc1 = cirq.FrozenCircuit(cirq.SWAP(a, b), cirq.FSimGate(0.1, 0.2).on(a, b))
|
|
253
253
|
cop1_1 = cirq.CircuitOperation(fc1).with_tags('test_tag')
|
|
@@ -275,7 +275,7 @@ def test_decompose_preserving_structure():
|
|
|
275
275
|
|
|
276
276
|
# Test both intercepting and fallback decomposers.
|
|
277
277
|
@pytest.mark.parametrize('decompose_mode', ['intercept', 'fallback'])
|
|
278
|
-
def test_decompose_preserving_structure_forwards_args(decompose_mode):
|
|
278
|
+
def test_decompose_preserving_structure_forwards_args(decompose_mode) -> None:
|
|
279
279
|
a, b = cirq.LineQubit.range(2)
|
|
280
280
|
fc1 = cirq.FrozenCircuit(cirq.SWAP(a, b), cirq.FSimGate(0.1, 0.2).on(a, b))
|
|
281
281
|
cop1_1 = cirq.CircuitOperation(fc1).with_tags('test_tag')
|
|
@@ -322,7 +322,7 @@ def test_decompose_preserving_structure_forwards_args(decompose_mode):
|
|
|
322
322
|
assert actual == expected
|
|
323
323
|
|
|
324
324
|
|
|
325
|
-
def test_decompose_tagged_operation():
|
|
325
|
+
def test_decompose_tagged_operation() -> None:
|
|
326
326
|
op = cirq.TaggedOperation(
|
|
327
327
|
cirq.CircuitOperation(
|
|
328
328
|
circuit=cirq.FrozenCircuit(
|
|
@@ -377,7 +377,7 @@ class RecursiveDecompose(cirq.Gate):
|
|
|
377
377
|
|
|
378
378
|
|
|
379
379
|
@pytest.mark.parametrize('with_context', [True, False])
|
|
380
|
-
def test_decompose_recursive_dfs(with_context: bool):
|
|
380
|
+
def test_decompose_recursive_dfs(with_context: bool) -> None:
|
|
381
381
|
expected_calls = [
|
|
382
382
|
mock.call.qalloc(True),
|
|
383
383
|
mock.call.qalloc(False),
|
|
@@ -426,7 +426,7 @@ class G2(cirq.Gate):
|
|
|
426
426
|
|
|
427
427
|
|
|
428
428
|
@mock.patch('cirq.protocols.decompose_protocol._CONTEXT_COUNTER', itertools.count())
|
|
429
|
-
def test_successive_decompose_once_succeed():
|
|
429
|
+
def test_successive_decompose_once_succeed() -> None:
|
|
430
430
|
op = G2()(cirq.NamedQubit('q'))
|
|
431
431
|
d1 = cirq.decompose_once(op)
|
|
432
432
|
d2 = cirq.decompose_once(d1[0])
|
|
@@ -438,7 +438,7 @@ def test_successive_decompose_once_succeed():
|
|
|
438
438
|
]
|
|
439
439
|
|
|
440
440
|
|
|
441
|
-
def test_decompose_without_context_succeed():
|
|
441
|
+
def test_decompose_without_context_succeed() -> None:
|
|
442
442
|
op = G2()(cirq.NamedQubit('q'))
|
|
443
443
|
assert cirq.decompose(op, keep=lambda op: op.gate is cirq.CNOT) == [
|
|
444
444
|
cirq.CNOT(
|
|
@@ -16,7 +16,7 @@ import numpy as np
|
|
|
16
16
|
import cirq
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_equal_up_to_global_phase_primitives():
|
|
19
|
+
def test_equal_up_to_global_phase_primitives() -> None:
|
|
20
20
|
assert cirq.equal_up_to_global_phase(1.0 + 1j, 1.0 + 1j, atol=1e-9)
|
|
21
21
|
assert not cirq.equal_up_to_global_phase(2.0, 1.0 + 1j, atol=1e-9)
|
|
22
22
|
assert cirq.equal_up_to_global_phase(1.0 + 1j, 1.0 - 1j, atol=1e-9)
|
|
@@ -34,7 +34,7 @@ def test_equal_up_to_global_phase_primitives():
|
|
|
34
34
|
assert cirq.equal_up_to_global_phase(1.0 + 1e-10j, 1.0, atol=1e-15)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_equal_up_to_global_numeric_iterables():
|
|
37
|
+
def test_equal_up_to_global_numeric_iterables() -> None:
|
|
38
38
|
assert cirq.equal_up_to_global_phase([], [], atol=1e-9)
|
|
39
39
|
assert cirq.equal_up_to_global_phase([[]], [[]], atol=1e-9)
|
|
40
40
|
assert cirq.equal_up_to_global_phase([1j, 1], [1j, 1], atol=1e-9)
|
|
@@ -49,7 +49,7 @@ def test_equal_up_to_global_numeric_iterables():
|
|
|
49
49
|
assert not cirq.equal_up_to_global_phase((1j, 1), (1, 1j), atol=1e-09)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def test_equal_up_to_global_numpy_array():
|
|
52
|
+
def test_equal_up_to_global_numpy_array() -> None:
|
|
53
53
|
assert cirq.equal_up_to_global_phase(
|
|
54
54
|
np.asarray([1j, 1j]), np.asarray([1, 1], dtype=np.complex64)
|
|
55
55
|
)
|
|
@@ -60,7 +60,7 @@ def test_equal_up_to_global_numpy_array():
|
|
|
60
60
|
assert cirq.equal_up_to_global_phase(np.asarray([[]]), np.asarray([[]]))
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def test_equal_up_to_global_mixed_array_types():
|
|
63
|
+
def test_equal_up_to_global_mixed_array_types() -> None:
|
|
64
64
|
a = [1j, 1, -1j, -1]
|
|
65
65
|
b = [-1, 1j, 1, -1j]
|
|
66
66
|
c = [-1, 1, -1, 1]
|
|
@@ -108,7 +108,7 @@ class B:
|
|
|
108
108
|
return cirq.equal_up_to_global_phase(self.val[0], other, atol=atol)
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def test_equal_up_to_global_phase_eq_supported():
|
|
111
|
+
def test_equal_up_to_global_phase_eq_supported() -> None:
|
|
112
112
|
assert cirq.equal_up_to_global_phase(A(0.1 + 0j), A(0.1j), atol=1e-2)
|
|
113
113
|
assert not cirq.equal_up_to_global_phase(A(0.0 + 0j), A(0.1j), atol=0.0)
|
|
114
114
|
assert not cirq.equal_up_to_global_phase(A(0.0 + 0j), 0.1j, atol=0.0)
|
|
@@ -120,7 +120,7 @@ def test_equal_up_to_global_phase_eq_supported():
|
|
|
120
120
|
assert not cirq.equal_up_to_global_phase(1e-8j, B(0.0), atol=1e-10)
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def test_equal_up_to_global_phase_non_eigen_gates():
|
|
123
|
+
def test_equal_up_to_global_phase_non_eigen_gates() -> None:
|
|
124
124
|
gate1 = cirq.PhasedXPowGate(phase_exponent=1.5, exponent=1.0)
|
|
125
125
|
gate2 = cirq.PhasedXPowGate(phase_exponent=0.5, exponent=1.0)
|
|
126
126
|
assert cirq.equal_up_to_global_phase(gate1, gate2)
|
|
@@ -105,7 +105,7 @@ class GateDecomposes(cirq.Gate):
|
|
|
105
105
|
yield YesOp(*qubits)
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
def test_inconclusive():
|
|
108
|
+
def test_inconclusive() -> None:
|
|
109
109
|
assert not cirq.has_stabilizer_effect(object())
|
|
110
110
|
assert not cirq.has_stabilizer_effect('boo')
|
|
111
111
|
assert not cirq.has_stabilizer_effect(cirq.testing.SingleQubitGate())
|
|
@@ -113,21 +113,21 @@ def test_inconclusive():
|
|
|
113
113
|
assert not cirq.has_stabilizer_effect(NoOp())
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
def test_via_has_stabilizer_effect_method():
|
|
116
|
+
def test_via_has_stabilizer_effect_method() -> None:
|
|
117
117
|
assert not cirq.has_stabilizer_effect(No1())
|
|
118
118
|
assert not cirq.has_stabilizer_effect(No2())
|
|
119
119
|
assert not cirq.has_stabilizer_effect(No3())
|
|
120
120
|
assert cirq.has_stabilizer_effect(Yes())
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def test_via_gate_of_op():
|
|
123
|
+
def test_via_gate_of_op() -> None:
|
|
124
124
|
assert cirq.has_stabilizer_effect(YesOp())
|
|
125
125
|
assert not cirq.has_stabilizer_effect(NoOp1())
|
|
126
126
|
assert not cirq.has_stabilizer_effect(NoOp2())
|
|
127
127
|
assert not cirq.has_stabilizer_effect(NoOp3())
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
def test_via_unitary():
|
|
130
|
+
def test_via_unitary() -> None:
|
|
131
131
|
op1 = OpWithUnitary(np.array([[0, 1], [1, 0]]))
|
|
132
132
|
assert cirq.has_stabilizer_effect(op1)
|
|
133
133
|
|
|
@@ -148,7 +148,7 @@ def test_via_unitary():
|
|
|
148
148
|
assert not cirq.has_stabilizer_effect(cirq.CCZ)
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
def test_via_decompose():
|
|
151
|
+
def test_via_decompose() -> None:
|
|
152
152
|
assert cirq.has_stabilizer_effect(cirq.Circuit(cirq.H.on_each(cirq.LineQubit.range(4))))
|
|
153
153
|
assert not cirq.has_stabilizer_effect(cirq.Circuit(cirq.T.on_each(cirq.LineQubit.range(4))))
|
|
154
154
|
assert not cirq.has_stabilizer_effect(
|
|
@@ -18,7 +18,7 @@ import pytest
|
|
|
18
18
|
import cirq
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_inconclusive():
|
|
21
|
+
def test_inconclusive() -> None:
|
|
22
22
|
class No:
|
|
23
23
|
pass
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ def test_inconclusive():
|
|
|
30
30
|
@pytest.mark.parametrize(
|
|
31
31
|
'measurement_gate', (cirq.MeasurementGate(1, 'a'), cirq.PauliMeasurementGate([cirq.X], 'a'))
|
|
32
32
|
)
|
|
33
|
-
def test_fail_fast_measure(measurement_gate):
|
|
33
|
+
def test_fail_fast_measure(measurement_gate) -> None:
|
|
34
34
|
assert not cirq.has_unitary(measurement_gate)
|
|
35
35
|
|
|
36
36
|
qubit = cirq.NamedQubit('q0')
|
|
@@ -40,13 +40,13 @@ def test_fail_fast_measure(measurement_gate):
|
|
|
40
40
|
assert not cirq.has_unitary(circuit)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def test_fail_fast_measure_large_memory():
|
|
43
|
+
def test_fail_fast_measure_large_memory() -> None:
|
|
44
44
|
num_qubits = 100
|
|
45
45
|
measurement_op = cirq.MeasurementGate(num_qubits, 'a').on(*cirq.LineQubit.range(num_qubits))
|
|
46
46
|
assert not cirq.has_unitary(measurement_op)
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def test_via_unitary():
|
|
49
|
+
def test_via_unitary() -> None:
|
|
50
50
|
class No1:
|
|
51
51
|
def _unitary_(self):
|
|
52
52
|
return NotImplemented
|
|
@@ -65,7 +65,7 @@ def test_via_unitary():
|
|
|
65
65
|
assert cirq.has_unitary(Yes(), allow_decompose=False)
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def test_via_apply_unitary():
|
|
68
|
+
def test_via_apply_unitary() -> None:
|
|
69
69
|
class No1(EmptyOp):
|
|
70
70
|
def _apply_unitary_(self, args):
|
|
71
71
|
return None
|
|
@@ -100,7 +100,7 @@ def test_via_apply_unitary():
|
|
|
100
100
|
assert not cirq.has_unitary(No4())
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
def test_via_decompose():
|
|
103
|
+
def test_via_decompose() -> None:
|
|
104
104
|
class Yes1:
|
|
105
105
|
def _decompose_(self):
|
|
106
106
|
return []
|
|
@@ -132,7 +132,7 @@ def test_via_decompose():
|
|
|
132
132
|
assert not cirq.has_unitary(No1(), allow_decompose=False)
|
|
133
133
|
|
|
134
134
|
|
|
135
|
-
def test_via_has_unitary():
|
|
135
|
+
def test_via_has_unitary() -> None:
|
|
136
136
|
class No1:
|
|
137
137
|
def _has_unitary_(self):
|
|
138
138
|
return NotImplemented
|
|
@@ -150,7 +150,7 @@ def test_via_has_unitary():
|
|
|
150
150
|
assert cirq.has_unitary(Yes())
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def test_order():
|
|
153
|
+
def test_order() -> None:
|
|
154
154
|
class Yes1(EmptyOp):
|
|
155
155
|
def _has_unitary_(self):
|
|
156
156
|
return True
|
|
@@ -105,7 +105,7 @@ def test_exclude_json_files_has_valid_entries() -> None:
|
|
|
105
105
|
if _is_included(f"{abs_path}.json")
|
|
106
106
|
],
|
|
107
107
|
)
|
|
108
|
-
def test_hash_from_pickle(json_filename: str, pool: multiprocessing.pool.Pool):
|
|
108
|
+
def test_hash_from_pickle(json_filename: str, pool: multiprocessing.pool.Pool) -> None:
|
|
109
109
|
obj_local = _read_json(json_filename)
|
|
110
110
|
if not isinstance(obj_local, Hashable):
|
|
111
111
|
return
|
|
@@ -50,7 +50,7 @@ class IsIterable:
|
|
|
50
50
|
@pytest.mark.parametrize(
|
|
51
51
|
'val', (NoMethod(), 'text', object(), ReturnsNotImplemented(), [NoMethod(), 5])
|
|
52
52
|
)
|
|
53
|
-
def test_objects_with_no_inverse(val):
|
|
53
|
+
def test_objects_with_no_inverse(val) -> None:
|
|
54
54
|
with pytest.raises(TypeError, match="isn't invertible"):
|
|
55
55
|
_ = cirq.inverse(val)
|
|
56
56
|
assert cirq.inverse(val, None) is None
|
|
@@ -76,6 +76,6 @@ def test_objects_with_no_inverse(val):
|
|
|
76
76
|
(IsIterable(), (0.5, 1)),
|
|
77
77
|
),
|
|
78
78
|
)
|
|
79
|
-
def test_objects_with_inverse(val, inv):
|
|
79
|
+
def test_objects_with_inverse(val, inv) -> None:
|
|
80
80
|
assert cirq.inverse(val) == inv
|
|
81
81
|
assert cirq.inverse(val, 0) == inv
|
|
@@ -24,7 +24,7 @@ import cirq
|
|
|
24
24
|
LOCAL_DEFAULT: List[np.ndarray] = [np.array([])]
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def test_kraus_no_methods():
|
|
27
|
+
def test_kraus_no_methods() -> None:
|
|
28
28
|
class NoMethod:
|
|
29
29
|
pass
|
|
30
30
|
|
|
@@ -51,7 +51,7 @@ def assert_not_implemented(val):
|
|
|
51
51
|
assert not cirq.has_kraus(val)
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def test_kraus_returns_not_implemented():
|
|
54
|
+
def test_kraus_returns_not_implemented() -> None:
|
|
55
55
|
class ReturnsNotImplemented:
|
|
56
56
|
def _kraus_(self):
|
|
57
57
|
return NotImplemented
|
|
@@ -59,7 +59,7 @@ def test_kraus_returns_not_implemented():
|
|
|
59
59
|
assert_not_implemented(ReturnsNotImplemented())
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
def test_mixture_returns_not_implemented():
|
|
62
|
+
def test_mixture_returns_not_implemented() -> None:
|
|
63
63
|
class ReturnsNotImplemented:
|
|
64
64
|
def _mixture_(self):
|
|
65
65
|
return NotImplemented
|
|
@@ -67,7 +67,7 @@ def test_mixture_returns_not_implemented():
|
|
|
67
67
|
assert_not_implemented(ReturnsNotImplemented())
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def test_unitary_returns_not_implemented():
|
|
70
|
+
def test_unitary_returns_not_implemented() -> None:
|
|
71
71
|
class ReturnsNotImplemented:
|
|
72
72
|
def _unitary_(self):
|
|
73
73
|
return NotImplemented
|
|
@@ -80,7 +80,7 @@ def test_unitary_returns_not_implemented():
|
|
|
80
80
|
assert cirq.kraus(ReturnsNotImplemented(), LOCAL_DEFAULT) is LOCAL_DEFAULT
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
def test_explicit_kraus():
|
|
83
|
+
def test_explicit_kraus() -> None:
|
|
84
84
|
a0 = np.array([[0, 0], [1, 0]])
|
|
85
85
|
a1 = np.array([[1, 0], [0, 0]])
|
|
86
86
|
c = (a0, a1)
|
|
@@ -98,7 +98,7 @@ def test_explicit_kraus():
|
|
|
98
98
|
assert cirq.has_kraus(ReturnsKraus())
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_kraus_fallback_to_mixture():
|
|
101
|
+
def test_kraus_fallback_to_mixture() -> None:
|
|
102
102
|
m = ((0.3, cirq.unitary(cirq.X)), (0.4, cirq.unitary(cirq.Y)), (0.3, cirq.unitary(cirq.Z)))
|
|
103
103
|
|
|
104
104
|
class ReturnsMixture:
|
|
@@ -120,7 +120,7 @@ def test_kraus_fallback_to_mixture():
|
|
|
120
120
|
assert cirq.has_kraus(ReturnsMixture())
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def test_kraus_fallback_to_unitary():
|
|
123
|
+
def test_kraus_fallback_to_unitary() -> None:
|
|
124
124
|
u = np.array([[1, 0], [1, 0]])
|
|
125
125
|
|
|
126
126
|
class ReturnsUnitary:
|
|
@@ -160,12 +160,12 @@ class HasKrausWhenDecomposed(cirq.testing.SingleQubitGate):
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
@pytest.mark.parametrize('cls', [HasKraus, HasMixture, HasUnitary])
|
|
163
|
-
def test_has_kraus(cls):
|
|
163
|
+
def test_has_kraus(cls) -> None:
|
|
164
164
|
assert cirq.has_kraus(cls())
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
@pytest.mark.parametrize('decomposed_cls', [HasKraus, HasMixture, HasUnitary])
|
|
168
|
-
def test_has_kraus_when_decomposed(decomposed_cls):
|
|
168
|
+
def test_has_kraus_when_decomposed(decomposed_cls) -> None:
|
|
169
169
|
op = HasKrausWhenDecomposed(decomposed_cls).on(cirq.NamedQubit('test'))
|
|
170
170
|
assert cirq.has_kraus(op)
|
|
171
171
|
assert not cirq.has_kraus(op, allow_decompose=False)
|
|
@@ -28,7 +28,7 @@ class ReturnsObj:
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@pytest.mark.parametrize('gate', [ReturnsStr(), ReturnsObj()])
|
|
31
|
-
def test_measurement_key_name(gate):
|
|
31
|
+
def test_measurement_key_name(gate) -> None:
|
|
32
32
|
assert isinstance(cirq.measurement_key_name(gate), str)
|
|
33
33
|
assert cirq.measurement_key_name(gate) == 'door locker'
|
|
34
34
|
assert cirq.measurement_key_obj(gate) == cirq.MeasurementKey(name='door locker')
|
|
@@ -39,7 +39,7 @@ def test_measurement_key_name(gate):
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
@pytest.mark.parametrize('gate', [ReturnsStr(), ReturnsObj()])
|
|
42
|
-
def test_measurement_key_obj(gate):
|
|
42
|
+
def test_measurement_key_obj(gate) -> None:
|
|
43
43
|
assert isinstance(cirq.measurement_key_obj(gate), cirq.MeasurementKey)
|
|
44
44
|
assert cirq.measurement_key_obj(gate) == cirq.MeasurementKey(name='door locker')
|
|
45
45
|
assert cirq.measurement_key_obj(gate) == 'door locker'
|
|
@@ -50,7 +50,7 @@ def test_measurement_key_obj(gate):
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@pytest.mark.parametrize('key_method', [cirq.measurement_key_name, cirq.measurement_key_obj])
|
|
53
|
-
def test_measurement_key_no_method(key_method):
|
|
53
|
+
def test_measurement_key_no_method(key_method) -> None:
|
|
54
54
|
class NoMethod:
|
|
55
55
|
pass
|
|
56
56
|
|
|
@@ -73,7 +73,7 @@ def test_measurement_key_no_method(key_method):
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
@pytest.mark.parametrize('key_method', [cirq.measurement_key_name, cirq.measurement_key_obj])
|
|
76
|
-
def test_measurement_key_not_implemented_default_behavior(key_method):
|
|
76
|
+
def test_measurement_key_not_implemented_default_behavior(key_method) -> None:
|
|
77
77
|
class ReturnsNotImplemented:
|
|
78
78
|
def _measurement_key_name_(self):
|
|
79
79
|
return NotImplemented
|
|
@@ -89,7 +89,7 @@ def test_measurement_key_not_implemented_default_behavior(key_method):
|
|
|
89
89
|
assert key_method(ReturnsNotImplemented(), 'a') == 'a'
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def test_is_measurement():
|
|
92
|
+
def test_is_measurement() -> None:
|
|
93
93
|
q = cirq.NamedQubit('q')
|
|
94
94
|
assert cirq.is_measurement(cirq.measure(q))
|
|
95
95
|
assert cirq.is_measurement(cirq.MeasurementGate(num_qubits=1, key='b'))
|
|
@@ -109,7 +109,7 @@ def test_is_measurement():
|
|
|
109
109
|
assert not cirq.is_measurement(NotImplementedOperation())
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
def test_measurement_without_key():
|
|
112
|
+
def test_measurement_without_key() -> None:
|
|
113
113
|
class MeasurementWithoutKey:
|
|
114
114
|
def _is_measurement_(self):
|
|
115
115
|
return True
|
|
@@ -120,7 +120,7 @@ def test_measurement_without_key():
|
|
|
120
120
|
assert cirq.is_measurement(MeasurementWithoutKey())
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def test_non_measurement_with_key():
|
|
123
|
+
def test_non_measurement_with_key() -> None:
|
|
124
124
|
class NonMeasurementGate(cirq.Gate):
|
|
125
125
|
def _is_measurement_(self):
|
|
126
126
|
return False # pragma: no cover
|
|
@@ -155,7 +155,7 @@ def test_non_measurement_with_key():
|
|
|
155
155
|
('key_method', 'keys'),
|
|
156
156
|
[(cirq.measurement_key_names, {'a', 'b'}), (cirq.measurement_key_objs, {'c', 'd'})],
|
|
157
157
|
)
|
|
158
|
-
def test_measurement_keys(key_method, keys):
|
|
158
|
+
def test_measurement_keys(key_method, keys) -> None:
|
|
159
159
|
class MeasurementKeysGate(cirq.Gate):
|
|
160
160
|
def _measurement_key_names_(self):
|
|
161
161
|
return frozenset(['a', 'b'])
|
|
@@ -180,7 +180,7 @@ def test_measurement_keys(key_method, keys):
|
|
|
180
180
|
assert key_method(MeasurementKeysGate().on(a)) == keys
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
def test_measurement_key_mapping():
|
|
183
|
+
def test_measurement_key_mapping() -> None:
|
|
184
184
|
class MultiKeyGate:
|
|
185
185
|
def __init__(self, keys):
|
|
186
186
|
self._keys = frozenset(keys)
|
|
@@ -217,7 +217,7 @@ def test_measurement_key_mapping():
|
|
|
217
217
|
assert cirq.measurement_key_names(mkg_cdx) == {'c', 'd'}
|
|
218
218
|
|
|
219
219
|
|
|
220
|
-
def test_measurement_key_path():
|
|
220
|
+
def test_measurement_key_path() -> None:
|
|
221
221
|
class MultiKeyGate:
|
|
222
222
|
def __init__(self, keys):
|
|
223
223
|
self._keys = frozenset(cirq.MeasurementKey.parse_serialized(key) for key in keys)
|
|
@@ -54,7 +54,7 @@ class HasQuditUnitary:
|
|
|
54
54
|
@pytest.mark.parametrize(
|
|
55
55
|
'val', (NoMethod(), ReturnsNotImplemented(), HasQuditUnitary(), 123, np.eye(2), object(), cirq)
|
|
56
56
|
)
|
|
57
|
-
def test_raises_no_pauli_expansion(val):
|
|
57
|
+
def test_raises_no_pauli_expansion(val) -> None:
|
|
58
58
|
assert cirq.pauli_expansion(val, default=None) is None
|
|
59
59
|
with pytest.raises(TypeError, match='No Pauli expansion'):
|
|
60
60
|
cirq.pauli_expansion(val)
|
|
@@ -78,7 +78,7 @@ def test_raises_no_pauli_expansion(val):
|
|
|
78
78
|
),
|
|
79
79
|
),
|
|
80
80
|
)
|
|
81
|
-
def test_pauli_expansion(val, expected_expansion):
|
|
81
|
+
def test_pauli_expansion(val, expected_expansion) -> None:
|
|
82
82
|
actual_expansion = cirq.pauli_expansion(val)
|
|
83
83
|
assert cirq.approx_eq(actual_expansion, expected_expansion, atol=1e-12)
|
|
84
84
|
assert set(actual_expansion.keys()) == set(expected_expansion.keys())
|