cirq-core 1.6.0.dev20250509215532__py3-none-any.whl → 1.6.0.dev20250512192405__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cirq-core might be problematic. Click here for more details.

Files changed (167) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +2 -2
  3. cirq/circuits/_block_diagram_drawer_test.py +6 -6
  4. cirq/circuits/_box_drawing_character_data_test.py +1 -1
  5. cirq/circuits/insert_strategy_test.py +2 -2
  6. cirq/circuits/optimization_pass_test.py +5 -5
  7. cirq/contrib/acquaintance/inspection_utils_test.py +2 -2
  8. cirq/contrib/acquaintance/mutation_utils_test.py +2 -2
  9. cirq/contrib/acquaintance/optimizers_test.py +1 -1
  10. cirq/contrib/acquaintance/shift_test.py +6 -6
  11. cirq/contrib/acquaintance/strategies/cubic_test.py +2 -2
  12. cirq/contrib/acquaintance/topological_sort_test.py +1 -1
  13. cirq/contrib/hacks/disable_validation_test.py +1 -1
  14. cirq/contrib/json_test.py +3 -3
  15. cirq/contrib/noise_models/noise_models_test.py +8 -8
  16. cirq/contrib/paulistring/clifford_optimize_test.py +5 -5
  17. cirq/contrib/paulistring/clifford_target_gateset_test.py +11 -11
  18. cirq/contrib/paulistring/optimize_test.py +3 -3
  19. cirq/contrib/paulistring/pauli_string_dag_test.py +1 -1
  20. cirq/contrib/paulistring/pauli_string_optimize_test.py +3 -3
  21. cirq/contrib/paulistring/recombine_test.py +1 -1
  22. cirq/contrib/paulistring/separate_test.py +1 -1
  23. cirq/contrib/qasm_import/_parser_test.py +67 -67
  24. cirq/contrib/qcircuit/qcircuit_pdf_test.py +1 -1
  25. cirq/contrib/qcircuit/qcircuit_test.py +6 -6
  26. cirq/contrib/routing/greedy_test.py +2 -2
  27. cirq/contrib/routing/initialization_test.py +3 -3
  28. cirq/contrib/svg/svg_test.py +5 -5
  29. cirq/devices/device_test.py +4 -4
  30. cirq/devices/insertion_noise_model_test.py +5 -5
  31. cirq/devices/named_topologies_test.py +10 -10
  32. cirq/devices/noise_properties_test.py +1 -1
  33. cirq/experiments/n_qubit_tomography_test.py +5 -5
  34. cirq/experiments/t1_decay_experiment_test.py +11 -11
  35. cirq/interop/quirk/cells/arithmetic_cells_test.py +14 -14
  36. cirq/interop/quirk/cells/control_cells_test.py +5 -5
  37. cirq/interop/quirk/cells/frequency_space_cells_test.py +1 -1
  38. cirq/interop/quirk/cells/ignored_cells_test.py +1 -1
  39. cirq/interop/quirk/cells/input_cells_test.py +5 -5
  40. cirq/interop/quirk/cells/input_rotation_cells_test.py +7 -7
  41. cirq/interop/quirk/cells/measurement_cells_test.py +1 -1
  42. cirq/interop/quirk/cells/qubit_permutation_cells_test.py +7 -7
  43. cirq/interop/quirk/cells/scalar_cells_test.py +1 -1
  44. cirq/interop/quirk/cells/single_qubit_rotation_cells_test.py +3 -3
  45. cirq/interop/quirk/cells/swap_cell_test.py +4 -4
  46. cirq/interop/quirk/cells/testing_test.py +6 -6
  47. cirq/interop/quirk/cells/unsupported_cells_test.py +2 -2
  48. cirq/linalg/combinators_test.py +7 -7
  49. cirq/linalg/diagonalize_test.py +10 -10
  50. cirq/linalg/operator_spaces_test.py +11 -11
  51. cirq/linalg/tolerance_test.py +4 -4
  52. cirq/neutral_atoms/convert_to_neutral_atom_gates_test.py +1 -1
  53. cirq/ops/arithmetic_operation_test.py +2 -2
  54. cirq/ops/common_channels_test.py +80 -80
  55. cirq/ops/fsim_gate_test.py +26 -26
  56. cirq/ops/gate_features_test.py +3 -3
  57. cirq/ops/greedy_qubit_manager_test.py +3 -3
  58. cirq/ops/mixed_unitary_channel_test.py +11 -11
  59. cirq/ops/parallel_gate_test.py +16 -16
  60. cirq/ops/parity_gates_test.py +34 -32
  61. cirq/ops/pauli_gates_test.py +20 -20
  62. cirq/ops/pauli_interaction_gate_test.py +8 -8
  63. cirq/ops/pauli_sum_exponential_test.py +10 -10
  64. cirq/ops/permutation_gate_test.py +8 -8
  65. cirq/ops/phased_iswap_gate_test.py +15 -15
  66. cirq/ops/qubit_manager_test.py +4 -4
  67. cirq/ops/random_gate_channel_test.py +11 -11
  68. cirq/ops/state_preparation_channel_test.py +8 -8
  69. cirq/ops/swap_gates_test.py +17 -17
  70. cirq/ops/tags_test.py +2 -2
  71. cirq/ops/three_qubit_gates_test.py +17 -17
  72. cirq/ops/two_qubit_diagonal_gate_test.py +8 -8
  73. cirq/ops/uniform_superposition_gate_test.py +3 -3
  74. cirq/protocols/act_on_protocol_test.py +6 -6
  75. cirq/protocols/circuit_diagram_info_protocol_test.py +13 -13
  76. cirq/protocols/control_key_protocol_test.py +1 -1
  77. cirq/protocols/decompose_protocol_test.py +12 -12
  78. cirq/protocols/equal_up_to_global_phase_protocol_test.py +6 -6
  79. cirq/protocols/has_stabilizer_effect_protocol_test.py +5 -5
  80. cirq/protocols/has_unitary_protocol_test.py +8 -8
  81. cirq/protocols/hash_from_pickle_test.py +1 -1
  82. cirq/protocols/inverse_protocol_test.py +2 -2
  83. cirq/protocols/kraus_protocol_test.py +9 -9
  84. cirq/protocols/measurement_key_protocol_test.py +10 -10
  85. cirq/protocols/pauli_expansion_protocol_test.py +2 -2
  86. cirq/protocols/phase_protocol_test.py +1 -1
  87. cirq/protocols/qasm_test.py +3 -3
  88. cirq/protocols/qid_shape_protocol_test.py +1 -1
  89. cirq/protocols/resolve_parameters_test.py +5 -5
  90. cirq/protocols/trace_distance_bound_test.py +1 -1
  91. cirq/qis/channels_test.py +16 -16
  92. cirq/qis/measures_test.py +16 -14
  93. cirq/qis/noise_utils_test.py +7 -7
  94. cirq/sim/clifford/clifford_tableau_simulation_state_test.py +3 -3
  95. cirq/sim/clifford/stabilizer_ch_form_simulation_state_test.py +6 -6
  96. cirq/sim/clifford/stabilizer_sampler_test.py +2 -2
  97. cirq/sim/clifford/stabilizer_simulation_state_test.py +4 -4
  98. cirq/sim/clifford/stabilizer_state_ch_form_test.py +2 -2
  99. cirq/sim/density_matrix_simulation_state_test.py +8 -8
  100. cirq/sim/density_matrix_utils_test.py +36 -36
  101. cirq/sim/simulation_product_state_test.py +22 -22
  102. cirq/sim/simulation_state_test.py +12 -12
  103. cirq/sim/simulation_utils_test.py +1 -1
  104. cirq/sim/state_vector_simulation_state_test.py +12 -12
  105. cirq/study/flatten_expressions_test.py +11 -11
  106. cirq/study/resolver_test.py +20 -20
  107. cirq/testing/consistent_act_on_test.py +1 -1
  108. cirq/testing/consistent_channels_test.py +8 -8
  109. cirq/testing/consistent_controlled_gate_op_test.py +2 -2
  110. cirq/testing/consistent_decomposition_test.py +2 -2
  111. cirq/testing/consistent_pauli_expansion_test.py +1 -1
  112. cirq/testing/consistent_phase_by_test.py +1 -1
  113. cirq/testing/consistent_qasm_test.py +1 -1
  114. cirq/testing/consistent_specified_has_unitary_test.py +4 -4
  115. cirq/testing/consistent_unitary_test.py +2 -2
  116. cirq/testing/deprecation_test.py +2 -2
  117. cirq/testing/devices_test.py +4 -4
  118. cirq/testing/equivalent_basis_map_test.py +2 -2
  119. cirq/testing/equivalent_repr_eval_test.py +3 -3
  120. cirq/testing/gate_features_test.py +5 -5
  121. cirq/testing/json_test.py +3 -3
  122. cirq/testing/lin_alg_utils_test.py +12 -12
  123. cirq/testing/logs_test.py +7 -7
  124. cirq/testing/no_identifier_qubit_test.py +3 -3
  125. cirq/testing/op_tree_test.py +1 -1
  126. cirq/testing/order_tester_test.py +6 -6
  127. cirq/testing/pytest_utils_test.py +2 -2
  128. cirq/testing/random_circuit_test.py +5 -5
  129. cirq/testing/repr_pretty_tester_test.py +3 -3
  130. cirq/testing/routing_devices_test.py +6 -6
  131. cirq/testing/sample_circuits_test.py +1 -1
  132. cirq/testing/sample_gates_test.py +2 -2
  133. cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py +3 -3
  134. cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +7 -7
  135. cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +6 -6
  136. cirq/transformers/analytical_decompositions/two_qubit_to_fsim_test.py +5 -5
  137. cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py +1 -1
  138. cirq/transformers/drop_empty_moments_test.py +2 -2
  139. cirq/transformers/eject_phased_paulis_test.py +9 -9
  140. cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation_test.py +7 -7
  141. cirq/transformers/insertion_sort_test.py +1 -1
  142. cirq/transformers/merge_k_qubit_gates_test.py +9 -9
  143. cirq/transformers/qubit_management_transformers_test.py +3 -3
  144. cirq/transformers/randomized_measurements_test.py +8 -4
  145. cirq/transformers/routing/line_initial_mapper_test.py +5 -5
  146. cirq/transformers/routing/route_circuit_cqc_test.py +13 -13
  147. cirq/transformers/routing/visualize_routed_circuit_test.py +2 -2
  148. cirq/transformers/synchronize_terminal_measurements_test.py +10 -10
  149. cirq/transformers/target_gatesets/compilation_target_gateset_test.py +8 -8
  150. cirq/transformers/target_gatesets/cz_gateset_test.py +17 -17
  151. cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +23 -23
  152. cirq/value/angle_test.py +3 -3
  153. cirq/value/classical_data_test.py +8 -8
  154. cirq/value/periodic_value_test.py +9 -7
  155. cirq/value/probability_test.py +2 -2
  156. cirq/value/value_equality_attr_test.py +11 -11
  157. cirq/vis/histogram_test.py +2 -2
  158. cirq/vis/state_histogram_test.py +5 -5
  159. cirq/vis/vis_utils_test.py +1 -1
  160. cirq/work/observable_grouping_test.py +8 -8
  161. cirq/work/observable_readout_calibration_test.py +1 -1
  162. cirq/work/zeros_sampler_test.py +4 -4
  163. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/METADATA +1 -1
  164. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/RECORD +167 -167
  165. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/WHEEL +0 -0
  166. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/licenses/LICENSE +0 -0
  167. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/top_level.txt +0 -0
