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.

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.dev20250514001158.dist-info}/METADATA +2 -1
  164. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/RECORD +167 -167
  165. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/WHEEL +0 -0
  166. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/licenses/LICENSE +0 -0
  167. {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250514001158.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,7 @@ import pytest
17
17
  import cirq
18
18
 
19
19
 
20
- def test_two_qubit_gate_is_abstract_can_implement():
20
+ def test_two_qubit_gate_is_abstract_can_implement() -> None:
21
21
  class Included(cirq.testing.TwoQubitGate):
22
22
  def matrix(self):
23
23
  pass
@@ -25,7 +25,7 @@ def test_two_qubit_gate_is_abstract_can_implement():
25
25
  assert isinstance(Included(), cirq.testing.TwoQubitGate)
26
26
 
27
27
 
28
- def test_two_qubit_gate_validate_pass():
28
+ def test_two_qubit_gate_validate_pass() -> None:
29
29
  class Example(cirq.testing.TwoQubitGate):
30
30
  def matrix(self):
31
31
  pass
@@ -41,7 +41,7 @@ def test_two_qubit_gate_validate_pass():
41
41
  g.validate_args([q3, q2])
42
42
 
43
43
 
44
- def test_two_qubit_gate_validate_wrong_number():
44
+ def test_two_qubit_gate_validate_wrong_number() -> None:
45
45
  class Example(cirq.testing.TwoQubitGate):
46
46
  def matrix(self):
47
47
  pass
@@ -59,7 +59,7 @@ def test_two_qubit_gate_validate_wrong_number():
59
59
  g.validate_args([q1, q2, q3])
60
60
 
61
61
 
62
- def test_three_qubit_gate_validate():
62
+ def test_three_qubit_gate_validate() -> None:
63
63
  class Example(cirq.testing.ThreeQubitGate):
64
64
  def matrix(self):
65
65
  pass
@@ -80,6 +80,6 @@ def test_three_qubit_gate_validate():
80
80
  g.validate_args([a, b, c, d])
81
81
 
82
82
 
83
- def test_does_not_support_serialization_gate():
83
+ def test_does_not_support_serialization_gate() -> None:
84
84
  g = cirq.testing.DoesNotSupportSerializationGate(n_qubits=4)
85
85
  assert g.num_qubits() == 4
cirq/testing/json_test.py CHANGED
@@ -17,16 +17,16 @@ import pytest
17
17
  from cirq.testing.json import spec_for
18
18
 
19
19
 
20
- def test_module_missing_json_test_data():
20
+ def test_module_missing_json_test_data() -> None:
21
21
  with pytest.raises(ValueError, match="json_test_data"):
22
22
  spec_for('cirq.testing.test_data.test_module_missing_json_test_data')
23
23
 
24
24
 
25
- def test_module_missing_testspec():
25
+ def test_module_missing_testspec() -> None:
26
26
  with pytest.raises(ValueError, match="TestSpec"):
27
27
  spec_for('cirq.testing.test_data.test_module_missing_testspec')
28
28
 
29
29
 
30
- def test_missing_module():
30
+ def test_missing_module() -> None:
31
31
  with pytest.raises(ModuleNotFoundError):
32
32
  spec_for('non_existent')
@@ -28,14 +28,14 @@ from cirq.testing import (
28
28
 
29
29
 
30
30
  @pytest.mark.parametrize('dim', range(1, 10))
31
- def test_random_superposition(dim):
31
+ def test_random_superposition(dim) -> None:
32
32
  state = random_superposition(dim)
33
33
 
34
34
  assert dim == len(state)
35
35
  assert np.isclose(np.linalg.norm(state), 1.0)
36
36
 
37
37
 
38
- def test_random_superposition_deterministic_given_seed():
38
+ def test_random_superposition_deterministic_given_seed() -> None:
39
39
  state1 = random_superposition(10, random_state=1234)
40
40
  state2 = random_superposition(10, random_state=1234)
41
41
 
@@ -43,7 +43,7 @@ def test_random_superposition_deterministic_given_seed():
43
43
 
44
44
 
45
45
  @pytest.mark.parametrize('dim', range(1, 10))
46
- def test_random_density_matrix(dim):
46
+ def test_random_density_matrix(dim) -> None:
47
47
  state = random_density_matrix(dim)
48
48
 
49
49
  assert state.shape == (dim, dim)
@@ -53,14 +53,14 @@ def test_random_density_matrix(dim):
53
53
  assert np.all(eigs >= 0)
54
54
 
55
55
 
56
- def test_random_density_matrix_deterministic_given_seed():
56
+ def test_random_density_matrix_deterministic_given_seed() -> None:
57
57
  state1 = random_density_matrix(10, random_state=1234)
58
58
  state2 = random_density_matrix(10, random_state=1234)
59
59
 
60
60
  np.testing.assert_equal(state1, state2)
61
61
 
62
62
 
63
- def test_random_unitary():
63
+ def test_random_unitary() -> None:
64
64
  u1 = random_unitary(2)
65
65
  u2 = random_unitary(2)
66
66
  assert is_unitary(u1)
@@ -68,7 +68,7 @@ def test_random_unitary():
68
68
  assert not np.allclose(u1, u2)
69
69
 
70
70
 
71
- def test_random_orthogonal():
71
+ def test_random_orthogonal() -> None:
72
72
  o1 = random_orthogonal(2)
73
73
  o2 = random_orthogonal(2)
74
74
  assert is_orthogonal(o1)
@@ -76,14 +76,14 @@ def test_random_orthogonal():
76
76
  assert not np.allclose(o1, o2)
77
77
 
78
78
 
79
- def test_random_orthogonal_deterministic_given_seed():
79
+ def test_random_orthogonal_deterministic_given_seed() -> None:
80
80
  o1 = random_orthogonal(2, random_state=1234)
81
81
  o2 = random_orthogonal(2, random_state=1234)
82
82
 
83
83
  np.testing.assert_equal(o1, o2)
84
84
 
85
85
 
86
- def test_random_special_unitary():
86
+ def test_random_special_unitary() -> None:
87
87
  u1 = random_special_unitary(2)
88
88
  u2 = random_special_unitary(2)
89
89
  assert is_special_unitary(u1)
@@ -91,7 +91,7 @@ def test_random_special_unitary():
91
91
  assert not np.allclose(u1, u2)
92
92
 
93
93
 
94
- def test_seeded_special_unitary():
94
+ def test_seeded_special_unitary() -> None:
95
95
  u1 = random_special_unitary(2, random_state=np.random.RandomState(1))
96
96
  u2 = random_special_unitary(2, random_state=np.random.RandomState(1))
97
97
  u3 = random_special_unitary(2, random_state=np.random.RandomState(2))
@@ -99,7 +99,7 @@ def test_seeded_special_unitary():
99
99
  assert not np.allclose(u1, u3)
100
100
 
101
101
 
102
- def test_random_special_orthogonal():
102
+ def test_random_special_orthogonal() -> None:
103
103
  o1 = random_special_orthogonal(2)
104
104
  o2 = random_special_orthogonal(2)
105
105
  assert is_special_orthogonal(o1)
@@ -107,14 +107,14 @@ def test_random_special_orthogonal():
107
107
  assert not np.allclose(o1, o2)
108
108
 
109
109
 
110
- def test_random_special_orthogonal_deterministic_given_seed():
110
+ def test_random_special_orthogonal_deterministic_given_seed() -> None:
111
111
  o1 = random_special_orthogonal(2, random_state=1234)
112
112
  o2 = random_special_orthogonal(2, random_state=1234)
113
113
 
114
114
  np.testing.assert_equal(o1, o2)
115
115
 
116
116
 
117
- def test_assert_allclose_up_to_global_phase():
117
+ def test_assert_allclose_up_to_global_phase() -> None:
118
118
  assert_allclose_up_to_global_phase(np.array([[1]]), np.array([[1j]]), atol=0)
119
119
 
120
120
  with pytest.raises(AssertionError):
cirq/testing/logs_test.py CHANGED
@@ -20,7 +20,7 @@ import pytest
20
20
  import cirq.testing
21
21
 
22
22
 
23
- def test_assert_logs_valid_single_logs():
23
+ def test_assert_logs_valid_single_logs() -> None:
24
24
  with cirq.testing.assert_logs('apple'):
25
25
  logging.error('orange apple fruit')
26
26
 
@@ -43,7 +43,7 @@ def test_assert_logs_valid_single_logs():
43
43
  warnings.warn('orange apple fruit')
44
44
 
45
45
 
46
- def test_assert_logs_invalid_single_logs():
46
+ def test_assert_logs_invalid_single_logs() -> None:
47
47
  match = (
48
48
  '^dog expected to appear in log messages but it was not found. '
49
49
  'Log messages: \\[\'orange apple fruit\'\\].$'
@@ -57,7 +57,7 @@ def test_assert_logs_invalid_single_logs():
57
57
  logging.error('orange apple fruit')
58
58
 
59
59
 
60
- def test_assert_logs_valid_multiple_logs():
60
+ def test_assert_logs_valid_multiple_logs() -> None:
61
61
  with cirq.testing.assert_logs('apple', count=2):
62
62
  logging.error('orange apple fruit')
63
63
  logging.error('other')
@@ -84,7 +84,7 @@ def test_assert_logs_valid_multiple_logs():
84
84
  logging.warning('other two')
85
85
 
86
86
 
87
- def test_assert_logs_invalid_multiple_logs():
87
+ def test_assert_logs_invalid_multiple_logs() -> None:
88
88
  with pytest.raises(AssertionError, match='^Expected 1 log message but got 2. Log messages.*$'):
89
89
  with cirq.testing.assert_logs('dog'):
90
90
  logging.error('orange apple fruit')
@@ -107,7 +107,7 @@ def test_assert_logs_invalid_multiple_logs():
107
107
  logging.error('whatever')
108
108
 
109
109
 
110
- def test_assert_logs_log_level():
110
+ def test_assert_logs_log_level() -> None:
111
111
  # Default minlevel is WARNING, max level CRITICAL
112
112
  with cirq.testing.assert_logs('apple'):
113
113
  logging.error('orange apple fruit')
@@ -131,7 +131,7 @@ def test_assert_logs_log_level():
131
131
  logging.warning("info warning 1")
132
132
 
133
133
 
134
- def test_invalid_levels():
134
+ def test_invalid_levels() -> None:
135
135
  with pytest.raises(ValueError, match="min_level.*max_level"):
136
136
  with cirq.testing.assert_logs(
137
137
  "test", min_level=logging.CRITICAL, max_level=logging.WARNING
@@ -139,7 +139,7 @@ def test_invalid_levels():
139
139
  pass
140
140
 
141
141
 
142
- def test_assert_logs_warnings():
142
+ def test_assert_logs_warnings() -> None:
143
143
  # Capture all warnings in one context, so that test cases that will
144
144
  # display a warning do not do so when the test is run.
145
145
  with warnings.catch_warnings(record=True):
@@ -15,16 +15,16 @@
15
15
  import cirq
16
16
 
17
17
 
18
- def test_named_qubit_repr():
18
+ def test_named_qubit_repr() -> None:
19
19
  q = cirq.testing.NoIdentifierQubit()
20
20
  assert repr(q) == "cirq.testing.NoIdentifierQubit()"
21
21
 
22
22
 
23
- def test_comparsion_key():
23
+ def test_comparsion_key() -> None:
24
24
  q = cirq.testing.NoIdentifierQubit()
25
25
  p = cirq.testing.NoIdentifierQubit()
26
26
  assert p == q
27
27
 
28
28
 
29
- def test_to_json():
29
+ def test_to_json() -> None:
30
30
  assert cirq.testing.NoIdentifierQubit()._json_dict_() == {}
@@ -17,7 +17,7 @@ import cirq
17
17
  from cirq.testing import assert_equivalent_op_tree
18
18
 
19
19
 
20
- def test_assert_equivalent_op_tree():
20
+ def test_assert_equivalent_op_tree() -> None:
21
21
  assert_equivalent_op_tree([], [])
22
22
  a = cirq.NamedQubit("a")
23
23
  assert_equivalent_op_tree([cirq.X(a)], [cirq.X(a)])
@@ -62,7 +62,7 @@ class MockValue:
62
62
  return f'MockValue(val={self.val!r}, ...)'
63
63
 
64
64
 
65
- def test_add_ordering_group_correct():
65
+ def test_add_ordering_group_correct() -> None:
66
66
  ot = cirq.testing.OrderTester()
67
67
  ot.add_ascending(-4, 0)
68
68
  ot.add_ascending(1, 2)
@@ -70,7 +70,7 @@ def test_add_ordering_group_correct():
70
70
  ot.add_ascending_equivalence_group(float('inf'), float('inf'))
71
71
 
72
72
 
73
- def test_add_ordering_group_incorrect():
73
+ def test_add_ordering_group_incorrect() -> None:
74
74
  ot = cirq.testing.OrderTester()
75
75
  ot.add_ascending(0)
76
76
  with pytest.raises(AssertionError):
@@ -88,7 +88,7 @@ def test_add_ordering_group_incorrect():
88
88
  ot.add_ascending(0)
89
89
 
90
90
 
91
- def test_propagates_internal_errors():
91
+ def test_propagates_internal_errors() -> None:
92
92
  class UnorderableClass: # pragma: no cover
93
93
  def __eq__(self, other):
94
94
  return NotImplemented
@@ -113,7 +113,7 @@ def test_propagates_internal_errors():
113
113
  ot.add_ascending(UnorderableClass())
114
114
 
115
115
 
116
- def test_add_ascending_equivalence_group():
116
+ def test_add_ascending_equivalence_group() -> None:
117
117
  ot = cirq.testing.OrderTester()
118
118
  with pytest.raises(AssertionError, match='Expected X=1 to equal Y=3'):
119
119
  ot.add_ascending_equivalence_group(1, 3)
@@ -127,7 +127,7 @@ def test_add_ascending_equivalence_group():
127
127
  ot.add_ascending_equivalence_group(5)
128
128
 
129
129
 
130
- def test_fails_to_return_not_implemented_vs_unknown():
130
+ def test_fails_to_return_not_implemented_vs_unknown() -> None:
131
131
  def make_impls(bad_index: int, bad_result: bool):
132
132
  def make_impl(i, op):
133
133
  def impl(x, y):
@@ -153,7 +153,7 @@ def test_fails_to_return_not_implemented_vs_unknown():
153
153
  ot.add_ascending(MockValue(1, *good_impls))
154
154
 
155
155
 
156
- def test_fails_on_inconsistent_hashes():
156
+ def test_fails_on_inconsistent_hashes() -> None:
157
157
  class ModifiedHash(tuple):
158
158
  def __hash__(self):
159
159
  return super().__hash__() ^ 1
@@ -19,7 +19,7 @@ import pytest
19
19
  import cirq
20
20
 
21
21
 
22
- def test_retry_once_after_timeout():
22
+ def test_retry_once_after_timeout() -> None:
23
23
  testfunc = Mock(side_effect=[TimeoutError("first call fails"), None])
24
24
  decoratedfunc = cirq.testing.retry_once_after_timeout(testfunc)
25
25
  with pytest.warns(UserWarning, match="Retrying.*transitive TimeoutError"):
@@ -27,7 +27,7 @@ def test_retry_once_after_timeout():
27
27
  assert testfunc.call_count == 2
28
28
 
29
29
 
30
- def test_retry_once_with_later_random_values():
30
+ def test_retry_once_with_later_random_values() -> None:
31
31
  testfunc = Mock(side_effect=[AssertionError("first call fails"), None])
32
32
  decoratedfunc = cirq.testing.retry_once_with_later_random_values(testfunc)
33
33
  with pytest.warns(UserWarning, match="Retrying.*failing seed.*pytest-randomly"):
@@ -21,7 +21,7 @@ import cirq
21
21
  import cirq.testing
22
22
 
23
23
 
24
- def test_random_circuit_errors():
24
+ def test_random_circuit_errors() -> None:
25
25
  with pytest.raises(ValueError, match='but was -1'):
26
26
  _ = cirq.testing.random_circuit(qubits=5, n_moments=5, op_density=-1)
27
27
 
@@ -92,7 +92,7 @@ def test_random_circuit(
92
92
 
93
93
 
94
94
  @pytest.mark.parametrize('seed', [random.randint(0, 2**32) for _ in range(10)])
95
- def test_random_circuit_reproducible_with_seed(seed):
95
+ def test_random_circuit_reproducible_with_seed(seed) -> None:
96
96
  wrappers = (lambda s: s, np.random.RandomState)
97
97
  circuits = [
98
98
  cirq.testing.random_circuit(
@@ -105,7 +105,7 @@ def test_random_circuit_reproducible_with_seed(seed):
105
105
  eq.add_equality_group(*circuits)
106
106
 
107
107
 
108
- def test_random_circuit_not_expected_number_of_qubits():
108
+ def test_random_circuit_not_expected_number_of_qubits() -> None:
109
109
  circuit = cirq.testing.random_circuit(
110
110
  qubits=3, n_moments=1, op_density=1.0, gate_domain={cirq.CNOT: 2}
111
111
  )
@@ -114,7 +114,7 @@ def test_random_circuit_not_expected_number_of_qubits():
114
114
  assert len(circuit.all_qubits()) == 2
115
115
 
116
116
 
117
- def test_random_circuit_reproducible_between_runs():
117
+ def test_random_circuit_reproducible_between_runs() -> None:
118
118
  circuit = cirq.testing.random_circuit(5, 8, 0.5, random_state=77)
119
119
  expected_diagram = """
120
120
  ┌──┐
@@ -132,7 +132,7 @@ def test_random_circuit_reproducible_between_runs():
132
132
  cirq.testing.assert_has_diagram(circuit, expected_diagram)
133
133
 
134
134
 
135
- def test_random_two_qubit_circuit_with_czs():
135
+ def test_random_two_qubit_circuit_with_czs() -> None:
136
136
  num_czs = lambda circuit: len(
137
137
  [o for o in circuit.all_operations() if isinstance(o.gate, cirq.CZPowGate)]
138
138
  )
@@ -15,7 +15,7 @@
15
15
  import cirq.testing
16
16
 
17
17
 
18
- def test_fake_printer():
18
+ def test_fake_printer() -> None:
19
19
  p = cirq.testing.FakePrinter()
20
20
  assert p.text_pretty == ""
21
21
  p.text("stuff")
@@ -24,7 +24,7 @@ def test_fake_printer():
24
24
  assert p.text_pretty == "stuff more"
25
25
 
26
26
 
27
- def test_assert_repr_pretty():
27
+ def test_assert_repr_pretty() -> None:
28
28
  class TestClass:
29
29
  def _repr_pretty_(self, p, cycle):
30
30
  p.text("TestClass" if cycle else "I'm so pretty")
@@ -44,7 +44,7 @@ def test_assert_repr_pretty():
44
44
  cirq.testing.assert_repr_pretty(TestClassMultipleTexts(), "TestClass", cycle=True)
45
45
 
46
46
 
47
- def test_assert_repr_pretty_contains():
47
+ def test_assert_repr_pretty_contains() -> None:
48
48
  class TestClass:
49
49
  def _repr_pretty_(self, p, cycle):
50
50
  p.text("TestClass" if cycle else "I'm so pretty")
@@ -17,7 +17,7 @@ import pytest
17
17
  import cirq
18
18
 
19
19
 
20
- def test_grid_device():
20
+ def test_grid_device() -> None:
21
21
  rect_device = cirq.testing.construct_grid_device(5, 7)
22
22
  rect_device_graph = rect_device.metadata.nx_graph
23
23
  isomorphism_class = nx.Graph()
@@ -33,7 +33,7 @@ def test_grid_device():
33
33
  assert nx.is_isomorphic(isomorphism_class, rect_device_graph)
34
34
 
35
35
 
36
- def test_grid_op_validation():
36
+ def test_grid_op_validation() -> None:
37
37
  device = cirq.testing.construct_grid_device(5, 7)
38
38
 
39
39
  with pytest.raises(ValueError, match="Qubits not on device"):
@@ -56,7 +56,7 @@ def test_grid_op_validation():
56
56
  device.validate_operation(cirq.CNOT(cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)))
57
57
 
58
58
 
59
- def test_ring_device():
59
+ def test_ring_device() -> None:
60
60
  undirected_device = cirq.testing.construct_ring_device(5)
61
61
  undirected_device_graph = undirected_device.metadata.nx_graph
62
62
  assert all(q in undirected_device_graph.nodes for q in cirq.LineQubit.range(5))
@@ -74,7 +74,7 @@ def test_ring_device():
74
74
  assert nx.is_isomorphic(isomorphism_class, directed_device_graph)
75
75
 
76
76
 
77
- def test_ring_op_validation():
77
+ def test_ring_op_validation() -> None:
78
78
  directed_device = cirq.testing.construct_ring_device(5, directed=True)
79
79
  undirected_device = cirq.testing.construct_ring_device(5, directed=False)
80
80
 
@@ -93,7 +93,7 @@ def test_ring_op_validation():
93
93
  directed_device.validate_operation(cirq.CNOT(cirq.LineQubit(0), cirq.LineQubit(1)))
94
94
 
95
95
 
96
- def test_allowed_multi_qubit_gates():
96
+ def test_allowed_multi_qubit_gates() -> None:
97
97
  device = cirq.testing.construct_ring_device(5)
98
98
 
99
99
  device.validate_operation(cirq.MeasurementGate(1).on(cirq.LineQubit(0)))
@@ -106,7 +106,7 @@ def test_allowed_multi_qubit_gates():
106
106
  device.validate_operation(cirq.CNOT(*cirq.LineQubit.range(2)))
107
107
 
108
108
 
109
- def test_namedqubit_device():
109
+ def test_namedqubit_device() -> None:
110
110
  # 4-star graph
111
111
  nx_graph = nx.Graph([("a", "b"), ("a", "c"), ("a", "d")])
112
112
 
@@ -15,7 +15,7 @@
15
15
  import cirq
16
16
 
17
17
 
18
- def test_nonoptimal_toffoli_circuit():
18
+ def test_nonoptimal_toffoli_circuit() -> None:
19
19
  q0, q1, q2 = cirq.LineQubit.range(3)
20
20
  cirq.testing.assert_allclose_up_to_global_phase(
21
21
  cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2).unitary(),
@@ -19,7 +19,7 @@ from cirq.testing import sample_gates
19
19
 
20
20
 
21
21
  @pytest.mark.parametrize('theta', np.linspace(0, 2 * np.pi, 20))
22
- def test_phase_using_clean_ancilla(theta: float):
22
+ def test_phase_using_clean_ancilla(theta: float) -> None:
23
23
  g = sample_gates.PhaseUsingCleanAncilla(theta)
24
24
  q = cirq.LineQubit(0)
25
25
  qubit_order = cirq.QubitOrder.explicit([q], fallback=cirq.QubitOrder.DEFAULT)
@@ -45,7 +45,7 @@ def test_phase_using_clean_ancilla(theta: float):
45
45
  'target_bitsize, phase_state', [(1, 0), (1, 1), (2, 0), (2, 1), (2, 2), (2, 3)]
46
46
  )
47
47
  @pytest.mark.parametrize('ancilla_bitsize', [1, 4])
48
- def test_phase_using_dirty_ancilla(target_bitsize, phase_state, ancilla_bitsize):
48
+ def test_phase_using_dirty_ancilla(target_bitsize, phase_state, ancilla_bitsize) -> None:
49
49
  g = sample_gates.PhaseUsingDirtyAncilla(phase_state, target_bitsize, ancilla_bitsize)
50
50
  q = cirq.LineQubit.range(target_bitsize)
51
51
  qubit_order = cirq.QubitOrder.explicit(q, fallback=cirq.QubitOrder.DEFAULT)
@@ -28,7 +28,7 @@ from cirq.transformers.analytical_decompositions import unitary_to_pauli_string
28
28
  @pytest.mark.parametrize(
29
29
  'pauli_string', [''.join(p) for p in itertools.product(['', 'I', 'X', 'Y', 'Z'], repeat=4)]
30
30
  )
31
- def test_unitary_to_pauli_string(pauli_string: str, phase: complex):
31
+ def test_unitary_to_pauli_string(pauli_string: str, phase: complex) -> None:
32
32
  want = DensePauliString(pauli_string, coefficient=phase)
33
33
  got = unitary_to_pauli_string(protocols.unitary(want))
34
34
  assert got is not None
@@ -36,7 +36,7 @@ def test_unitary_to_pauli_string(pauli_string: str, phase: complex):
36
36
  assert np.isclose(cast(np.complex128, want.coefficient), cast(np.complex128, got.coefficient))
37
37
 
38
38
 
39
- def test_unitary_to_pauli_string_non_pauli_input():
39
+ def test_unitary_to_pauli_string_non_pauli_input() -> None:
40
40
  got = unitary_to_pauli_string(protocols.unitary(T))
41
41
  assert got is None
42
42
 
@@ -50,7 +50,7 @@ def test_unitary_to_pauli_string_non_pauli_input():
50
50
  assert got is None
51
51
 
52
52
 
53
- def test_invalid_input():
53
+ def test_invalid_input() -> None:
54
54
  with pytest.raises(ValueError, match='Input has a non-square shape.*'):
55
55
  _ = unitary_to_pauli_string(np.zeros((2, 3)))
56
56
 
@@ -52,7 +52,7 @@ def _skip_if_scipy(*, version_is_greater_than_1_5_0: bool) -> Callable[[Callable
52
52
  cirq.CCX._unitary_(),
53
53
  ],
54
54
  )
55
- def test_three_qubit_matrix_to_operations(u):
55
+ def test_three_qubit_matrix_to_operations(u) -> None:
56
56
  a, b, c = cirq.LineQubit.range(3)
57
57
  operations = cirq.three_qubit_matrix_to_operations(a, b, c, u)
58
58
  final_circuit = cirq.Circuit(operations)
@@ -69,7 +69,7 @@ def test_three_qubit_matrix_to_operations(u):
69
69
 
70
70
 
71
71
  @_skip_if_scipy(version_is_greater_than_1_5_0=False)
72
- def test_three_qubit_matrix_to_operations_errors():
72
+ def test_three_qubit_matrix_to_operations_errors() -> None:
73
73
  a, b, c = cirq.LineQubit.range(3)
74
74
  with pytest.raises(ValueError, match="(8,8)"):
75
75
  cirq.three_qubit_matrix_to_operations(a, b, c, np.eye(2))
@@ -82,7 +82,7 @@ def test_three_qubit_matrix_to_operations_errors():
82
82
  # environment like that, we'll need to ignore the coverage somehow conditionally on
83
83
  # the scipy version.
84
84
  @_skip_if_scipy(version_is_greater_than_1_5_0=True)
85
- def test_three_qubit_matrix_to_operations_scipy_error(): # pragma: no cover
85
+ def test_three_qubit_matrix_to_operations_scipy_error() -> None: # pragma: no cover
86
86
  a, b, c = cirq.LineQubit.range(3)
87
87
  with pytest.raises(ImportError, match="three_qubit.*1.5.0+"):
88
88
  cirq.three_qubit_matrix_to_operations(a, b, c, np.eye(8))
@@ -100,7 +100,7 @@ def test_three_qubit_matrix_to_operations_scipy_error(): # pragma: no cover
100
100
  (np.array([0.3, 0.3, -0.3, -0.3]), 2),
101
101
  ],
102
102
  )
103
- def test_cs_to_ops(theta, num_czs):
103
+ def test_cs_to_ops(theta, num_czs) -> None:
104
104
  a, b, c = cirq.LineQubit.range(3)
105
105
  cs = _theta_to_cs(theta)
106
106
  circuit_cs = cirq.Circuit(_cs_to_ops(a, b, c, theta))
@@ -126,7 +126,7 @@ def _theta_to_cs(theta: np.ndarray) -> np.ndarray:
126
126
  return np.block([[c, -s], [s, c]])
127
127
 
128
128
 
129
- def test_multiplexed_angles():
129
+ def test_multiplexed_angles() -> None:
130
130
  theta = [random() * np.pi, random() * np.pi, random() * np.pi, random() * np.pi]
131
131
 
132
132
  angles = _multiplexed_angles(theta)
@@ -190,7 +190,7 @@ def test_multiplexed_angles():
190
190
  [([-0.3, 0.3, -0.3, -0.3]), 4],
191
191
  ],
192
192
  )
193
- def test_middle_multiplexor(angles, num_cnots):
193
+ def test_middle_multiplexor(angles, num_cnots) -> None:
194
194
  a, b, c = cirq.LineQubit.range(3)
195
195
  eigvals = np.exp(np.array(angles) * np.pi * 1j)
196
196
  d = np.diag(np.sqrt(eigvals))
@@ -212,7 +212,7 @@ def test_middle_multiplexor(angles, num_cnots):
212
212
 
213
213
 
214
214
  @pytest.mark.parametrize("shift_left", [True, False])
215
- def test_two_qubit_multiplexor_to_circuit(shift_left):
215
+ def test_two_qubit_multiplexor_to_circuit(shift_left) -> None:
216
216
  a, b, c = cirq.LineQubit.range(3)
217
217
  u1 = cirq.testing.random_unitary(4)
218
218
  u2 = cirq.testing.random_unitary(4)
@@ -52,7 +52,7 @@ from cirq.transformers.analytical_decompositions.two_qubit_to_cz import (
52
52
  ]
53
53
  )(1e-8 * 2 / 3, 1e-8 * 4 / 3),
54
54
  )
55
- def test_is_trivial_angle(rad, expected):
55
+ def test_is_trivial_angle(rad, expected) -> None:
56
56
  tolerance = 1e-8
57
57
  out = _is_trivial_angle(rad, tolerance)
58
58
  assert out == expected, f'rad = {rad}'
@@ -163,7 +163,7 @@ def test_two_to_ops_equivalent_and_bounded_for_known_and_random(
163
163
  assert_cz_depth_below(operations_with_full, max_full_cz_depth, True)
164
164
 
165
165
 
166
- def test_trivial_parity_interaction_corner_case():
166
+ def test_trivial_parity_interaction_corner_case() -> None:
167
167
  q0 = cirq.NamedQubit('q0')
168
168
  q1 = cirq.NamedQubit('q1')
169
169
  nearPi4 = np.pi / 4 * 0.99
@@ -172,7 +172,7 @@ def test_trivial_parity_interaction_corner_case():
172
172
  assert len(circuit) == 2
173
173
 
174
174
 
175
- def test_kak_decomposition_depth_full_cz():
175
+ def test_kak_decomposition_depth_full_cz() -> None:
176
176
  a, b = cirq.LineQubit.range(2)
177
177
 
178
178
  # Random.
@@ -210,7 +210,7 @@ def test_kak_decomposition_depth_full_cz():
210
210
  assert len(c) <= 4
211
211
 
212
212
 
213
- def test_kak_decomposition_depth_partial_cz():
213
+ def test_kak_decomposition_depth_partial_cz() -> None:
214
214
  a, b = cirq.LineQubit.range(2)
215
215
 
216
216
  # Random.
@@ -250,7 +250,7 @@ def test_kak_decomposition_depth_partial_cz():
250
250
  np.diag(np.exp(1j * np.pi * np.random.random(4))),
251
251
  ],
252
252
  )
253
- def test_decompose_to_diagonal_and_circuit(v):
253
+ def test_decompose_to_diagonal_and_circuit(v) -> None:
254
254
  b, c = cirq.LineQubit.range(2)
255
255
  diagonal, ops = two_qubit_matrix_to_diagonal_and_cz_operations(b, c, v, atol=1e-8)
256
256
  assert cirq.is_diagonal(diagonal)
@@ -259,7 +259,7 @@ def test_decompose_to_diagonal_and_circuit(v):
259
259
  cirq.testing.assert_allclose_up_to_global_phase(circuit_unitary, v, atol=2e-6)
260
260
 
261
261
 
262
- def test_remove_partial_czs_or_fail():
262
+ def test_remove_partial_czs_or_fail() -> None:
263
263
  CZ = cirq.CZ(*cirq.LineQubit.range(2))
264
264
  assert (
265
265
  cirq.transformers.analytical_decompositions.two_qubit_to_cz._remove_partial_czs_or_fail(
@@ -65,7 +65,7 @@ FEASIBLE_FSIM_GATES = [
65
65
 
66
66
 
67
67
  @pytest.mark.parametrize('obj', UNITARY_OBJS)
68
- def test_decompose_two_qubit_interaction_into_two_b_gates(obj: Any):
68
+ def test_decompose_two_qubit_interaction_into_two_b_gates(obj: Any) -> None:
69
69
  circuit = cirq.Circuit(
70
70
  _decompose_two_qubit_interaction_into_two_b_gates(obj, qubits=cirq.LineQubit.range(2))
71
71
  )
@@ -75,7 +75,7 @@ def test_decompose_two_qubit_interaction_into_two_b_gates(obj: Any):
75
75
  np.testing.assert_allclose(cirq.unitary(circuit), desired_unitary, atol=1e-6)
76
76
 
77
77
 
78
- def test_decompose_xx_yy_into_two_fsims_ignoring_single_qubit_ops_fail():
78
+ def test_decompose_xx_yy_into_two_fsims_ignoring_single_qubit_ops_fail() -> None:
79
79
  c = _decompose_xx_yy_into_two_fsims_ignoring_single_qubit_ops(
80
80
  qubits=cirq.LineQubit.range(2),
81
81
  fsim_gate=cirq.FSimGate(theta=np.pi / 2, phi=0),
@@ -108,7 +108,7 @@ def test_decompose_two_qubit_interaction_into_four_fsim_gates_equivalence(
108
108
  assert cirq.approx_eq(circuit.unitary(qubit_order=qubits), desired_unitary, atol=1e-4)
109
109
 
110
110
 
111
- def test_decompose_two_qubit_interaction_into_four_fsim_gates_validate():
111
+ def test_decompose_two_qubit_interaction_into_four_fsim_gates_validate() -> None:
112
112
  iswap = cirq.FSimGate(theta=np.pi / 2, phi=0)
113
113
  with pytest.raises(ValueError, match='fsim_gate.theta'):
114
114
  cirq.decompose_two_qubit_interaction_into_four_fsim_gates(
@@ -127,7 +127,7 @@ def test_decompose_two_qubit_interaction_into_four_fsim_gates_validate():
127
127
  cirq.decompose_two_qubit_interaction_into_four_fsim_gates(np.eye(4), fsim_gate=fsim)
128
128
 
129
129
 
130
- def test_decompose_two_qubit_interaction_into_four_fsim_gates():
130
+ def test_decompose_two_qubit_interaction_into_four_fsim_gates() -> None:
131
131
  iswap = cirq.FSimGate(theta=np.pi / 2, phi=0)
132
132
 
133
133
  # Defaults to line qubits.
@@ -153,7 +153,7 @@ def test_decompose_two_qubit_interaction_into_four_fsim_gates():
153
153
  assert set(c.all_qubits()) == set(cirq.LineQubit.range(10, 12))
154
154
 
155
155
 
156
- def test_sticky_0_to_1():
156
+ def test_sticky_0_to_1() -> None:
157
157
  assert _sticky_0_to_1(-1, atol=1e-8) is None
158
158
 
159
159
  assert _sticky_0_to_1(-1e-6, atol=1e-8) is None