cirq-core 1.7.0.dev20250911180440__py3-none-any.whl → 1.7.0.dev20250917002151__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 (65) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit_operation_test.py +5 -0
  4. cirq/ops/classically_controlled_operation.py +3 -7
  5. cirq/ops/gate_operation.py +15 -0
  6. cirq/ops/linear_combinations.py +4 -14
  7. cirq/ops/measure_util.py +7 -6
  8. cirq/ops/pauli_string_test.py +7 -6
  9. cirq/ops/raw_types.py +19 -2
  10. cirq/protocols/has_stabilizer_effect_protocol_test.py +11 -9
  11. cirq/protocols/has_unitary_protocol_test.py +3 -3
  12. cirq/protocols/json_serialization.py +3 -3
  13. cirq/protocols/json_serialization_test.py +31 -31
  14. cirq/protocols/kraus_protocol_test.py +5 -5
  15. cirq/protocols/measurement_key_protocol.py +31 -8
  16. cirq/protocols/mixture_protocol.py +1 -1
  17. cirq/protocols/mixture_protocol_test.py +7 -7
  18. cirq/protocols/mul_protocol_test.py +4 -4
  19. cirq/protocols/phase_protocol.py +13 -4
  20. cirq/protocols/pow_protocol_test.py +5 -5
  21. cirq/protocols/resolve_parameters.py +1 -1
  22. cirq/protocols/unitary_protocol_test.py +31 -19
  23. cirq/qis/clifford_tableau.py +14 -14
  24. cirq/qis/clifford_tableau_test.py +17 -17
  25. cirq/qis/entropy.py +1 -1
  26. cirq/qis/entropy_test.py +1 -1
  27. cirq/qis/states_test.py +54 -54
  28. cirq/sim/classical_simulator_test.py +56 -28
  29. cirq/sim/clifford/clifford_simulator.py +5 -5
  30. cirq/sim/clifford/clifford_simulator_test.py +50 -49
  31. cirq/sim/clifford/stabilizer_state_ch_form.py +9 -9
  32. cirq/sim/density_matrix_simulation_state.py +6 -6
  33. cirq/sim/density_matrix_simulator.py +1 -1
  34. cirq/sim/density_matrix_simulator_test.py +94 -84
  35. cirq/sim/density_matrix_utils_test.py +1 -1
  36. cirq/sim/mux_test.py +26 -26
  37. cirq/sim/simulation_product_state_test.py +7 -7
  38. cirq/sim/simulation_state.py +4 -4
  39. cirq/sim/simulation_state_base.py +1 -1
  40. cirq/sim/simulation_state_test.py +5 -5
  41. cirq/sim/simulator.py +2 -2
  42. cirq/sim/simulator_base_test.py +49 -35
  43. cirq/sim/simulator_test.py +39 -35
  44. cirq/sim/sparse_simulator.py +1 -1
  45. cirq/sim/sparse_simulator_test.py +92 -82
  46. cirq/sim/state_vector.py +1 -1
  47. cirq/sim/state_vector_simulation_state.py +7 -7
  48. cirq/sim/state_vector_simulator_test.py +9 -9
  49. cirq/sim/state_vector_test.py +37 -37
  50. cirq/study/result_test.py +20 -20
  51. cirq/study/sweepable_test.py +20 -20
  52. cirq/study/sweeps_test.py +43 -43
  53. cirq/testing/circuit_compare_test.py +16 -14
  54. cirq/testing/consistent_channels.py +2 -2
  55. cirq/testing/consistent_controlled_gate_op.py +1 -1
  56. cirq/testing/consistent_decomposition.py +4 -2
  57. cirq/testing/consistent_phase_by.py +1 -1
  58. cirq/testing/consistent_qasm.py +2 -2
  59. cirq/testing/consistent_qasm_test.py +3 -3
  60. cirq/transformers/eject_z.py +1 -0
  61. {cirq_core-1.7.0.dev20250911180440.dist-info → cirq_core-1.7.0.dev20250917002151.dist-info}/METADATA +1 -1
  62. {cirq_core-1.7.0.dev20250911180440.dist-info → cirq_core-1.7.0.dev20250917002151.dist-info}/RECORD +65 -65
  63. {cirq_core-1.7.0.dev20250911180440.dist-info → cirq_core-1.7.0.dev20250917002151.dist-info}/WHEEL +0 -0
  64. {cirq_core-1.7.0.dev20250911180440.dist-info → cirq_core-1.7.0.dev20250917002151.dist-info}/licenses/LICENSE +0 -0
  65. {cirq_core-1.7.0.dev20250911180440.dist-info → cirq_core-1.7.0.dev20250917002151.dist-info}/top_level.txt +0 -0
@@ -25,14 +25,14 @@ import sympy
25
25
  import cirq
26
26
 
27
27
 
28
- def test_invalid_dtype():
28
+ def test_invalid_dtype() -> None:
29
29
  with pytest.raises(ValueError, match='complex'):
30
- cirq.Simulator(dtype=np.int32)
30
+ cirq.Simulator(dtype=np.int32) # type: ignore[arg-type]
31
31
 
32
32
 
33
33
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
34
34
  @pytest.mark.parametrize('split', [True, False])
35
- def test_run_no_measurements(dtype: type[np.complexfloating], split: bool):
35
+ def test_run_no_measurements(dtype: type[np.complexfloating], split: bool) -> None:
36
36
  q0, q1 = cirq.LineQubit.range(2)
37
37
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
38
38
 
@@ -43,7 +43,7 @@ def test_run_no_measurements(dtype: type[np.complexfloating], split: bool):
43
43
 
44
44
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
45
45
  @pytest.mark.parametrize('split', [True, False])