@@ -40,7 +40,7 @@ class ExpectsArgsQubits:
40
40
  return 'text'
41
41
 
42
42
 
43
- def test_qasm():
43
+ def test_qasm() -> None:
44
44
  assert cirq.qasm(NoMethod(), default=None) is None
45
45
  assert cirq.qasm(NoMethod(), default=5) == 5
46
46
  assert cirq.qasm(ReturnsText()) == 'text'
@@ -54,12 +54,12 @@ def test_qasm():
54
54
  assert cirq.qasm(ExpectsArgsQubits(), args=cirq.QasmArgs(), qubits=()) == 'text'
55
55
 
56
56
 
57
- def test_qasm_qubits_improperly_supplied():
57
+ def test_qasm_qubits_improperly_supplied() -> None:
58
58
  with pytest.raises(TypeError, match="does not expect qubits or args to be specified"):
59
59
  _ = cirq.qasm(cirq.Circuit(), qubits=[cirq.LineQubit(1)])
60
60
 
61
61
 
62
- def test_qasm_args_formatting():
62
+ def test_qasm_args_formatting() -> None:
63
63
  args = cirq.QasmArgs()
64
64
  assert args.format_field(0.01, '') == '0.01'
65
65
  assert args.format_field(0.01, 'half_turns') == 'pi*0.01'
