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.

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.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/METADATA +1 -1
  164. {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/RECORD +167 -167
  165. {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/WHEEL +1 -1
  166. {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/licenses/LICENSE +0 -0
  167. {cirq_core-1.6.0.dev20250508231110.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/top_level.txt +0 -0
@@ -29,7 +29,7 @@ from cirq.contrib.qasm_import._parser import QasmParser
29
29
  from cirq.testing import consistent_qasm as cq
30
30
 
31
31
 
32
- def test_format_header_circuit():
32
+ def test_format_header_circuit() -> None:
33
33
  parser = QasmParser()
34
34
 
35
35
  parsed_qasm = parser.parse("OPENQASM 2.0;")
@@ -39,7 +39,7 @@ def test_format_header_circuit():
39
39
  ct.assert_same_circuits(parsed_qasm.circuit, Circuit())
40
40
 
41
41
 
42
- def test_unsupported_format():
42
+ def test_unsupported_format() -> None:
43
43
  qasm = "OPENQASM 2.1;"
44
44
  parser = QasmParser()
45
45
 
@@ -47,7 +47,7 @@ def test_unsupported_format():
47
47
  parser.parse(qasm)
48
48
 
49
49
 
50
- def test_format_header_with_quelibinc_circuit():
50
+ def test_format_header_with_quelibinc_circuit() -> None:
51
51
  qasm = """OPENQASM 2.0;
52
52
  include "qelib1.inc";
53
53
  """
@@ -61,14 +61,14 @@ include "qelib1.inc";
61
61
 
62
62
 
63
63
  @pytest.mark.parametrize('qasm', ["include \"qelib1.inc\";", "", "qreg q[3];"])
64
- def test_error_not_starting_with_format(qasm: str):
64
+ def test_error_not_starting_with_format(qasm: str) -> None:
65
65
  parser = QasmParser()
66
66
 
67
67
  with pytest.raises(QasmException, match="Missing 'OPENQASM 2.0;' statement"):
68
68
  parser.parse(qasm)
69
69
 
70
70
 
71
- def test_comments():
71
+ def test_comments() -> None:
72
72
  parser = QasmParser()
73
73
 
74
74
  parsed_qasm = parser.parse(
@@ -87,7 +87,7 @@ def test_comments():
87
87
  ct.assert_same_circuits(parsed_qasm.circuit, Circuit())
88
88
 
89
89
 
90
- def test_multiple_qreg_declaration():
90
+ def test_multiple_qreg_declaration() -> None:
91
91
  qasm = """OPENQASM 2.0;
92
92
  include "qelib1.inc";
93
93
  qreg a_quantum_register [ 1337 ];
@@ -116,7 +116,7 @@ def test_multiple_qreg_declaration():
116
116
  """,
117
117
  ],
118
118
  )
119
- def test_already_defined_error(qasm: str):
119
+ def test_already_defined_error(qasm: str) -> None:
120
120
  parser = QasmParser()
121
121
 
122
122
  with pytest.raises(QasmException, match=r"q.*already defined.* line 3"):
@@ -134,14 +134,14 @@ def test_already_defined_error(qasm: str):
134
134
  """,
135
135
  ],
136
136
  )
137
- def test_zero_length_register(qasm: str):
137
+ def test_zero_length_register(qasm: str) -> None:
138
138
  parser = QasmParser()
139
139
 
140
140
  with pytest.raises(QasmException, match=".* zero-length.*'q'.*line 2"):
141
141
  parser.parse(qasm)
142
142
 
143
143
 
144
- def test_unexpected_end_of_file():
144
+ def test_unexpected_end_of_file() -> None:
145
145
  qasm = """OPENQASM 2.0;
146
146
  include "qelib1.inc";
147
147
  creg
@@ -152,7 +152,7 @@ def test_unexpected_end_of_file():
152
152
  parser.parse(qasm)
153
153
 
154
154
 
155
- def test_multiple_creg_declaration():
155
+ def test_multiple_creg_declaration() -> None:
156
156
  qasm = """OPENQASM 2.0;
157
157
  include "qelib1.inc";
158
158
  creg a_classical_register [1337];
@@ -170,7 +170,7 @@ def test_multiple_creg_declaration():
170
170
  assert parsed_qasm.cregs == {'a_classical_register': 1337, 'c': 42}
171
171
 
172
172
 
173
- def test_syntax_error():
173
+ def test_syntax_error() -> None:
174
174
  qasm = """OPENQASM 2.0;
175
175
  qreg q[2] bla;
176
176
  foobar q[0];
@@ -181,7 +181,7 @@ def test_syntax_error():
181
181
  parser.parse(qasm)
182
182
 
183
183
 
184
- def test_CX_gate():
184
+ def test_CX_gate() -> None:
185
185
  qasm = """OPENQASM 2.0;
186
186
  qreg q1[2];
187
187
  qreg q2[2];
@@ -215,7 +215,7 @@ def test_CX_gate():
215
215
  assert parsed_qasm.qregs == {'q1': 2, 'q2': 2}
216
216
 
217
217
 
218
- def test_classical_control():
218
+ def test_classical_control() -> None:
219
219
  qasm = """OPENQASM 2.0;
220
220
  qreg q[2];
221
221
  creg a[1];
@@ -259,7 +259,7 @@ if (m_a_0==1) cx q[0],q[1];
259
259
  assert cirq.qasm(parsed_qasm.circuit) == expected_generated_qasm
260
260
 
261
261
 
262
- def test_classical_control_multi_bit():
262
+ def test_classical_control_multi_bit() -> None:
263
263
  qasm = """OPENQASM 2.0;
264
264
  qreg q[2];
265
265
  creg a[2];
@@ -296,7 +296,7 @@ def test_classical_control_multi_bit():
296
296
  _ = cirq.qasm(parsed_qasm.circuit)
297
297
 
298
298
 
299
- def test_CX_gate_not_enough_args():
299
+ def test_CX_gate_not_enough_args() -> None:
300
300
  qasm = """OPENQASM 2.0;
301
301
  qreg q[2];
302
302
  CX q[0];
@@ -307,7 +307,7 @@ def test_CX_gate_not_enough_args():
307
307
  parser.parse(qasm)
308
308
 
309
309
 
310
- def test_CX_gate_mismatched_registers():
310
+ def test_CX_gate_mismatched_registers() -> None:
311
311
  qasm = """OPENQASM 2.0;
312
312
  qreg q1[2];
313
313
  qreg q2[3];
@@ -319,7 +319,7 @@ def test_CX_gate_mismatched_registers():
319
319
  parser.parse(qasm)
320
320
 
321
321
 
322
- def test_CX_gate_bounds():
322
+ def test_CX_gate_bounds() -> None:
323
323
  qasm = """OPENQASM 2.0;
324
324
  qreg q1[2];
325
325
  qreg q2[3];
@@ -331,7 +331,7 @@ def test_CX_gate_bounds():
331
331
  parser.parse(qasm)
332
332
 
333
333
 
334
- def test_CX_gate_arg_overlap():
334
+ def test_CX_gate_arg_overlap() -> None:
335
335
  qasm = """OPENQASM 2.0;
336
336
  qreg q1[2];
337
337
  qreg q2[3];
@@ -343,7 +343,7 @@ def test_CX_gate_arg_overlap():
343
343
  parser.parse(qasm)
344
344
 
345
345
 
346
- def test_U_gate():
346
+ def test_U_gate() -> None:
347
347
  qasm = """
348
348
  OPENQASM 2.0;
349
349
  qreg q[2];
@@ -376,7 +376,7 @@ def test_U_gate():
376
376
  assert parsed_qasm.qregs == {'q': 2}
377
377
 
378
378
 
379
- def test_U_angles():
379
+ def test_U_angles() -> None:
380
380
  qasm = """
381
381
  OPENQASM 2.0;
382
382
  qreg q[1];
@@ -389,7 +389,7 @@ def test_U_angles():
389
389
  )
390
390
 
391
391
 
392
- def test_U_gate_zero_params_error():
392
+ def test_U_gate_zero_params_error() -> None:
393
393
  qasm = """OPENQASM 2.0;
394
394
  qreg q[2];
395
395
  U q[1];"""
@@ -400,7 +400,7 @@ def test_U_gate_zero_params_error():
400
400
  parser.parse(qasm)
401
401
 
402
402
 
403
- def test_U_gate_too_much_params_error():
403
+ def test_U_gate_too_much_params_error() -> None:
404
404
  qasm = """OPENQASM 2.0;
405
405
  qreg q[2];
406
406
  U(pi, pi, pi, pi) q[1];"""
@@ -439,7 +439,7 @@ def test_U_gate_too_much_params_error():
439
439
  'atan(0.2)',
440
440
  ],
441
441
  )
442
- def test_expressions(expr: str):
442
+ def test_expressions(expr: str) -> None:
443
443
  qasm = f"""OPENQASM 2.0;
444
444
  qreg q[1];
445
445
  U({expr}, 2 * pi, pi / 2.0) q[0];
@@ -463,7 +463,7 @@ def test_expressions(expr: str):
463
463
  assert parsed_qasm.qregs == {'q': 1}
464
464
 
465
465
 
466
- def test_unknown_function():
466
+ def test_unknown_function() -> None:
467
467
  qasm = """OPENQASM 2.0;
468
468
  qreg q[1];
469
469
  U(nonexistent(3), 2 * pi, pi / 3.0) q[0];
@@ -491,7 +491,7 @@ single_qubit_gates = [
491
491
 
492
492
 
493
493
  @pytest.mark.parametrize('qasm_gate,cirq_gate', rotation_gates)
494
- def test_rotation_gates(qasm_gate: str, cirq_gate: Callable[[float], cirq.Gate]):
494
+ def test_rotation_gates(qasm_gate: str, cirq_gate: Callable[[float], cirq.Gate]) -> None:
495
495
  qasm = f"""OPENQASM 2.0;
496
496
  include "qelib1.inc";
497
497
  qreg q[2];
@@ -518,7 +518,7 @@ def test_rotation_gates(qasm_gate: str, cirq_gate: Callable[[float], cirq.Gate])
518
518
 
519
519
 
520
520
  @pytest.mark.parametrize('qasm_gate', [g[0] for g in rotation_gates])
521
- def test_rotation_gates_wrong_number_of_args(qasm_gate: str):
521
+ def test_rotation_gates_wrong_number_of_args(qasm_gate: str) -> None:
522
522
  qasm = f"""
523
523
  OPENQASM 2.0;
524
524
  include "qelib1.inc";
@@ -533,7 +533,7 @@ def test_rotation_gates_wrong_number_of_args(qasm_gate: str):
533
533
 
534
534
 
535
535
  @pytest.mark.parametrize('qasm_gate', [g[0] for g in rotation_gates])
536
- def test_rotation_gates_zero_params_error(qasm_gate: str):
536
+ def test_rotation_gates_zero_params_error(qasm_gate: str) -> None:
537
537
  qasm = f"""OPENQASM 2.0;
538
538
  include "qelib1.inc";
539
539
  qreg q[2];
@@ -546,7 +546,7 @@ def test_rotation_gates_zero_params_error(qasm_gate: str):
546
546
  parser.parse(qasm)
547
547
 
548
548
 
549
- def test_qelib_gate_without_include_statement():
549
+ def test_qelib_gate_without_include_statement() -> None:
550
550
  qasm = """OPENQASM 2.0;
551
551
  qreg q[2];
552
552
  x q[0];
@@ -557,7 +557,7 @@ def test_qelib_gate_without_include_statement():
557
557
  parser.parse(qasm)
558
558
 
559
559
 
560
- def test_undefined_register_from_qubit_arg():
560
+ def test_undefined_register_from_qubit_arg() -> None:
561
561
  qasm = """OPENQASM 2.0;
562
562
  qreg q[2];
563
563
  CX q[0], q2[1];
@@ -568,7 +568,7 @@ def test_undefined_register_from_qubit_arg():
568
568
  parser.parse(qasm)
569
569
 
570
570
 
571
- def test_undefined_register_from_register_arg():
571
+ def test_undefined_register_from_register_arg() -> None:
572
572
  qasm = """OPENQASM 2.0;
573
573
  qreg q[2];
574
574
  qreg q2[2];
@@ -580,7 +580,7 @@ def test_undefined_register_from_register_arg():
580
580
  parser.parse(qasm)
581
581
 
582
582
 
583
- def test_measure_individual_bits():
583
+ def test_measure_individual_bits() -> None:
584
584
  qasm = """
585
585
  OPENQASM 2.0;
586
586
  include "qelib1.inc";
@@ -609,7 +609,7 @@ def test_measure_individual_bits():
609
609
  assert parsed_qasm.cregs == {'c1': 2}
610
610
 
611
611
 
612
- def test_measure_registers():
612
+ def test_measure_registers() -> None:
613
613
  qasm = """OPENQASM 2.0;
614
614
  include "qelib1.inc";
615
615
  qreg q1[3];
@@ -638,7 +638,7 @@ def test_measure_registers():
638
638
  assert parsed_qasm.cregs == {'c1': 3}
639
639
 
640
640
 
641
- def test_measure_mismatched_register_size():
641
+ def test_measure_mismatched_register_size() -> None:
642
642
  qasm = """OPENQASM 2.0;
643
643
  include "qelib1.inc";
644
644
  qreg q1[2];
@@ -652,7 +652,7 @@ def test_measure_mismatched_register_size():
652
652
  parser.parse(qasm)
653
653
 
654
654
 
655
- def test_measure_to_quantum_register():
655
+ def test_measure_to_quantum_register() -> None:
656
656
  qasm = """OPENQASM 2.0;
657
657
  include "qelib1.inc";
658
658
  qreg q1[3];
@@ -667,7 +667,7 @@ def test_measure_to_quantum_register():
667
667
  parser.parse(qasm)
668
668
 
669
669
 
670
- def test_measure_undefined_classical_bit():
670
+ def test_measure_undefined_classical_bit() -> None:
671
671
  qasm = """OPENQASM 2.0;
672
672
  include "qelib1.inc";
673
673
  qreg q1[3];
@@ -681,7 +681,7 @@ def test_measure_undefined_classical_bit():
681
681
  parser.parse(qasm)
682
682
 
683
683
 
684
- def test_measure_from_classical_register():
684
+ def test_measure_from_classical_register() -> None:
685
685
  qasm = """OPENQASM 2.0;
686
686
  include "qelib1.inc";
687
687
  qreg q1[2];
@@ -696,7 +696,7 @@ def test_measure_from_classical_register():
696
696
  parser.parse(qasm)
697
697
 
698
698
 
699
- def test_measurement_bounds():
699
+ def test_measurement_bounds() -> None:
700
700
  qasm = """OPENQASM 2.0;
701
701
  qreg q1[3];
702
702
  creg c1[3];
@@ -708,7 +708,7 @@ def test_measurement_bounds():
708
708
  parser.parse(qasm)
709
709
 
710
710
 
711
- def test_reset():
711
+ def test_reset() -> None:
712
712
  qasm = textwrap.dedent(
713
713
  """\
714
714
  OPENQASM 2.0;
@@ -737,7 +737,7 @@ def test_reset():
737
737
  assert parsed_qasm.cregs == {'c': 1}
738
738
 
739
739
 
740
- def test_u1_gate():
740
+ def test_u1_gate() -> None:
741
741
  qasm = """
742
742
  OPENQASM 2.0;
743
743
  include "qelib1.inc";
@@ -760,7 +760,7 @@ def test_u1_gate():
760
760
  assert parsed_qasm.qregs == {'q': 1}
761
761
 
762
762
 
763
- def test_u2_gate():
763
+ def test_u2_gate() -> None:
764
764
  qasm = """
765
765
  OPENQASM 2.0;
766
766
  include "qelib1.inc";
@@ -783,7 +783,7 @@ def test_u2_gate():
783
783
  assert parsed_qasm.qregs == {'q': 1}
784
784
 
785
785
 
786
- def test_id_gate():
786
+ def test_id_gate() -> None:
787
787
  qasm = """
788
788
  OPENQASM 2.0;
789
789
  include "qelib1.inc";
@@ -808,7 +808,7 @@ def test_id_gate():
808
808
  assert parsed_qasm.qregs == {'q': 2}
809
809
 
810
810
 
811
- def test_u3_gate():
811
+ def test_u3_gate() -> None:
812
812
  qasm = """
813
813
  OPENQASM 2.0;
814
814
  include "qelib1.inc";
@@ -842,7 +842,7 @@ def test_u3_gate():
842
842
  assert parsed_qasm.qregs == {'q': 2}
843
843
 
844
844
 
845
- def test_r_gate():
845
+ def test_r_gate() -> None:
846
846
  qasm = """
847
847
  OPENQASM 2.0;
848
848
  include "qelib1.inc";
@@ -869,7 +869,7 @@ def test_r_gate():
869
869
  'qasm_gate',
870
870
  ['id', 'u2', 'u3', 'r'] + [g[0] for g in rotation_gates] + [g[0] for g in single_qubit_gates],
871
871
  )
872
- def test_standard_single_qubit_gates_wrong_number_of_args(qasm_gate):
872
+ def test_standard_single_qubit_gates_wrong_number_of_args(qasm_gate) -> None:
873
873
  qasm = f"""
874
874
  OPENQASM 2.0;
875
875
  include "qelib1.inc";
@@ -888,7 +888,7 @@ def test_standard_single_qubit_gates_wrong_number_of_args(qasm_gate):
888
888
  [['id', 0], ['u2', 2], ['u3', 3], ['rx', 1], ['ry', 1], ['rz', 1], ['r', 2]]
889
889
  + [[g[0], 0] for g in single_qubit_gates],
890
890
  )
891
- def test_standard_gates_wrong_params_error(qasm_gate: str, num_params: int):
891
+ def test_standard_gates_wrong_params_error(qasm_gate: str, num_params: int) -> None:
892
892
  qasm = f"""OPENQASM 2.0;
893
893
  include "qelib1.inc";
894
894
  qreg q[2];
@@ -934,7 +934,7 @@ two_qubit_param_gates = {
934
934
 
935
935
 
936
936
  @pytest.mark.parametrize('qasm_gate,cirq_gate', two_qubit_gates)
937
- def test_two_qubit_gates(qasm_gate: str, cirq_gate: cirq.testing.TwoQubitGate):
937
+ def test_two_qubit_gates(qasm_gate: str, cirq_gate: cirq.testing.TwoQubitGate) -> None:
938
938
  qasm = f"""
939
939
  OPENQASM 2.0;
940
940
  include "qelib1.inc";
@@ -1015,7 +1015,7 @@ def test_two_qubit_param_gates(
1015
1015
  @pytest.mark.parametrize(
1016
1016
  'qasm_gate', [g[0] for g in two_qubit_gates] + [g[0] for g in two_qubit_param_gates.keys()]
1017
1017
  )
1018
- def test_two_qubit_gates_not_enough_qubits(qasm_gate: str):
1018
+ def test_two_qubit_gates_not_enough_qubits(qasm_gate: str) -> None:
1019
1019
  if qasm_gate in ('cu1', 'crz'):
1020
1020
  qasm = f"""
1021
1021
  OPENQASM 2.0;
@@ -1045,7 +1045,7 @@ def test_two_qubit_gates_not_enough_qubits(qasm_gate: str):
1045
1045
 
1046
1046
 
1047
1047
  @pytest.mark.parametrize('qasm_gate', [g[0] for g in two_qubit_param_gates.keys()])
1048
- def test_two_qubit_gates_not_enough_args(qasm_gate: str):
1048
+ def test_two_qubit_gates_not_enough_args(qasm_gate: str) -> None:
1049
1049
  qasm = f"""
1050
1050
  OPENQASM 2.0;
1051
1051
  include "qelib1.inc";
@@ -1062,7 +1062,7 @@ def test_two_qubit_gates_not_enough_args(qasm_gate: str):
1062
1062
  @pytest.mark.parametrize(
1063
1063
  'qasm_gate', [g[0] for g in two_qubit_gates] + [g[0] for g in two_qubit_param_gates.keys()]
1064
1064
  )
1065
- def test_two_qubit_gates_with_too_much_parameters(qasm_gate: str):
1065
+ def test_two_qubit_gates_with_too_much_parameters(qasm_gate: str) -> None:
1066
1066
  if qasm_gate in ('cu1', 'cu3', 'crz'):
1067
1067
  num_params_needed = 3 if qasm_gate == 'cu3' else 1
1068
1068
  else:
@@ -1088,7 +1088,7 @@ three_qubit_gates = [('ccx', cirq.TOFFOLI), ('cswap', cirq.CSWAP)]
1088
1088
 
1089
1089
 
1090
1090
  @pytest.mark.parametrize('qasm_gate,cirq_gate', three_qubit_gates)
1091
- def test_three_qubit_gates(qasm_gate: str, cirq_gate: cirq.testing.TwoQubitGate):
1091
+ def test_three_qubit_gates(qasm_gate: str, cirq_gate: cirq.testing.TwoQubitGate) -> None:
1092
1092
  qasm = f"""
1093
1093
  OPENQASM 2.0;
1094
1094
  include "qelib1.inc";
@@ -1128,7 +1128,7 @@ def test_three_qubit_gates(qasm_gate: str, cirq_gate: cirq.testing.TwoQubitGate)
1128
1128
 
1129
1129
 
1130
1130
  @pytest.mark.parametrize('qasm_gate', [g[0] for g in three_qubit_gates])
1131
- def test_three_qubit_gates_not_enough_args(qasm_gate: str):
1131
+ def test_three_qubit_gates_not_enough_args(qasm_gate: str) -> None:
1132
1132
  qasm = f"""OPENQASM 2.0;
1133
1133
  include "qelib1.inc";
1134
1134
  qreg q[2];
@@ -1142,7 +1142,7 @@ def test_three_qubit_gates_not_enough_args(qasm_gate: str):
1142
1142
 
1143
1143
 
1144
1144
  @pytest.mark.parametrize('qasm_gate', [g[0] for g in three_qubit_gates])
1145
- def test_three_qubit_gates_with_too_much_parameters(qasm_gate: str):
1145
+ def test_three_qubit_gates_with_too_much_parameters(qasm_gate: str) -> None:
1146
1146
  qasm = f"""OPENQASM 2.0;
1147
1147
  include "qelib1.inc";
1148
1148
  qreg q[3];
@@ -1156,7 +1156,7 @@ def test_three_qubit_gates_with_too_much_parameters(qasm_gate: str):
1156
1156
 
1157
1157
 
1158
1158
  @pytest.mark.parametrize('qasm_gate,cirq_gate', single_qubit_gates)
1159
- def test_single_qubit_gates(qasm_gate: str, cirq_gate: cirq.Gate):
1159
+ def test_single_qubit_gates(qasm_gate: str, cirq_gate: cirq.Gate) -> None:
1160
1160
  qasm = f"""OPENQASM 2.0;
1161
1161
  include "qelib1.inc";
1162
1162
  qreg q[2];
@@ -1180,7 +1180,7 @@ def test_single_qubit_gates(qasm_gate: str, cirq_gate: cirq.Gate):
1180
1180
  assert parsed_qasm.qregs == {'q': 2}
1181
1181
 
1182
1182
 
1183
- def test_openqasm_3_0_qubits():
1183
+ def test_openqasm_3_0_qubits() -> None:
1184
1184
  qasm = """OPENQASM 3.0;
1185
1185
  include "stdgates.inc";
1186
1186
  qubit[2] q;
@@ -1205,7 +1205,7 @@ def test_openqasm_3_0_qubits():
1205
1205
  assert parsed_qasm.qregs == {'q': 2}
1206
1206
 
1207
1207
 
1208
- def test_openqasm_3_0_scalar_qubit():
1208
+ def test_openqasm_3_0_scalar_qubit() -> None:
1209
1209
  qasm = """OPENQASM 3.0;
1210
1210
  include "stdgates.inc";
1211
1211
  qubit q;
@@ -1230,7 +1230,7 @@ def test_openqasm_3_0_scalar_qubit():
1230
1230
  assert parsed_qasm.qregs == {'q': 1}
1231
1231
 
1232
1232
 
1233
- def test_custom_gate():
1233
+ def test_custom_gate() -> None:
1234
1234
  qasm = """OPENQASM 2.0;
1235
1235
  include "qelib1.inc";
1236
1236
  qreg q[2];
@@ -1271,7 +1271,7 @@ def test_custom_gate():
1271
1271
  cq.assert_qiskit_parsed_qasm_consistent_with_unitary(qasm, cirq.unitary(unrolled))
1272
1272
 
1273
1273
 
1274
- def test_custom_gate_parameterized():
1274
+ def test_custom_gate_parameterized() -> None:
1275
1275
  qasm = """OPENQASM 2.0;
1276
1276
  include "qelib1.inc";
1277
1277
  qreg q[2];
@@ -1320,7 +1320,7 @@ def test_custom_gate_parameterized():
1320
1320
  cq.assert_qiskit_parsed_qasm_consistent_with_unitary(qasm, cirq.unitary(unrolled))
1321
1321
 
1322
1322
 
1323
- def test_custom_gate_broadcast():
1323
+ def test_custom_gate_broadcast() -> None:
1324
1324
  qasm = """OPENQASM 2.0;
1325
1325
  include "qelib1.inc";
1326
1326
  qreg q[3];
@@ -1370,7 +1370,7 @@ def test_custom_gate_broadcast():
1370
1370
  cq.assert_qiskit_parsed_qasm_consistent_with_unitary(qasm, cirq.unitary(unrolled))
1371
1371
 
1372
1372
 
1373
- def test_custom_gate_undefined_qubit_error():
1373
+ def test_custom_gate_undefined_qubit_error() -> None:
1374
1374
  qasm = """OPENQASM 2.0;
1375
1375
  include "qelib1.inc";
1376
1376
  qreg q[1];
@@ -1384,7 +1384,7 @@ def test_custom_gate_undefined_qubit_error():
1384
1384
  )
1385
1385
 
1386
1386
 
1387
- def test_custom_gate_qubit_scope_closure_error():
1387
+ def test_custom_gate_qubit_scope_closure_error() -> None:
1388
1388
  qasm = """OPENQASM 2.0;
1389
1389
  include "qelib1.inc";
1390
1390
  qreg q[1];
@@ -1398,7 +1398,7 @@ def test_custom_gate_qubit_scope_closure_error():
1398
1398
  )
1399
1399
 
1400
1400
 
1401
- def test_custom_gate_qubit_index_error():
1401
+ def test_custom_gate_qubit_index_error() -> None:
1402
1402
  qasm = """OPENQASM 2.0;
1403
1403
  include "qelib1.inc";
1404
1404
  qreg q[1];
@@ -1412,7 +1412,7 @@ def test_custom_gate_qubit_index_error():
1412
1412
  )
1413
1413
 
1414
1414
 
1415
- def test_custom_gate_qreg_count_error():
1415
+ def test_custom_gate_qreg_count_error() -> None:
1416
1416
  qasm = """OPENQASM 2.0;
1417
1417
  include "qelib1.inc";
1418
1418
  qreg q[2];
@@ -1426,7 +1426,7 @@ def test_custom_gate_qreg_count_error():
1426
1426
  )
1427
1427
 
1428
1428
 
1429
- def test_custom_gate_missing_param_error():
1429
+ def test_custom_gate_missing_param_error() -> None:
1430
1430
  qasm = """OPENQASM 2.0;
1431
1431
  include "qelib1.inc";
1432
1432
  qreg q[1];
@@ -1440,7 +1440,7 @@ def test_custom_gate_missing_param_error():
1440
1440
  )
1441
1441
 
1442
1442
 
1443
- def test_custom_gate_extra_param_error():
1443
+ def test_custom_gate_extra_param_error() -> None:
1444
1444
  qasm = """OPENQASM 2.0;
1445
1445
  include "qelib1.inc";
1446
1446
  qreg q[1];
@@ -1454,7 +1454,7 @@ def test_custom_gate_extra_param_error():
1454
1454
  )
1455
1455
 
1456
1456
 
1457
- def test_custom_gate_undefined_param_error():
1457
+ def test_custom_gate_undefined_param_error() -> None:
1458
1458
  qasm = """OPENQASM 2.0;
1459
1459
  include "qelib1.inc";
1460
1460
  qreg q[1];
@@ -1468,7 +1468,7 @@ def test_custom_gate_undefined_param_error():
1468
1468
  )
1469
1469
 
1470
1470
 
1471
- def test_top_level_param_error():
1471
+ def test_top_level_param_error() -> None:
1472
1472
  qasm = """OPENQASM 2.0;
1473
1473
  include "qelib1.inc";
1474
1474
  qreg q[1];
@@ -1495,7 +1495,7 @@ def _test_parse_exception(qasm: str, cirq_err: str, qiskit_err: str | None):
1495
1495
  qiskit.QuantumCircuit.from_qasm_str(qasm)
1496
1496
 
1497
1497
 
1498
- def test_nested_custom_gate_has_keyword_in_name():
1498
+ def test_nested_custom_gate_has_keyword_in_name() -> None:
1499
1499
  qasm = """OPENQASM 2.0;
1500
1500
  include "qelib1.inc";
1501
1501
  qreg q[1];
@@ -21,7 +21,7 @@ import cirq.contrib.qcircuit.qcircuit_pdf as qcircuit_pdf
21
21
 
22
22
 
23
23
  @mock.patch.object(pylatex.Document, "generate_pdf")
24
- def test_qcircuit_pdf(mock_generate_pdf):
24
+ def test_qcircuit_pdf(mock_generate_pdf) -> None:
25
25
  circuit = cirq.Circuit(cirq.X(cirq.q(0)), cirq.CZ(cirq.q(0), cirq.q(1)))
26
26
  qcircuit_pdf.circuit_to_pdf_using_qcircuit_via_tex(circuit, "/tmp/test_file")
27
27
  mock_generate_pdf.assert_called_once_with(
@@ -43,7 +43,7 @@ def assert_has_qcircuit_diagram(actual: cirq.Circuit, desired: str, **kwargs) ->
43
43
  )
44
44
 
45
45
 
46
- def test_fallback_diagram():
46
+ def test_fallback_diagram() -> None:
47
47
  class MagicGate(cirq.testing.ThreeQubitGate):
48
48
  def __str__(self):
49
49
  return 'MagicGate'
@@ -77,7 +77,7 @@ def test_fallback_diagram():
77
77
  assert_has_qcircuit_diagram(circuit, expected_diagram)
78
78
 
79
79
 
80
- def test_teleportation_diagram():
80
+ def test_teleportation_diagram() -> None:
81
81
  ali = cirq.NamedQubit('alice')
82
82
  car = cirq.NamedQubit('carrier')
83
83
  bob = cirq.NamedQubit('bob')
@@ -106,7 +106,7 @@ def test_teleportation_diagram():
106
106
  )
107
107
 
108
108
 
109
- def test_other_diagram():
109
+ def test_other_diagram() -> None:
110
110
  a, b, c = cirq.LineQubit.range(3)
111
111
 
112
112
  circuit = cirq.Circuit(cirq.X(a), cirq.Y(b), cirq.Z(c))
@@ -122,7 +122,7 @@ def test_other_diagram():
122
122
  assert_has_qcircuit_diagram(circuit, expected_diagram)
123
123
 
124
124
 
125
- def test_qcircuit_qubit_namer():
125
+ def test_qcircuit_qubit_namer() -> None:
126
126
  from cirq.contrib.qcircuit import qcircuit_diagram
127
127
 
128
128
  assert qcircuit_diagram.qcircuit_qubit_namer(cirq.NamedQubit('q')) == r'\lstick{\text{q}}&'
@@ -137,7 +137,7 @@ def test_qcircuit_qubit_namer():
137
137
  )
138
138
 
139
139
 
140
- def test_two_cx_diagram():
140
+ def test_two_cx_diagram() -> None:
141
141
  # test for no moment indication
142
142
  q0, q1, q2, q3 = cirq.LineQubit.range(4)
143
143
  circuit = cirq.Circuit(cirq.CX(q0, q2), cirq.CX(q1, q3), cirq.CX(q0, q2), cirq.CX(q1, q3))
@@ -153,7 +153,7 @@ def test_two_cx_diagram():
153
153
  assert_has_qcircuit_diagram(circuit, expected_diagram)
154
154
 
155
155
 
156
- def test_sqrt_iswap_diagram():
156
+ def test_sqrt_iswap_diagram() -> None:
157
157
  # test for proper rendering of ISWAP^{0.5}
158
158
  q0, q1 = cirq.LineQubit.range(2)
159
159
  circuit = cirq.Circuit(cirq.ISWAP(q0, q1) ** 0.5)
@@ -21,7 +21,7 @@ import cirq.contrib.routing as ccr
21
21
  from cirq.contrib.routing.greedy import route_circuit_greedily
22
22
 
23
23
 
24
- def test_bad_args():
24
+ def test_bad_args() -> None:
25
25
  """Test zero valued arguments in greedy router."""
26
26
  circuit = cirq.testing.random_circuit(4, 2, 0.5, random_state=5)
27
27
  device_graph = ccr.get_grid_device_graph(3, 2)
@@ -50,7 +50,7 @@ def create_hanging_routing_instance(circuit, device_graph):
50
50
  )
51
51
 
52
52
 
53
- def test_router_hanging():
53
+ def test_router_hanging() -> None:
54
54
  """Run a separate process and check if greedy router hits timeout (20s)."""
55
55
  circuit, device_graph = create_circuit_and_device()
56
56
  process = Process(target=create_hanging_routing_instance, args=[circuit, device_graph])
@@ -30,7 +30,7 @@ def get_seeded_initial_mapping(graph_seed, init_seed):
30
30
 
31
31
 
32
32
  @pytest.mark.parametrize('seed', [random.randint(0, 2**32) for _ in range(10)])
33
- def test_initialization_reproducible_with_seed(seed):
33
+ def test_initialization_reproducible_with_seed(seed) -> None:
34
34
  wrappers = (lambda s: s, np.random.RandomState)
35
35
  mappings = [
36
36
  get_seeded_initial_mapping(seed, wrapper(seed)) for wrapper in wrappers for _ in range(5)
@@ -39,7 +39,7 @@ def test_initialization_reproducible_with_seed(seed):
39
39
  eq.add_equality_group(*mappings)
40
40
 
41
41
 
42
- def test_initialization_with_no_seed():
42
+ def test_initialization_with_no_seed() -> None:
43
43
  graph_seed = random.randint(0, 2**32)
44
44
  state = np.random.get_state()
45
45
  mappings = []
@@ -50,7 +50,7 @@ def test_initialization_with_no_seed():
50
50
  eq.add_equality_group(*mappings)
51
51
 
52
52
 
53
- def test_initialization_reproducible_between_runs():
53
+ def test_initialization_reproducible_between_runs() -> None:
54
54
  seed = 45
55
55
  logical_graph = nx.erdos_renyi_graph(6, 0.5, seed=seed)
56
56
  logical_graph = nx.relabel_nodes(logical_graph, cirq.LineQubit)