46
- def test_run_no_results(dtype: type[np.complexfloating], split: bool):
46
+ def test_run_no_results(dtype: type[np.complexfloating], split: bool) -> None:
47
47
  q0, q1 = cirq.LineQubit.range(2)
48
48
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
49
49
 
@@ -54,7 +54,7 @@ def test_run_no_results(dtype: type[np.complexfloating], split: bool):
54
54
 
55
55
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
56
56
  @pytest.mark.parametrize('split', [True, False])
57
- def test_run_empty_circuit(dtype: type[np.complexfloating], split: bool):
57
+ def test_run_empty_circuit(dtype: type[np.complexfloating], split: bool) -> None:
58
58
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
59
59
  with pytest.raises(ValueError, match="no measurements"):
60
60
  simulator.run(cirq.Circuit())
@@ -62,7 +62,7 @@ def test_run_empty_circuit(dtype: type[np.complexfloating], split: bool):
62
62
 
63
63
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
64
64
  @pytest.mark.parametrize('split', [True, False])
65
- def test_run_reset(dtype: type[np.complexfloating], split: bool):
65
+ def test_run_reset(dtype: type[np.complexfloating], split: bool) -> None:
66
66
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
67
67
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
68
68
  circuit = cirq.Circuit(
@@ -82,7 +82,7 @@ def test_run_reset(dtype: type[np.complexfloating], split: bool):
82
82
 
83
83
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
84
84
  @pytest.mark.parametrize('split', [True, False])
85
- def test_run_bit_flips(dtype: type[np.complexfloating], split: bool):
85
+ def test_run_bit_flips(dtype: type[np.complexfloating], split: bool) -> None:
86
86
  q0, q1 = cirq.LineQubit.range(2)
87
87
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
88
88
  for b0 in [0, 1]:
@@ -96,7 +96,7 @@ def test_run_bit_flips(dtype: type[np.complexfloating], split: bool):
96
96
 
97
97
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
98
98
  @pytest.mark.parametrize('split', [True, False])
99
- def test_run_measure_at_end_no_repetitions(dtype: type[np.complexfloating], split: bool):
99
+ def test_run_measure_at_end_no_repetitions(dtype: type[np.complexfloating], split: bool) -> None:
100
100
  q0, q1 = cirq.LineQubit.range(2)
101
101
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
102
102
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -113,7 +113,7 @@ def test_run_measure_at_end_no_repetitions(dtype: type[np.complexfloating], spli
113
113
  assert mock_sim.call_count == 0
114
114
 
115
115
 
116
- def test_run_repetitions_terminal_measurement_stochastic():
116
+ def test_run_repetitions_terminal_measurement_stochastic() -> None:
117
117
  q = cirq.LineQubit(0)
118
118
  c = cirq.Circuit(cirq.H(q), cirq.measure(q, key='q'))
119
119
  results = cirq.Simulator().run(c, repetitions=10000)
@@ -122,7 +122,7 @@ def test_run_repetitions_terminal_measurement_stochastic():
122
122
 
123
123
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
124
124
  @pytest.mark.parametrize('split', [True, False])
125
- def test_run_repetitions_measure_at_end(dtype: type[np.complexfloating], split: bool):
125
+ def test_run_repetitions_measure_at_end(dtype: type[np.complexfloating], split: bool) -> None:
126
126
  q0, q1 = cirq.LineQubit.range(2)
127
127
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
128
128
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -142,7 +142,7 @@ def test_run_repetitions_measure_at_end(dtype: type[np.complexfloating], split:
142
142
 
143
143
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
144
144
  @pytest.mark.parametrize('split', [True, False])
145
- def test_run_invert_mask_measure_not_terminal(dtype: type[np.complexfloating], split: bool):
145
+ def test_run_invert_mask_measure_not_terminal(dtype: type[np.complexfloating], split: bool) -> None:
146
146
  q0, q1 = cirq.LineQubit.range(2)
147
147
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
148
148
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -163,7 +163,9 @@ def test_run_invert_mask_measure_not_terminal(dtype: type[np.complexfloating], s
163
163
 
164
164
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
165
165
  @pytest.mark.parametrize('split', [True, False])
166
- def test_run_partial_invert_mask_measure_not_terminal(dtype: type[np.complexfloating], split: bool):
166
+ def test_run_partial_invert_mask_measure_not_terminal(
167
+ dtype: type[np.complexfloating], split: bool
168
+ ) -> None:
167
169
  q0, q1 = cirq.LineQubit.range(2)
168
170
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
169
171
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -184,7 +186,9 @@ def test_run_partial_invert_mask_measure_not_terminal(dtype: type[np.complexfloa
184
186
 
185
187
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
186
188
  @pytest.mark.parametrize('split', [True, False])
187
- def test_run_measurement_not_terminal_no_repetitions(dtype: type[np.complexfloating], split: bool):
189
+ def test_run_measurement_not_terminal_no_repetitions(
190
+ dtype: type[np.complexfloating], split: bool
191
+ ) -> None:
188
192
  q0, q1 = cirq.LineQubit.range(2)
189
193
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
190
194
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -208,7 +212,9 @@ def test_run_measurement_not_terminal_no_repetitions(dtype: type[np.complexfloat
208
212
 
209
213
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
210
214
  @pytest.mark.parametrize('split', [True, False])
211
- def test_run_repetitions_measurement_not_terminal(dtype: type[np.complexfloating], split: bool):
215
+ def test_run_repetitions_measurement_not_terminal(
216
+ dtype: type[np.complexfloating], split: bool
217
+ ) -> None:
212
218
  q0, q1 = cirq.LineQubit.range(2)
213
219
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
214
220
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -233,7 +239,7 @@ def test_run_repetitions_measurement_not_terminal(dtype: type[np.complexfloating
233
239
 
234
240
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
235
241
  @pytest.mark.parametrize('split', [True, False])
236
- def test_run_param_resolver(dtype: type[np.complexfloating], split: bool):
242
+ def test_run_param_resolver(dtype: type[np.complexfloating], split: bool) -> None:
237
243
  q0, q1 = cirq.LineQubit.range(2)
238
244
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
239
245
  for b0 in [0, 1]:
@@ -252,7 +258,7 @@ def test_run_param_resolver(dtype: type[np.complexfloating], split: bool):
252
258
 
253
259
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
254
260
  @pytest.mark.parametrize('split', [True, False])
255
- def test_run_mixture(dtype: type[np.complexfloating], split: bool):
261
+ def test_run_mixture(dtype: type[np.complexfloating], split: bool) -> None:
256
262
  q0 = cirq.LineQubit(0)
257
263
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
258
264
  circuit = cirq.Circuit(cirq.bit_flip(0.5)(q0), cirq.measure(q0))
@@ -262,7 +268,7 @@ def test_run_mixture(dtype: type[np.complexfloating], split: bool):
262
268
 
263
269
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
264
270
  @pytest.mark.parametrize('split', [True, False])
265
- def test_run_mixture_with_gates(dtype: type[np.complexfloating], split: bool):
271
+ def test_run_mixture_with_gates(dtype: type[np.complexfloating], split: bool) -> None:
266
272
  q0 = cirq.LineQubit(0)
267
273
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split, seed=23)
268
274
  circuit = cirq.Circuit(cirq.H(q0), cirq.phase_flip(0.5)(q0), cirq.H(q0), cirq.measure(q0))
@@ -273,7 +279,7 @@ def test_run_mixture_with_gates(dtype: type[np.complexfloating], split: bool):
273
279
 
274
280
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
275
281
  @pytest.mark.parametrize('split', [True, False])
276
- def test_run_correlations(dtype: type[np.complexfloating], split: bool):
282
+ def test_run_correlations(dtype: type[np.complexfloating], split: bool) -> None:
277
283
  q0, q1 = cirq.LineQubit.range(2)
278
284
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
279
285
  circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1), cirq.measure(q0, q1))
@@ -285,7 +291,7 @@ def test_run_correlations(dtype: type[np.complexfloating], split: bool):
285
291
 
286
292
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
287
293
  @pytest.mark.parametrize('split', [True, False])
288
- def test_run_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool):
294
+ def test_run_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool) -> None:
289
295
  q0, q1 = cirq.LineQubit.range(2)
290
296
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
291
297
  for b0 in [0, 1]:
@@ -297,7 +303,7 @@ def test_run_measure_multiple_qubits(dtype: type[np.complexfloating], split: boo
297
303
 
298
304
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
299
305
  @pytest.mark.parametrize('split', [True, False])
300
- def test_run_sweeps_param_resolvers(dtype: type[np.complexfloating], split: bool):
306
+ def test_run_sweeps_param_resolvers(dtype: type[np.complexfloating], split: bool) -> None:
301
307
  q0, q1 = cirq.LineQubit.range(2)
302
308
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
303
309
  for b0 in [0, 1]:
@@ -323,7 +329,7 @@ def test_run_sweeps_param_resolvers(dtype: type[np.complexfloating], split: bool
323
329
 
324
330
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
325
331
  @pytest.mark.parametrize('split', [True, False])
326
- def test_simulate_random_unitary(dtype: type[np.complexfloating], split: bool):
332
+ def test_simulate_random_unitary(dtype: type[np.complexfloating], split: bool) -> None:
327
333
  q0, q1 = cirq.LineQubit.range(2)
328
334
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
329
335
  for _ in range(10):
@@ -341,7 +347,7 @@ def test_simulate_random_unitary(dtype: type[np.complexfloating], split: bool):
341
347
 
342
348
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
343
349
  @pytest.mark.parametrize('split', [True, False])
344
- def test_simulate_no_circuit(dtype: type[np.complexfloating], split: bool):
350
+ def test_simulate_no_circuit(dtype: type[np.complexfloating], split: bool) -> None:
345
351
  q0, q1 = cirq.LineQubit.range(2)
346
352
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
347
353
  circuit = cirq.Circuit()
@@ -352,7 +358,7 @@ def test_simulate_no_circuit(dtype: type[np.complexfloating], split: bool):
352
358
 
353
359
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
354
360
  @pytest.mark.parametrize('split', [True, False])
355
- def test_simulate(dtype: type[np.complexfloating], split: bool):
361
+ def test_simulate(dtype: type[np.complexfloating], split: bool) -> None:
356
362
  q0, q1 = cirq.LineQubit.range(2)
357
363
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
358
364
  circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1))
@@ -374,7 +380,7 @@ class _TestMixture(cirq.Gate):
374
380
 
375
381
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
376
382
  @pytest.mark.parametrize('split', [True, False])
377
- def test_simulate_qudits(dtype: type[np.complexfloating], split: bool):
383
+ def test_simulate_qudits(dtype: type[np.complexfloating], split: bool) -> None:
378
384
  q0, q1 = cirq.LineQid.for_qid_shape((3, 4))
379
385
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
380
386
  circuit = cirq.Circuit(cirq.XPowGate(dimension=3)(q0), cirq.XPowGate(dimension=4)(q1) ** 3)
@@ -387,7 +393,7 @@ def test_simulate_qudits(dtype: type[np.complexfloating], split: bool):
387
393
 
388
394
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
389
395
  @pytest.mark.parametrize('split', [True, False])
390
- def test_simulate_mixtures(dtype: type[np.complexfloating], split: bool):
396
+ def test_simulate_mixtures(dtype: type[np.complexfloating], split: bool) -> None:
391
397
  q0 = cirq.LineQubit(0)
392
398
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
393
399
  circuit = cirq.Circuit(cirq.bit_flip(0.5)(q0), cirq.measure(q0))
@@ -405,7 +411,7 @@ def test_simulate_mixtures(dtype: type[np.complexfloating], split: bool):
405
411
  @pytest.mark.parametrize(
406
412
  'dtype, split', itertools.product([np.complex64, np.complex128], [True, False])
407
413
  )
408
- def test_simulate_qudit_mixtures(dtype: type[np.complexfloating], split: bool):
414
+ def test_simulate_qudit_mixtures(dtype: type[np.complexfloating], split: bool) -> None:
409
415
  q0 = cirq.LineQid(0, 3)
410
416
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
411
417
  mixture = _TestMixture(
@@ -431,7 +437,7 @@ def test_simulate_qudit_mixtures(dtype: type[np.complexfloating], split: bool):
431
437
 
432
438
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
433
439
  @pytest.mark.parametrize('split', [True, False])
434
- def test_simulate_bit_flips(dtype: type[np.complexfloating], split: bool):
440
+ def test_simulate_bit_flips(dtype: type[np.complexfloating], split: bool) -> None:
435
441
  q0, q1 = cirq.LineQubit.range(2)
436
442
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
437
443
  for b0 in [0, 1]:
@@ -456,7 +462,7 @@ def test_simulate_initial_state(
456
462
  dtype: type[np.complexfloating],
457
463
  split: bool,
458
464
  initial_state: int | cirq.StateVectorSimulationState,
459
- ):
465
+ ) -> None:
460
466
  q0, q1 = cirq.LineQubit.range(2)
461
467
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
462
468
  for b0 in [0, 1]:
@@ -470,7 +476,7 @@ def test_simulate_initial_state(
470
476
 
471
477
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
472
478
  @pytest.mark.parametrize('split', [True, False])
473
- def test_simulation_state(dtype: type[np.complexfloating], split: bool):
479
+ def test_simulation_state(dtype: type[np.complexfloating], split: bool) -> None:
474
480
  q0, q1 = cirq.LineQubit.range(2)
475
481
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
476
482
  for b0 in [0, 1]:
@@ -485,7 +491,7 @@ def test_simulation_state(dtype: type[np.complexfloating], split: bool):
485
491
 
486
492
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
487
493
  @pytest.mark.parametrize('split', [True, False])
488
- def test_simulate_qubit_order(dtype: type[np.complexfloating], split: bool):
494
+ def test_simulate_qubit_order(dtype: type[np.complexfloating], split: bool) -> None:
489
495
  q0, q1 = cirq.LineQubit.range(2)
490
496
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
491
497
  for b0 in [0, 1]:
@@ -499,7 +505,7 @@ def test_simulate_qubit_order(dtype: type[np.complexfloating], split: bool):
499
505
 
500
506
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
501
507
  @pytest.mark.parametrize('split', [True, False])
502
- def test_simulate_param_resolver(dtype: type[np.complexfloating], split: bool):
508
+ def test_simulate_param_resolver(dtype: type[np.complexfloating], split: bool) -> None:
503
509
  q0, q1 = cirq.LineQubit.range(2)
504
510
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
505
511
  for b0 in [0, 1]:
@@ -518,7 +524,7 @@ def test_simulate_param_resolver(dtype: type[np.complexfloating], split: bool):
518
524
 
519
525
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
520
526
  @pytest.mark.parametrize('split', [True, False])
521
- def test_simulate_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool):
527
+ def test_simulate_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool) -> None:
522
528
  q0, q1 = cirq.LineQubit.range(2)
523
529
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
524
530
  for b0 in [0, 1]:
@@ -530,7 +536,7 @@ def test_simulate_measure_multiple_qubits(dtype: type[np.complexfloating], split
530
536
 
531
537
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
532
538
  @pytest.mark.parametrize('split', [True, False])
533
- def test_simulate_sweeps_param_resolver(dtype: type[np.complexfloating], split: bool):
539
+ def test_simulate_sweeps_param_resolver(dtype: type[np.complexfloating], split: bool) -> None:
534
540
  q0, q1 = cirq.LineQubit.range(2)
535
541
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
536
542
  for b0 in [0, 1]:
@@ -557,7 +563,7 @@ def test_simulate_sweeps_param_resolver(dtype: type[np.complexfloating], split:
557
563
 
558
564
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
559
565
  @pytest.mark.parametrize('split', [True, False])
560
- def test_simulate_moment_steps(dtype: type[np.complexfloating], split: bool):
566
+ def test_simulate_moment_steps(dtype: type[np.complexfloating], split: bool) -> None:
561
567
  q0, q1 = cirq.LineQubit.range(2)
562
568
  circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1), cirq.H(q0), cirq.H(q1))
563
569
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
@@ -570,7 +576,7 @@ def test_simulate_moment_steps(dtype: type[np.complexfloating], split: bool):
570
576
 
571
577
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
572
578
  @pytest.mark.parametrize('split', [True, False])
573
- def test_simulate_moment_steps_empty_circuit(dtype: type[np.complexfloating], split: bool):
579
+ def test_simulate_moment_steps_empty_circuit(dtype: type[np.complexfloating], split: bool) -> None:
574
580
  circuit = cirq.Circuit()
575
581
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
576
582
  for step in simulator.simulate_moment_steps(circuit):
@@ -581,7 +587,7 @@ def test_simulate_moment_steps_empty_circuit(dtype: type[np.complexfloating], sp
581
587
 
582
588
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
583
589
  @pytest.mark.parametrize('split', [True, False])
584
- def test_simulate_moment_steps_sample(dtype: type[np.complexfloating], split: bool):
590
+ def test_simulate_moment_steps_sample(dtype: type[np.complexfloating], split: bool) -> None:
585
591
  q0, q1 = cirq.LineQubit.range(2)
586
592
  circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1))
587
593
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
@@ -604,7 +610,7 @@ def test_simulate_moment_steps_sample(dtype: type[np.complexfloating], split: bo
604
610
  @pytest.mark.parametrize('split', [True, False])
605
611
  def test_simulate_moment_steps_intermediate_measurement(
606
612
  dtype: type[np.complexfloating], split: bool
607
- ):
613
+ ) -> None:
608
614
  q0 = cirq.LineQubit(0)
609
615
  circuit = cirq.Circuit(cirq.H(q0), cirq.measure(q0), cirq.H(q0))
610
616
  simulator = cirq.Simulator(dtype=dtype, split_untangled_states=split)
@@ -621,7 +627,7 @@ def test_simulate_moment_steps_intermediate_measurement(
621
627
 
622
628
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
623
629
  @pytest.mark.parametrize('split', [True, False])
624
- def test_simulate_expectation_values(dtype: type[np.complexfloating], split: bool):
630
+ def test_simulate_expectation_values(dtype: type[np.complexfloating], split: bool) -> None:
625
631
  # Compare with test_expectation_from_state_vector_two_qubit_states
626
632
  # in file: cirq/ops/linear_combinations_test.py
627
633
  q0, q1 = cirq.LineQubit.range(2)
@@ -646,7 +652,9 @@ def test_simulate_expectation_values(dtype: type[np.complexfloating], split: boo
646
652
 
647
653
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
648
654
  @pytest.mark.parametrize('split', [True, False])
649
- def test_simulate_expectation_values_terminal_measure(dtype: type[np.complexfloating], split: bool):
655
+ def test_simulate_expectation_values_terminal_measure(
656
+ dtype: type[np.complexfloating], split: bool
657
+ ) -> None:
650
658
  q0 = cirq.LineQubit(0)
651
659
  circuit = cirq.Circuit(cirq.H(q0), cirq.measure(q0))
652
660
  obs = cirq.Z(q0)
@@ -684,7 +692,9 @@ def test_simulate_expectation_values_terminal_measure(dtype: type[np.complexfloa
684
692
 
685
693
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
686
694
  @pytest.mark.parametrize('split', [True, False])
687
- def test_simulate_expectation_values_qubit_order(dtype: type[np.complexfloating], split: bool):
695
+ def test_simulate_expectation_values_qubit_order(
696
+ dtype: type[np.complexfloating], split: bool
697
+ ) -> None:
688
698
  q0, q1, q2 = cirq.LineQubit.range(3)
689
699
  circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1), cirq.X(q2))
690
700
  obs = cirq.X(q0) + cirq.X(q1) - cirq.Z(q2)
@@ -698,7 +708,7 @@ def test_simulate_expectation_values_qubit_order(dtype: type[np.complexfloating]
698
708
  assert cirq.approx_eq(result_flipped[0], 3, atol=1e-6)
699
709
 
700
710
 
701
- def test_invalid_run_no_unitary():
711
+ def test_invalid_run_no_unitary() -> None:
702
712
  class NoUnitary(cirq.testing.SingleQubitGate):
703
713
  pass
704
714
 
@@ -710,7 +720,7 @@ def test_invalid_run_no_unitary():
710
720
  simulator.run(circuit)
711
721
 
712
722
 
713
- def test_allocates_new_state():
723
+ def test_allocates_new_state() -> None:
714
724
  class NoUnitary(cirq.testing.SingleQubitGate):
715
725
  def _has_unitary_(self):
716
726
  return True
@@ -728,7 +738,7 @@ def test_allocates_new_state():
728
738
  assert not initial_state is result.state_vector()
729
739
 
730
740
 
731
- def test_does_not_modify_initial_state():
741
+ def test_does_not_modify_initial_state() -> None:
732
742
  q0 = cirq.LineQubit(0)
733
743
  simulator = cirq.Simulator()
734
744
 
@@ -753,7 +763,7 @@ def test_does_not_modify_initial_state():
753
763
  )
754
764
 
755
765
 
756
- def test_simulator_step_state_mixin():
766
+ def test_simulator_step_state_mixin() -> None:
757
767
  qubits = cirq.LineQubit.range(2)
758
768
  args = cirq.StateVectorSimulationState(
759
769
  available_buffer=np.array([0, 1, 0, 0]).reshape((2, 2)),
@@ -771,7 +781,7 @@ def test_simulator_step_state_mixin():
771
781
  assert result.dirac_notation() == '|01⟩'
772
782
 
773
783
 
774
- def test_sparse_simulator_repr():
784
+ def test_sparse_simulator_repr() -> None:
775
785
  qubits = cirq.LineQubit.range(2)
776
786
  args = cirq.StateVectorSimulationState(
777
787
  available_buffer=np.array([0, 1, 0, 0]).reshape((2, 2)),
@@ -795,7 +805,7 @@ class MultiHTestGate(cirq.testing.TwoQubitGate):
795
805
  return cirq.H.on_each(*qubits)
796
806
 
797
807
 
798
- def test_simulates_composite():
808
+ def test_simulates_composite() -> None:
799
809
  c = cirq.Circuit(MultiHTestGate().on(*cirq.LineQubit.range(2)))
800
810
  expected = np.array([0.5] * 4)
801
811
  np.testing.assert_allclose(
@@ -804,7 +814,7 @@ def test_simulates_composite():
804
814
  np.testing.assert_allclose(cirq.Simulator().simulate(c).state_vector(), expected)
805
815
 
806
816
 
807
- def test_simulate_measurement_inversions():
817
+ def test_simulate_measurement_inversions() -> None:
808
818
  q = cirq.NamedQubit('q')
809
819
 
810
820
  c = cirq.Circuit(cirq.measure(q, key='q', invert_mask=(True,)))
@@ -814,7 +824,7 @@ def test_simulate_measurement_inversions():
814
824
  assert cirq.Simulator().simulate(c).measurements == {'q': np.array([False])}
815
825
 
816
826
 
817
- def test_works_on_pauli_string_phasor():
827
+ def test_works_on_pauli_string_phasor() -> None:
818
828
  a, b = cirq.LineQubit.range(2)
819
829
  c = cirq.Circuit(np.exp(0.5j * np.pi * cirq.X(a) * cirq.X(b)))
820
830
  sim = cirq.Simulator()
@@ -822,7 +832,7 @@ def test_works_on_pauli_string_phasor():
822
832
  np.testing.assert_allclose(result.reshape(4), np.array([0, 0, 0, 1j]), atol=1e-8)
823
833
 
824
834
 
825
- def test_works_on_pauli_string():
835
+ def test_works_on_pauli_string() -> None:
826
836
  a, b = cirq.LineQubit.range(2)
827
837
  c = cirq.Circuit(cirq.X(a) * cirq.X(b))
828
838
  sim = cirq.Simulator()
@@ -830,7 +840,7 @@ def test_works_on_pauli_string():
830
840
  np.testing.assert_allclose(result.reshape(4), np.array([0, 0, 0, 1]), atol=1e-8)
831
841
 
832
842
 
833
- def test_measure_at_end_invert_mask():
843
+ def test_measure_at_end_invert_mask() -> None:
834
844
  simulator = cirq.Simulator()
835
845
  a = cirq.NamedQubit('a')
836
846
  circuit = cirq.Circuit(cirq.measure(a, key='a', invert_mask=(True,)))
@@ -838,7 +848,7 @@ def test_measure_at_end_invert_mask():
838
848
  np.testing.assert_equal(result.measurements['a'], np.array([[1]] * 4))
839
849
 
840
850
 
841
- def test_measure_at_end_invert_mask_multiple_qubits():
851
+ def test_measure_at_end_invert_mask_multiple_qubits() -> None:
842
852
  simulator = cirq.Simulator()
843
853
  a, b, c = cirq.LineQubit.range(3)
844
854
  circuit = cirq.Circuit(
@@ -850,7 +860,7 @@ def test_measure_at_end_invert_mask_multiple_qubits():
850
860
  np.testing.assert_equal(result.measurements['bc'], np.array([[0, 1]] * 4))
851
861
 
852
862
 
853
- def test_measure_at_end_invert_mask_partial():
863
+ def test_measure_at_end_invert_mask_partial() -> None:
854
864
  simulator = cirq.Simulator()
855
865
  a, _, c = cirq.LineQubit.range(3)
856
866
  circuit = cirq.Circuit(cirq.measure(a, c, key='ac', invert_mask=(True,)))
@@ -858,7 +868,7 @@ def test_measure_at_end_invert_mask_partial():
858
868
  np.testing.assert_equal(result.measurements['ac'], np.array([[1, 0]] * 4))
859
869
 
860
870
 
861
- def test_qudit_invert_mask():
871
+ def test_qudit_invert_mask() -> None:
862
872
  q0, q1, q2, q3, q4 = cirq.LineQid.for_qid_shape((2, 3, 3, 3, 4))
863
873
  c = cirq.Circuit(
864
874
  cirq.XPowGate(dimension=2)(q0),
@@ -870,7 +880,7 @@ def test_qudit_invert_mask():
870
880
  assert np.all(cirq.Simulator().run(c).measurements['a'] == [[0, 1, 0, 2, 3]])
871
881
 
872
882
 
873
- def test_compute_amplitudes():
883
+ def test_compute_amplitudes() -> None:
874
884
  a, b = cirq.LineQubit.range(2)
875
885
  c = cirq.Circuit(cirq.X(a), cirq.H(a), cirq.H(b))
876
886
  sim = cirq.Simulator()
@@ -885,16 +895,16 @@ def test_compute_amplitudes():
885
895
  np.testing.assert_allclose(np.array(result), np.array([-0.5, 0.5, -0.5]))
886
896
 
887
897
 
888
- def test_compute_amplitudes_bad_input():
898
+ def test_compute_amplitudes_bad_input() -> None:
889
899
  a, b = cirq.LineQubit.range(2)
890
900
  c = cirq.Circuit(cirq.X(a), cirq.H(a), cirq.H(b))
891
901
  sim = cirq.Simulator()
892
902
 
893
903
  with pytest.raises(ValueError, match='1-dimensional'):
894
- _ = sim.compute_amplitudes(c, np.array([[0, 0]]))
904
+ _ = sim.compute_amplitudes(c, np.array([[0, 0]])) # type: ignore[arg-type]
895
905
 
896
906
 
897
- def test_sample_from_amplitudes():
907
+ def test_sample_from_amplitudes() -> None:
898
908
  q0, q1 = cirq.LineQubit.range(2)
899
909
  circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1), cirq.X(q1))
900
910
  sim = cirq.Simulator(seed=1)
@@ -905,7 +915,7 @@ def test_sample_from_amplitudes():
905
915
  assert 3 not in result
906
916
 
907
917
 
908
- def test_sample_from_amplitudes_teleport():
918
+ def test_sample_from_amplitudes_teleport() -> None:
909
919
  q0, q1, q2 = cirq.LineQubit.range(3)
910
920
  # Initialize q0 to some state, teleport it to q2, then clean up.
911
921
  circuit = cirq.Circuit(
@@ -936,7 +946,7 @@ def test_sample_from_amplitudes_teleport():
936
946
  assert result_c[1] < 20
937
947
 
938
948
 
939
- def test_sample_from_amplitudes_nonunitary_fails():
949
+ def test_sample_from_amplitudes_nonunitary_fails() -> None:
940
950
  q0, q1 = cirq.LineQubit.range(2)
941
951
  sim = cirq.Simulator(seed=1)
942
952
 
@@ -951,7 +961,7 @@ def test_sample_from_amplitudes_nonunitary_fails():
951
961
  _ = sim.sample_from_amplitudes(circuit2, {}, sim._prng)
952
962
 
953
963
 
954
- def test_run_sweep_parameters_not_resolved():
964
+ def test_run_sweep_parameters_not_resolved() -> None:
955
965
  a = cirq.LineQubit(0)
956
966
  simulator = cirq.Simulator()
957
967
  circuit = cirq.Circuit(cirq.XPowGate(exponent=sympy.Symbol('a'))(a), cirq.measure(a))
@@ -959,7 +969,7 @@ def test_run_sweep_parameters_not_resolved():
959
969
  _ = simulator.run_sweep(circuit, cirq.ParamResolver({}))
960
970
 
961
971
 
962
- def test_simulate_sweep_parameters_not_resolved():
972
+ def test_simulate_sweep_parameters_not_resolved() -> None:
963
973
  a = cirq.LineQubit(0)
964
974
  simulator = cirq.Simulator()
965
975
  circuit = cirq.Circuit(cirq.XPowGate(exponent=sympy.Symbol('a'))(a), cirq.measure(a))
@@ -967,7 +977,7 @@ def test_simulate_sweep_parameters_not_resolved():
967
977
  _ = simulator.simulate_sweep(circuit, cirq.ParamResolver({}))
968
978
 
969
979
 
970
- def test_random_seed():
980
+ def test_random_seed() -> None:
971
981
  a = cirq.NamedQubit('a')
972
982
  circuit = cirq.Circuit(cirq.X(a) ** 0.5, cirq.measure(a))
973
983
 
@@ -986,7 +996,7 @@ def test_random_seed():
986
996
  )
987
997
 
988
998
 
989
- def test_random_seed_does_not_modify_global_state_terminal_measurements():
999
+ def test_random_seed_does_not_modify_global_state_terminal_measurements() -> None:
990
1000
  a = cirq.NamedQubit('a')
991
1001
  circuit = cirq.Circuit(cirq.X(a) ** 0.5, cirq.measure(a))
992
1002
 
@@ -1001,7 +1011,7 @@ def test_random_seed_does_not_modify_global_state_terminal_measurements():
1001
1011
  assert result1 == result2
1002
1012
 
1003
1013
 
1004
- def test_random_seed_does_not_modify_global_state_non_terminal_measurements():
1014
+ def test_random_seed_does_not_modify_global_state_non_terminal_measurements() -> None:
1005
1015
  a = cirq.NamedQubit('a')
1006
1016
  circuit = cirq.Circuit(
1007
1017
  cirq.X(a) ** 0.5, cirq.measure(a, key='a0'), cirq.X(a) ** 0.5, cirq.measure(a, key='a1')
@@ -1018,7 +1028,7 @@ def test_random_seed_does_not_modify_global_state_non_terminal_measurements():
1018
1028
  assert result1 == result2
1019
1029
 
1020
1030
 
1021
- def test_random_seed_does_not_modify_global_state_mixture():
1031
+ def test_random_seed_does_not_modify_global_state_mixture() -> None:
1022
1032
  a = cirq.NamedQubit('a')
1023
1033
  circuit = cirq.Circuit(cirq.depolarize(0.5).on(a), cirq.measure(a))
1024
1034
 
@@ -1033,7 +1043,7 @@ def test_random_seed_does_not_modify_global_state_mixture():
1033
1043
  assert result1 == result2
1034
1044
 
1035
1045
 
1036
- def test_random_seed_terminal_measurements_deterministic():
1046
+ def test_random_seed_terminal_measurements_deterministic() -> None:
1037
1047
  a = cirq.NamedQubit('a')
1038
1048
  circuit = cirq.Circuit(cirq.X(a) ** 0.5, cirq.measure(a, key='a'))
1039
1049
  sim = cirq.Simulator(seed=1234)
@@ -1111,7 +1121,7 @@ def test_random_seed_terminal_measurements_deterministic():
1111
1121
  )
1112
1122
 
1113
1123
 
1114
- def test_random_seed_non_terminal_measurements_deterministic():
1124
+ def test_random_seed_non_terminal_measurements_deterministic() -> None:
1115
1125
  a = cirq.NamedQubit('a')
1116
1126
  circuit = cirq.Circuit(
1117
1127
  cirq.X(a) ** 0.5, cirq.measure(a, key='a'), cirq.X(a) ** 0.5, cirq.measure(a, key='b')
@@ -1190,7 +1200,7 @@ def test_random_seed_non_terminal_measurements_deterministic():
1190
1200
  )
1191
1201
 
1192
1202
 
1193
- def test_random_seed_mixture_deterministic():
1203
+ def test_random_seed_mixture_deterministic() -> None:
1194
1204
  a = cirq.NamedQubit('a')
1195
1205
  circuit = cirq.Circuit(
1196
1206
  cirq.depolarize(0.9).on(a),
@@ -1239,7 +1249,7 @@ def test_random_seed_mixture_deterministic():
1239
1249
  )
1240
1250
 
1241
1251
 
1242
- def test_entangled_reset_does_not_break_randomness():
1252
+ def test_entangled_reset_does_not_break_randomness() -> None:
1243
1253
  """Test for bad assumptions on caching the wave function on general channels.
1244
1254
 
1245
1255
  A previous version of cirq made the mistake of assuming that it was okay to
@@ -1258,7 +1268,7 @@ def test_entangled_reset_does_not_break_randomness():
1258
1268
  assert 10 <= counts[1] <= 90
1259
1269
 
1260
1270
 
1261
- def test_overlapping_measurements_at_end():
1271
+ def test_overlapping_measurements_at_end() -> None:
1262
1272
  a, b = cirq.LineQubit.range(2)
1263
1273
  circuit = cirq.Circuit(
1264
1274
  cirq.H(a),
@@ -1282,7 +1292,7 @@ def test_overlapping_measurements_at_end():
1282
1292
  assert 10 <= counts[1] <= 90
1283
1293
 
1284
1294
 
1285
- def test_separated_measurements():
1295
+ def test_separated_measurements() -> None:
1286
1296
  a, b = cirq.LineQubit.range(2)
1287
1297
  c = cirq.Circuit(
1288
1298
  [
@@ -1299,7 +1309,7 @@ def test_separated_measurements():
1299
1309
  np.testing.assert_array_equal(sample['zero'].values, [0] * 10)
1300
1310
 
1301
1311
 
1302
- def test_state_vector_copy():
1312
+ def test_state_vector_copy() -> None:
1303
1313
  sim = cirq.Simulator(split_untangled_states=False)
1304
1314
 
1305
1315
  class InplaceGate(cirq.testing.SingleQubitGate):
@@ -1329,7 +1339,7 @@ def test_state_vector_copy():
1329
1339
  assert any(not np.array_equal(x, y) for x, y in zip(vectors, copy_of_vectors))
1330
1340
 
1331
1341
 
1332
- def test_final_state_vector_is_not_last_object():
1342
+ def test_final_state_vector_is_not_last_object() -> None:
1333
1343
  sim = cirq.Simulator()
1334
1344
 
1335
1345
  q = cirq.LineQubit(0)
@@ -1341,7 +1351,7 @@ def test_final_state_vector_is_not_last_object():
1341
1351
  np.testing.assert_equal(result.state_vector(), initial_state)
1342
1352
 
1343
1353
 
1344
- def test_deterministic_gate_noise():
1354
+ def test_deterministic_gate_noise() -> None:
1345
1355
  q = cirq.LineQubit(0)
1346
1356
  circuit = cirq.Circuit(cirq.I(q), cirq.measure(q))
1347
1357
 
@@ -1359,7 +1369,7 @@ def test_deterministic_gate_noise():
1359
1369
  assert result1 != result3
1360
1370
 
1361
1371
 
1362
- def test_nondeterministic_mixture_noise():
1372
+ def test_nondeterministic_mixture_noise() -> None:
1363
1373
  q = cirq.LineQubit(0)
1364
1374
  circuit = cirq.Circuit(cirq.I(q), cirq.measure(q))
1365
1375
 
@@ -1370,12 +1380,12 @@ def test_nondeterministic_mixture_noise():
1370
1380
  assert result1 != result2
1371
1381
 
1372
1382
 
1373
- def test_pure_state_creation():
1383
+ def test_pure_state_creation() -> None:
1374
1384
  sim = cirq.Simulator()
1375
1385
  qids = cirq.LineQubit.range(3)
1376
1386
  shape = cirq.qid_shape(qids)
1377
1387
  args = sim._create_simulation_state(1, qids)
1378
- values = list(args.values())
1388
+ values = list(args.values()) # type: ignore[attr-defined]
1379
1389
  arg = (
1380
1390
  values[0]
1381
1391
  .kronecker_product(values[1])
@@ -1386,7 +1396,7 @@ def test_pure_state_creation():
1386
1396
  np.testing.assert_allclose(arg.target_tensor, expected.reshape(shape))
1387
1397
 
1388
1398
 
1389
- def test_noise_model():
1399
+ def test_noise_model() -> None:
1390
1400
  q = cirq.LineQubit(0)
1391
1401
  circuit = cirq.Circuit(cirq.H(q), cirq.measure(q))
1392
1402
 
@@ -1397,7 +1407,7 @@ def test_noise_model():
1397
1407
  assert 20 <= sum(result.measurements['q(0)'])[0] < 80
1398
1408
 
1399
1409
 
1400
- def test_separated_states_str_does_not_merge():
1410
+ def test_separated_states_str_does_not_merge() -> None:
1401
1411
  q0, q1 = cirq.LineQubit.range(2)
1402
1412
  circuit = cirq.Circuit(
1403
1413
  cirq.measure(q0), cirq.measure(q1), cirq.H(q0), cirq.global_phase_operation(0 + 1j)
@@ -1419,7 +1429,7 @@ output vector: 1j|⟩"""
1419
1429
  )
1420
1430
 
1421
1431
 
1422
- def test_separable_non_dirac_str():
1432
+ def test_separable_non_dirac_str() -> None:
1423
1433
  circuit = cirq.Circuit()
1424
1434
  for i in range(4):
1425
1435
  circuit.append(cirq.H(cirq.LineQubit(i)))
@@ -1429,7 +1439,7 @@ def test_separable_non_dirac_str():
1429
1439
  assert '+0.j' in str(result)
1430
1440
 
1431
1441
 
1432
- def test_unseparated_states_str():
1442
+ def test_unseparated_states_str() -> None:
1433
1443
  q0, q1 = cirq.LineQubit.range(2)
1434
1444
  circuit = cirq.Circuit(
1435
1445
  cirq.measure(q0), cirq.measure(q1), cirq.H(q0), cirq.global_phase_operation(0 + 1j)
@@ -1446,7 +1456,7 @@ output vector: 0.707j|00⟩ + 0.707j|10⟩"""
1446
1456
 
1447
1457
 
1448
1458
  @pytest.mark.parametrize('split', [True, False])
1449
- def test_measurement_preserves_phase(split: bool):
1459
+ def test_measurement_preserves_phase(split: bool) -> None:
1450
1460
  c1, c2, t = cirq.LineQubit.range(3)
1451
1461
  circuit = cirq.Circuit(
1452
1462
  cirq.H(t),