@@ -17,7 +17,7 @@ import pytest
17
17
  import cirq
18
18
 
19
19
 
20
- def test_qid_shape():
20
+ def test_qid_shape() -> None:
21
21
  class ShapeObj:
22
22
  def _qid_shape_(self):
23
23
  return (1, 2, 3)
@@ -20,7 +20,7 @@ from cirq.study import ParamResolver
20
20
 
21
21
 
22
22
  @pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
23
- def test_resolve_parameters(resolve_fn):
23
+ def test_resolve_parameters(resolve_fn) -> None:
24
24
  class NoMethod:
25
25
  pass
26
26
 
@@ -74,7 +74,7 @@ def test_resolve_parameters(resolve_fn):
74
74
  assert resolve_fn(1j, resolver) == 1j
75
75
 
76
76
 
77
- def test_is_parameterized():
77
+ def test_is_parameterized() -> None:
78
78
  a, b = tuple(sympy.Symbol(l) for l in 'ab')
79
79
  x, y = 0, 4
80
80
  assert not cirq.is_parameterized((x, y))
@@ -90,7 +90,7 @@ def test_is_parameterized():
90
90
  assert not cirq.is_parameterized(1j)
91
91
 
92
92
 
93
- def test_parameter_names():
93
+ def test_parameter_names() -> None:
94
94
  a, b, c = tuple(sympy.Symbol(l) for l in 'abc')
95
95
  x, y, z = 0, 4, 7
96
96
  assert cirq.parameter_names((a, b, c)) == {'a', 'b', 'c'}
@@ -105,7 +105,7 @@ def test_parameter_names():
105
105
 
106
106
 
107
107
  @pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
108
- def test_skips_empty_resolution(resolve_fn):
108
+ def test_skips_empty_resolution(resolve_fn) -> None:
109
109
  class Tester:
110
110
  def _resolve_parameters_(self, resolver, recursive):
111
111
  return 5
@@ -115,7 +115,7 @@ def test_skips_empty_resolution(resolve_fn):
115
115
  assert resolve_fn(t, {'x': 2}) == 5
116
116
 
117
117
 
118
- def test_recursive_resolve():
118
+ def test_recursive_resolve() -> None:
119
119
  a, b, c = [sympy.Symbol(l) for l in 'abc']
120
120
  resolver = cirq.ParamResolver({a: b + 3, b: c + 2, c: 1})
121
121
  assert cirq.resolve_parameters_once(a, resolver) == b + 3
@@ -17,7 +17,7 @@ import numpy as np
17
17
  import cirq
18
18
 
19
19
 
20
- def test_trace_distance_bound():
20
+ def test_trace_distance_bound() -> None:
21
21
  class NoMethod:
22
22
  pass
23
23
 
cirq/qis/channels_test.py CHANGED
@@ -65,7 +65,7 @@ def compute_choi(channel: cirq.SupportsKraus) -> np.ndarray:
65
65
  ),
66
66
  ),
67
67
  )
68
- def test_kraus_to_choi(kraus_operators, expected_choi):
68
+ def test_kraus_to_choi(kraus_operators, expected_choi) -> None:
69
69
  """Verifies that cirq.kraus_to_choi computes the correct Choi matrix."""
70
70
  assert np.allclose(cirq.kraus_to_choi(kraus_operators), expected_choi)
71
71
 
@@ -89,7 +89,7 @@ def test_kraus_to_choi(kraus_operators, expected_choi):
89
89
  ),
90
90
  ),
91
91
  )
92
- def test_choi_to_kraus_invalid_input(choi, error):
92
+ def test_choi_to_kraus_invalid_input(choi, error) -> None:
93
93
  with pytest.raises(ValueError, match=error):
94
94
  _ = cirq.choi_to_kraus(choi)
95
95
 
@@ -143,7 +143,7 @@ def test_choi_to_kraus_invalid_input(choi, error):
143
143
  ),
144
144
  ),
145
145
  )
146
- def test_choi_to_kraus_fixed_values(choi, expected_kraus):
146
+ def test_choi_to_kraus_fixed_values(choi, expected_kraus) -> None:
147
147
  """Verifies that cirq.choi_to_kraus gives correct results on a few fixed inputs."""
148
148
  actual_kraus = cirq.choi_to_kraus(choi)
149
149
  assert len(actual_kraus) == len(expected_kraus)
@@ -178,7 +178,7 @@ def test_choi_to_kraus_fixed_values(choi, expected_kraus):
178
178
  ),
179
179
  ),
180
180
  )
181
- def test_choi_to_kraus_action_on_operatorial_basis(choi):
181
+ def test_choi_to_kraus_action_on_operatorial_basis(choi) -> None:
182
182
  """Verifies that cirq.choi_to_kraus computes a valid Kraus representation."""
183
183
  kraus_operators = cirq.choi_to_kraus(choi)
184
184
  c = np.reshape(choi, (2, 2, 2, 2))
@@ -217,14 +217,14 @@ def test_choi_to_kraus_action_on_operatorial_basis(choi):
217
217
  # fmt: on
218
218
  ),
219
219
  )
220
- def test_choi_to_kraus_inverse_of_kraus_to_choi(choi):
220
+ def test_choi_to_kraus_inverse_of_kraus_to_choi(choi) -> None:
221
221
  """Verifies that cirq.kraus_to_choi(cirq.choi_to_kraus(.)) is identity on Choi matrices."""
222
222
  kraus = cirq.choi_to_kraus(choi)
223
223
  recovered_choi = cirq.kraus_to_choi(kraus)
224
224
  assert np.allclose(recovered_choi, choi)
225
225
 
226
226
 
227
- def test_choi_to_kraus_atol():
227
+ def test_choi_to_kraus_atol() -> None:
228
228
  """Verifies that insignificant Kraus operators are omitted."""
229
229
  choi = cirq.kraus_to_choi(cirq.kraus(cirq.phase_damp(1e-6)))
230
230
  assert len(cirq.choi_to_kraus(choi, atol=1e-2)) == 1
@@ -242,7 +242,7 @@ def test_choi_to_kraus_atol():
242
242
  cirq.amplitude_damp(0.2),
243
243
  ),
244
244
  )
245
- def test_operation_to_choi(channel):
245
+ def test_operation_to_choi(channel) -> None:
246
246
  """Verifies that cirq.operation_to_choi correctly computes the Choi matrix."""
247
247
  n_qubits = cirq.num_qubits(channel)
248
248
  actual = cirq.operation_to_choi(channel)
@@ -251,7 +251,7 @@ def test_operation_to_choi(channel):
251
251
  assert np.all(actual == expected)
252
252
 
253
253
 
254
- def test_choi_for_completely_dephasing_channel():
254
+ def test_choi_for_completely_dephasing_channel() -> None:
255
255
  """Checks cirq.operation_to_choi on the completely dephasing channel."""
256
256
  assert np.all(cirq.operation_to_choi(cirq.phase_damp(1)) == np.diag([1, 0, 0, 1]))
257
257
 
@@ -268,7 +268,7 @@ def test_choi_for_completely_dephasing_channel():
268
268
  ),
269
269
  ),
270
270
  )
271
- def test_superoperator_to_kraus_fixed_values(superoperator, expected_kraus_operators):
271
+ def test_superoperator_to_kraus_fixed_values(superoperator, expected_kraus_operators) -> None:
272
272
  """Verifies that cirq.kraus_to_superoperator computes the correct channel matrix."""
273
273
  actual_kraus_operators = cirq.superoperator_to_kraus(superoperator)
274
274
  for i in (0, 1):
@@ -306,14 +306,14 @@ def test_superoperator_to_kraus_fixed_values(superoperator, expected_kraus_opera
306
306
  # fmt: on
307
307
  ),
308
308
  )
309
- def test_superoperator_to_kraus_inverse_of_kraus_to_superoperator(superoperator):
309
+ def test_superoperator_to_kraus_inverse_of_kraus_to_superoperator(superoperator) -> None:
310
310
  """Verifies that cirq.kraus_to_superoperator(cirq.superoperator_to_kraus(.)) is identity."""
311
311
  kraus = cirq.superoperator_to_kraus(superoperator)
312
312
  recovered_superoperator = cirq.kraus_to_superoperator(kraus)
313
313
  assert np.allclose(recovered_superoperator, superoperator)
314
314
 
315
315
 
316
- def test_superoperator_to_kraus_atol():
316
+ def test_superoperator_to_kraus_atol() -> None:
317
317
  """Verifies that insignificant Kraus operators are omitted."""
318
318
  superop = cirq.kraus_to_superoperator(cirq.kraus(cirq.phase_damp(1e-6)))
319
319
  assert len(cirq.superoperator_to_kraus(superop, atol=1e-2)) == 1
@@ -338,7 +338,7 @@ def test_superoperator_to_kraus_atol():
338
338
  ),
339
339
  ),
340
340
  )
341
- def test_choi_to_superoperator_invalid_input(choi, error):
341
+ def test_choi_to_superoperator_invalid_input(choi, error) -> None:
342
342
  with pytest.raises(ValueError, match=error):
343
343
  _ = cirq.choi_to_superoperator(choi)
344
344
 
@@ -346,7 +346,7 @@ def test_choi_to_superoperator_invalid_input(choi, error):
346
346
  @pytest.mark.parametrize(
347
347
  'superoperator, error', ((np.array([[1, 2, 3], [4, 5, 6]]), "shape"), (np.eye(2), "shape"))
348
348
  )
349
- def test_superoperator_to_choi_invalid_input(superoperator, error):
349
+ def test_superoperator_to_choi_invalid_input(superoperator, error) -> None:
350
350
  with pytest.raises(ValueError, match=error):
351
351
  _ = cirq.superoperator_to_choi(superoperator)
352
352
 
@@ -402,7 +402,7 @@ def test_superoperator_to_choi_invalid_input(superoperator, error):
402
402
  ),
403
403
  ),
404
404
  )
405
- def test_superoperator_vs_choi_fixed_values(superoperator, choi):
405
+ def test_superoperator_vs_choi_fixed_values(superoperator, choi) -> None:
406
406
  recovered_choi = cirq.superoperator_to_choi(superoperator)
407
407
  assert np.allclose(recovered_choi, choi)
408
408
 
@@ -436,7 +436,7 @@ def test_superoperator_vs_choi_fixed_values(superoperator, choi):
436
436
  # fmt: on
437
437
  ),
438
438
  )
439
- def test_choi_to_superoperator_inverse_of_superoperator_to_choi(choi):
439
+ def test_choi_to_superoperator_inverse_of_superoperator_to_choi(choi) -> None:
440
440
  superoperator = cirq.choi_to_superoperator(choi)
441
441
  recovered_choi = cirq.superoperator_to_choi(superoperator)
442
442
  assert np.allclose(recovered_choi, choi)
@@ -445,6 +445,6 @@ def test_choi_to_superoperator_inverse_of_superoperator_to_choi(choi):
445
445
  assert np.allclose(recovered_superoperator, superoperator)
446
446
 
447
447
 
448
- def test_superoperator_for_completely_dephasing_channel():
448
+ def test_superoperator_for_completely_dephasing_channel() -> None:
449
449
  """Checks cirq.operation_to_superoperator on the completely dephasing channel."""
450
450
  assert np.all(cirq.operation_to_superoperator(cirq.phase_damp(1)) == np.diag([1, 0, 0, 1]))
cirq/qis/measures_test.py CHANGED
@@ -25,7 +25,7 @@ MAT2 = cirq.testing.random_density_matrix(N)
25
25
  U = cirq.testing.random_unitary(N)
26
26
 
27
27
 
28
- def test_fidelity_symmetric():
28
+ def test_fidelity_symmetric() -> None:
29
29
  np.testing.assert_allclose(cirq.fidelity(VEC1, VEC2), cirq.fidelity(VEC2, VEC1))
30
30
  np.testing.assert_allclose(cirq.fidelity(VEC1, MAT1), cirq.fidelity(MAT1, VEC1))
31
31
  np.testing.assert_allclose(
@@ -34,27 +34,27 @@ def test_fidelity_symmetric():
34
34
  )
35
35
 
36
36
 
37
- def test_bad_fidelity():
37
+ def test_bad_fidelity() -> None:
38
38
  arr = np.asarray([[[1j, 0], [0, 0]], [[0, 0], [0, 0]]])
39
39
  assert arr.ndim > 2
40
40
  assert arr.dtype.kind == 'c'
41
41
  _ = cirq.fidelity(arr, arr)
42
42
 
43
43
 
44
- def test_fidelity_between_zero_and_one():
44
+ def test_fidelity_between_zero_and_one() -> None:
45
45
  assert 0 <= cirq.fidelity(VEC1, VEC2) <= 1
46
46
  assert 0 <= cirq.fidelity(VEC1, MAT1) <= 1
47
47
  assert 0 <= cirq.fidelity(cirq.density_matrix(MAT1), MAT2) <= 1
48
48
 
49
49
 
50
- def test_fidelity_invariant_under_unitary_transformation():
50
+ def test_fidelity_invariant_under_unitary_transformation() -> None:
51
51
  np.testing.assert_allclose(
52
52
  cirq.fidelity(cirq.density_matrix(MAT1), MAT2),
53
53
  cirq.fidelity(cirq.density_matrix(U @ MAT1 @ U.T.conj()), U @ MAT2 @ U.T.conj()),
54
54
  )
55
55
 
56
56
 
57
- def test_fidelity_commuting_matrices():
57
+ def test_fidelity_commuting_matrices() -> None:
58
58
  d1 = np.random.uniform(size=N)
59
59
  d1 /= np.sum(d1)
60
60
  d2 = np.random.uniform(size=N)
@@ -67,7 +67,7 @@ def test_fidelity_commuting_matrices():
67
67
  )
68
68
 
69
69
 
70
- def test_fidelity_known_values():
70
+ def test_fidelity_known_values() -> None:
71
71
  vec1 = np.array([1, 1j, -1, -1j]) * 0.5
72
72
  vec2 = np.array([1, -1, 1, -1], dtype=np.complex128) * 0.5
73
73
  vec3 = np.array([1, 0, 0, 0], dtype=np.complex128)
@@ -94,7 +94,7 @@ def test_fidelity_known_values():
94
94
  np.testing.assert_allclose(cirq.fidelity(mat3, vec2), 0.7)
95
95
 
96
96
 
97
- def test_fidelity_numpy_arrays():
97
+ def test_fidelity_numpy_arrays() -> None:
98
98
  vec1 = np.array([1, 0, 0, 0, 0, 0, 0, 0], dtype=np.complex64)
99
99
  vec2 = np.array([1, 0, 0, 0], dtype=np.complex64)
100
100
  tensor1 = np.reshape(vec1, (2, 2, 2))
@@ -122,7 +122,7 @@ def test_fidelity_numpy_arrays():
122
122
  _ = cirq.fidelity(mat1, mat1)
123
123
 
124
124
 
125
- def test_fidelity_ints():
125
+ def test_fidelity_ints() -> None:
126
126
  assert cirq.fidelity(3, 4) == 0.0
127
127
  assert cirq.fidelity(4, 4) == 1.0
128
128
 
@@ -134,7 +134,7 @@ def test_fidelity_ints():
134
134
  _ = cirq.fidelity(1, 4, qid_shape=(2,))
135
135
 
136
136
 
137
- def test_fidelity_product_states():
137
+ def test_fidelity_product_states() -> None:
138
138
  a, b = cirq.LineQubit.range(2)
139
139
 
140
140
  np.testing.assert_allclose(
@@ -171,19 +171,19 @@ def test_fidelity_product_states():
171
171
  )
172
172
 
173
173
 
174
- def test_fidelity_fail_inference():
174
+ def test_fidelity_fail_inference() -> None:
175
175
  state_vector = cirq.one_hot(shape=(4,), dtype=np.complex128)
176
176
  state_tensor = np.reshape(state_vector, (2, 2))
177
177
  with pytest.raises(ValueError, match='Please specify'):
178
178
  _ = cirq.fidelity(state_tensor, 4)
179
179
 
180
180
 
181
- def test_fidelity_bad_shape():
181
+ def test_fidelity_bad_shape() -> None:
182
182
  with pytest.raises(ValueError, match='Invalid quantum state'):
183
183
  _ = cirq.fidelity(np.array([[[1.0]]]), np.array([[[1.0]]]), qid_shape=(1,))
184
184
 
185
185
 
186
- def test_von_neumann_entropy():
186
+ def test_von_neumann_entropy() -> None:
187
187
  # 1x1 matrix
188
188
  assert cirq.von_neumann_entropy(np.array([[1]])) == 0
189
189
  # An EPR pair state (|00> + |11>)(<00| + <11|)
@@ -243,7 +243,7 @@ def test_von_neumann_entropy():
243
243
  (cirq.TOFFOLI, 9 / 16),
244
244
  ),
245
245
  )
246
- def test_entanglement_fidelity_of_unitary_channels(gate, expected_entanglement_fidelity):
246
+ def test_entanglement_fidelity_of_unitary_channels(gate, expected_entanglement_fidelity) -> None:
247
247
  assert np.isclose(cirq.entanglement_fidelity(gate), expected_entanglement_fidelity)
248
248
 
249
249
 
@@ -261,7 +261,9 @@ def test_entanglement_fidelity_of_unitary_channels(gate, expected_entanglement_f
261
261
  (cirq.amplitude_damp, lambda gamma: 1 / 2 - gamma / 4 + np.sqrt(1 - gamma) / 2),
262
262
  ),
263
263
  )
264
- def test_entanglement_fidelity_of_noisy_channels(p, channel_factory, entanglement_fidelity_formula):
264
+ def test_entanglement_fidelity_of_noisy_channels(
265
+ p, channel_factory, entanglement_fidelity_formula
266
+ ) -> None:
265
267
  channel = channel_factory(p)
266
268
  actual_entanglement_fidelity = cirq.entanglement_fidelity(channel)
267
269
  expected_entanglement_fidelity = entanglement_fidelity_formula(p)
@@ -30,7 +30,7 @@ from cirq.qis.noise_utils import (
30
30
  'decay_constant,num_qubits,expected_output',
31
31
  [(0.01, 1, 1 - (0.99 * 1 / 2)), (0.05, 2, 1 - (0.95 * 3 / 4))],
32
32
  )
33
- def test_decay_constant_to_xeb_fidelity(decay_constant, num_qubits, expected_output):
33
+ def test_decay_constant_to_xeb_fidelity(decay_constant, num_qubits, expected_output) -> None:
34
34
  val = decay_constant_to_xeb_fidelity(decay_constant, num_qubits)
35
35
  assert val == expected_output
36
36
 
@@ -39,7 +39,7 @@ def test_decay_constant_to_xeb_fidelity(decay_constant, num_qubits, expected_out
39
39
  'decay_constant,num_qubits,expected_output',
40
40
  [(0.01, 1, 0.99 * 3 / 4), (0.05, 2, 0.95 * 15 / 16)],
41
41
  )
42
- def test_decay_constant_to_pauli_error(decay_constant, num_qubits, expected_output):
42
+ def test_decay_constant_to_pauli_error(decay_constant, num_qubits, expected_output) -> None:
43
43
  val = decay_constant_to_pauli_error(decay_constant, num_qubits)
44
44
  assert val == expected_output
45
45
 
@@ -48,7 +48,7 @@ def test_decay_constant_to_pauli_error(decay_constant, num_qubits, expected_outp
48
48
  'pauli_error,num_qubits,expected_output',
49
49
  [(0.01, 1, 1 - (0.01 / (3 / 4))), (0.05, 2, 1 - (0.05 / (15 / 16)))],
50
50
  )
51
- def test_pauli_error_to_decay_constant(pauli_error, num_qubits, expected_output):
51
+ def test_pauli_error_to_decay_constant(pauli_error, num_qubits, expected_output) -> None:
52
52
  val = pauli_error_to_decay_constant(pauli_error, num_qubits)
53
53
  assert val == expected_output
54
54
 
@@ -57,7 +57,7 @@ def test_pauli_error_to_decay_constant(pauli_error, num_qubits, expected_output)
57
57
  'xeb_fidelity,num_qubits,expected_output',
58
58
  [(0.01, 1, 1 - 0.99 / (1 / 2)), (0.05, 2, 1 - 0.95 / (3 / 4))],
59
59
  )
60
- def test_xeb_fidelity_to_decay_constant(xeb_fidelity, num_qubits, expected_output):
60
+ def test_xeb_fidelity_to_decay_constant(xeb_fidelity, num_qubits, expected_output) -> None:
61
61
  val = xeb_fidelity_to_decay_constant(xeb_fidelity, num_qubits)
62
62
  assert val == expected_output
63
63
 
@@ -69,7 +69,7 @@ def test_xeb_fidelity_to_decay_constant(xeb_fidelity, num_qubits, expected_outpu
69
69
  (4000, 1e4, (1 - np.exp(-4000 / 2e4)) / 2 + (1 - np.exp(-4000 / 1e4)) / 4),
70
70
  ],
71
71
  )
72
- def test_pauli_error_from_t1(t, t1_ns, expected_output):
72
+ def test_pauli_error_from_t1(t, t1_ns, expected_output) -> None:
73
73
  val = pauli_error_from_t1(t, t1_ns)
74
74
  assert val == expected_output
75
75
 
@@ -77,7 +77,7 @@ def test_pauli_error_from_t1(t, t1_ns, expected_output):
77
77
  @pytest.mark.parametrize(
78
78
  'decay_constant,num_qubits,expected_output', [(0.01, 1, 0.99 * 1 / 2), (0.05, 2, 0.95 * 3 / 4)]
79
79
  )
80
- def test_average_error(decay_constant, num_qubits, expected_output):
80
+ def test_average_error(decay_constant, num_qubits, expected_output) -> None:
81
81
  val = average_error(decay_constant, num_qubits)
82
82
  assert val == expected_output
83
83
 
@@ -85,7 +85,7 @@ def test_average_error(decay_constant, num_qubits, expected_output):
85
85
  @pytest.mark.parametrize(
86
86
  'T1_ns,Tphi_ns,gate_time_ns', [(1e4, 2e4, 25), (1e5, 2e3, 25), (1e4, 2e4, 4000)]
87
87
  )
88
- def test_decoherence_pauli_error(T1_ns, Tphi_ns, gate_time_ns):
88
+ def test_decoherence_pauli_error(T1_ns, Tphi_ns, gate_time_ns) -> None:
89
89
  val = decoherence_pauli_error(T1_ns, Tphi_ns, gate_time_ns)
90
90
  # Expected value is of the form:
91
91
  #
@@ -20,7 +20,7 @@ import pytest
20
20
  import cirq
21
21
 
22
22
 
23
- def test_unitary_fallback():
23
+ def test_unitary_fallback() -> None:
24
24
  class UnitaryXGate(cirq.testing.SingleQubitGate):
25
25
  def _unitary_(self):
26
26
  return np.array([[0, 1], [1, 0]])
@@ -57,7 +57,7 @@ def test_unitary_fallback():
57
57
  assert args.tableau == expected_args.tableau
58
58
 
59
59
 
60
- def test_cannot_act():
60
+ def test_cannot_act() -> None:
61
61
  class NoDetails:
62
62
  pass
63
63
 
@@ -77,7 +77,7 @@ def test_cannot_act():
77
77
  cirq.act_on(NoDetailsSingleQubitGate(), args, [cirq.LineQubit(1)])
78
78
 
79
79
 
80
- def test_copy():
80
+ def test_copy() -> None:
81
81
  args = cirq.CliffordTableauSimulationState(
82
82
  tableau=cirq.CliffordTableau(num_qubits=3),
83
83
  qubits=cirq.LineQubit.range(3),
@@ -18,14 +18,14 @@ import pytest
18
18
  import cirq
19
19
 
20
20
 
21
- def test_init_state():
21
+ def test_init_state() -> None:
22
22
  args = cirq.StabilizerChFormSimulationState(qubits=cirq.LineQubit.range(1), initial_state=1)
23
23
  np.testing.assert_allclose(args.state.state_vector(), [0, 1])
24
24
  with pytest.raises(ValueError, match='Must specify qubits'):
25
25
  _ = cirq.StabilizerChFormSimulationState(initial_state=1)
26
26
 
27
27
 
28
- def test_cannot_act():
28
+ def test_cannot_act() -> None:
29
29
  class NoDetails(cirq.testing.SingleQubitGate):
30
30
  pass
31
31
 
@@ -35,7 +35,7 @@ def test_cannot_act():
35
35
  cirq.act_on(NoDetails(), args, qubits=())
36
36
 
37
37
 
38
- def test_gate_with_act_on():
38
+ def test_gate_with_act_on() -> None:
39
39
  class CustomGate(cirq.testing.SingleQubitGate):
40
40
  def _act_on_(self, sim_state, qubits):
41
41
  if isinstance(sim_state, cirq.StabilizerChFormSimulationState):
@@ -53,7 +53,7 @@ def test_gate_with_act_on():
53
53
  np.testing.assert_allclose(state.gamma, [0, 1, 0])
54
54
 
55
55
 
56
- def test_unitary_fallback_y():
56
+ def test_unitary_fallback_y() -> None:
57
57
  class UnitaryYGate(cirq.Gate):
58
58
  def num_qubits(self) -> int:
59
59
  return 1
@@ -72,7 +72,7 @@ def test_unitary_fallback_y():
72
72
  np.testing.assert_allclose(args.state.state_vector(), expected_args.state.state_vector())
73
73
 
74
74
 
75
- def test_unitary_fallback_h():
75
+ def test_unitary_fallback_h() -> None:
76
76
  class UnitaryHGate(cirq.Gate):
77
77
  def num_qubits(self) -> int:
78
78
  return 1
@@ -91,7 +91,7 @@ def test_unitary_fallback_h():
91
91
  np.testing.assert_allclose(args.state.state_vector(), expected_args.state.state_vector())
92
92
 
93
93
 
94
- def test_copy():
94
+ def test_copy() -> None:
95
95
  args = cirq.StabilizerChFormSimulationState(
96
96
  qubits=cirq.LineQubit.range(3), prng=np.random.RandomState()
97
97
  )
@@ -17,7 +17,7 @@ import numpy as np
17
17
  import cirq
18
18
 
19
19
 
20
- def test_produces_samples():
20
+ def test_produces_samples() -> None:
21
21
  a, b = cirq.LineQubit.range(2)
22
22
  c = cirq.Circuit(cirq.H(a), cirq.CNOT(a, b), cirq.measure(a, key='a'), cirq.measure(b, key='b'))
23
23
 
@@ -26,7 +26,7 @@ def test_produces_samples():
26
26
  assert np.all(result['a'] ^ result['b'] == 0)
27
27
 
28
28
 
29
- def test_reset():
29
+ def test_reset() -> None:
30
30
  q = cirq.LineQubit(0)
31
31
  sampler = cirq.StabilizerSampler()
32
32
  c = cirq.Circuit(cirq.X(q), cirq.reset(q), cirq.measure(q))
@@ -20,7 +20,7 @@ import sympy
20
20
  import cirq
21
21
 
22
22
 
23
- def test_apply_gate():
23
+ def test_apply_gate() -> None:
24
24
  q0, q1 = cirq.LineQubit.range(2)
25
25
  state = mock.Mock()
26
26
  args = cirq.StabilizerSimulationState(state=state, qubits=[q0, q1])
@@ -89,7 +89,7 @@ def test_apply_gate():
89
89
  state.apply_x.assert_not_called()
90
90
 
91
91
 
92
- def test_apply_mixture():
92
+ def test_apply_mixture() -> None:
93
93
  q0 = cirq.LineQubit(0)
94
94
  state = mock.Mock()
95
95
  args = cirq.StabilizerSimulationState(state=state, qubits=[q0])
@@ -100,7 +100,7 @@ def test_apply_mixture():
100
100
  assert 10 < state.apply_x.call_count < 90
101
101
 
102
102
 
103
- def test_act_from_single_qubit_decompose():
103
+ def test_act_from_single_qubit_decompose() -> None:
104
104
  q0 = cirq.LineQubit(0)
105
105
  state = mock.Mock()
106
106
  args = cirq.StabilizerSimulationState(state=state, qubits=[q0])
@@ -113,7 +113,7 @@ def test_act_from_single_qubit_decompose():
113
113
  state.apply_x.assert_called_with(0, 1.0, 0.0)
114
114
 
115
115
 
116
- def test_decompose():
116
+ def test_decompose() -> None:
117
117
  class XContainer(cirq.Gate):
118
118
  def _decompose_(self, qs):
119
119
  return [cirq.X(*qs)]
@@ -22,7 +22,7 @@ import cirq.testing
22
22
  # Github issue: https://github.com/quantumlib/Cirq/issues/3021
23
23
 
24
24
 
25
- def test_initial_state():
25
+ def test_initial_state() -> None:
26
26
  with pytest.raises(ValueError, match='Out of range'):
27
27
  _ = cirq.StabilizerStateChForm(initial_state=-31, num_qubits=5)
28
28
  with pytest.raises(ValueError, match='Out of range'):
@@ -33,7 +33,7 @@ def test_initial_state():
33
33
  np.testing.assert_allclose(state.state_vector(), expected_state_vector)
34
34
 
35
35
 
36
- def test_run():
36
+ def test_run() -> None:
37
37
  (q0, q1, q2) = (cirq.LineQubit(0), cirq.LineQubit(1), cirq.LineQubit(2))
38
38
 
39
39
  """
@@ -18,7 +18,7 @@ import pytest
18
18
  import cirq
19
19
 
20
20
 
21
- def test_default_parameter():
21
+ def test_default_parameter() -> None:
22
22
  qid_shape = (2,)
23
23
  tensor = cirq.to_valid_density_matrix(
24
24
  0, len(qid_shape), qid_shape=qid_shape, dtype=np.complex64
@@ -32,13 +32,13 @@ def test_default_parameter():
32
32
  assert args.qid_shape == qid_shape
33
33
 
34
34
 
35
- def test_shallow_copy_buffers():
35
+ def test_shallow_copy_buffers() -> None:
36
36
  args = cirq.DensityMatrixSimulationState(qubits=cirq.LineQubit.range(1), initial_state=0)
37
37
  copy = args.copy(deep_copy_buffers=False)
38
38
  assert copy.available_buffer is args.available_buffer
39
39
 
40
40
 
41
- def test_decomposed_fallback():
41
+ def test_decomposed_fallback() -> None:
42
42
  class Composite(cirq.Gate):
43
43
  def num_qubits(self) -> int:
44
44
  return 1
@@ -59,7 +59,7 @@ def test_decomposed_fallback():
59
59
  )
60
60
 
61
61
 
62
- def test_cannot_act():
62
+ def test_cannot_act() -> None:
63
63
  class NoDetails:
64
64
  pass
65
65
 
@@ -73,12 +73,12 @@ def test_cannot_act():
73
73
  cirq.act_on(NoDetails(), args, qubits=())
74
74
 
75
75
 
76
- def test_qid_shape_error():
76
+ def test_qid_shape_error() -> None:
77
77
  with pytest.raises(ValueError, match="qid_shape must be provided"):
78
78
  cirq.sim.density_matrix_simulation_state._BufferedDensityMatrix.create(initial_state=0)
79
79
 
80
80
 
81
- def test_initial_state_vector():
81
+ def test_initial_state_vector() -> None:
82
82
  qubits = cirq.LineQubit.range(3)
83
83
  args = cirq.DensityMatrixSimulationState(
84
84
  qubits=qubits, initial_state=np.full((8,), 1 / np.sqrt(8)), dtype=np.complex64
@@ -91,7 +91,7 @@ def test_initial_state_vector():
91
91
  assert args2.target_tensor.shape == (2, 2, 2, 2, 2, 2)
92
92
 
93
93
 
94
- def test_initial_state_matrix():
94
+ def test_initial_state_matrix() -> None:
95
95
  qubits = cirq.LineQubit.range(3)
96
96
  args = cirq.DensityMatrixSimulationState(
97
97
  qubits=qubits, initial_state=np.full((8, 8), 1 / 8), dtype=np.complex64
@@ -104,7 +104,7 @@ def test_initial_state_matrix():
104
104
  assert args2.target_tensor.shape == (2, 2, 2, 2, 2, 2)
105
105
 
106
106
 
107
- def test_initial_state_bad_shape():
107
+ def test_initial_state_bad_shape() -> None:
108
108
  qubits = cirq.LineQubit.range(3)
109
109
  with pytest.raises(ValueError, match="Invalid quantum state"):
110
110
  cirq.DensityMatrixSimulationState(