cirq-core 1.6.0.dev20250520234959__py3-none-any.whl → 1.6.0.dev20250521215048__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 (73) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit_operation_test.py +1 -2
  4. cirq/contrib/acquaintance/devices.py +2 -2
  5. cirq/contrib/acquaintance/inspection_utils.py +2 -2
  6. cirq/contrib/qasm_import/_lexer.py +1 -2
  7. cirq/contrib/routing/router.py +3 -3
  8. cirq/devices/device.py +4 -4
  9. cirq/experiments/fidelity_estimation.py +4 -4
  10. cirq/experiments/t1_decay_experiment.py +2 -2
  11. cirq/experiments/xeb_fitting.py +1 -1
  12. cirq/interop/quirk/cells/measurement_cells.py +2 -2
  13. cirq/linalg/combinators.py +3 -3
  14. cirq/linalg/predicates.py +2 -2
  15. cirq/linalg/tolerance.py +2 -2
  16. cirq/ops/arithmetic_operation_test.py +2 -4
  17. cirq/ops/common_gate_families.py +7 -7
  18. cirq/ops/controlled_gate.py +11 -0
  19. cirq/ops/controlled_gate_test.py +36 -2
  20. cirq/ops/controlled_operation_test.py +2 -2
  21. cirq/ops/linear_combinations_test.py +8 -9
  22. cirq/ops/qid_util.py +2 -2
  23. cirq/ops/qubit_order_or_list.py +2 -2
  24. cirq/protocols/act_on_protocol.py +4 -4
  25. cirq/protocols/commutes_protocol.py +5 -7
  26. cirq/protocols/control_key_protocol.py +4 -4
  27. cirq/protocols/decompose_protocol_test.py +1 -2
  28. cirq/protocols/has_stabilizer_effect_protocol.py +5 -5
  29. cirq/protocols/has_unitary_protocol.py +5 -5
  30. cirq/protocols/pauli_expansion_protocol.py +3 -3
  31. cirq/protocols/pow_protocol.py +5 -5
  32. cirq/protocols/trace_distance_bound.py +4 -4
  33. cirq/protocols/unitary_protocol.py +7 -7
  34. cirq/protocols/unitary_protocol_test.py +1 -3
  35. cirq/qis/entropy.py +2 -2
  36. cirq/sim/clifford/clifford_tableau_simulation_state.py +4 -4
  37. cirq/sim/clifford/stabilizer_ch_form_simulation_state.py +5 -5
  38. cirq/sim/clifford/stabilizer_simulation_state.py +5 -5
  39. cirq/sim/density_matrix_simulator_test.py +45 -46
  40. cirq/sim/sparse_simulator_test.py +38 -39
  41. cirq/sim/state_vector_simulation_state_test.py +2 -2
  42. cirq/sim/state_vector_test.py +3 -3
  43. cirq/study/sweepable.py +5 -5
  44. cirq/testing/consistent_act_on.py +5 -7
  45. cirq/testing/consistent_controlled_gate_op.py +3 -5
  46. cirq/testing/deprecation.py +2 -2
  47. cirq/testing/lin_alg_utils.py +2 -2
  48. cirq/transformers/align.py +3 -3
  49. cirq/transformers/drop_empty_moments.py +2 -2
  50. cirq/transformers/drop_negligible_operations.py +2 -2
  51. cirq/transformers/expand_composite.py +2 -2
  52. cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +3 -3
  53. cirq/transformers/merge_k_qubit_gates.py +5 -5
  54. cirq/transformers/merge_single_qubit_gates.py +5 -5
  55. cirq/transformers/optimize_for_target_gateset.py +6 -6
  56. cirq/transformers/optimize_for_target_gateset_test.py +3 -3
  57. cirq/transformers/tag_transformers.py +5 -5
  58. cirq/transformers/target_gatesets/cz_gateset_test.py +2 -2
  59. cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +1 -3
  60. cirq/transformers/transformer_api_test.py +7 -8
  61. cirq/value/abc_alt.py +2 -2
  62. cirq/value/abc_alt_test.py +3 -3
  63. cirq/value/angle.py +7 -7
  64. cirq/value/type_alias.py +3 -5
  65. cirq/vis/density_matrix.py +2 -4
  66. cirq/vis/histogram.py +6 -6
  67. cirq/vis/state_histogram.py +7 -7
  68. cirq/work/observable_readout_calibration.py +2 -2
  69. {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/METADATA +1 -1
  70. {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/RECORD +73 -73
  71. {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/WHEEL +0 -0
  72. {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/licenses/LICENSE +0 -0
  73. {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/top_level.txt +0 -0
@@ -16,7 +16,6 @@ from __future__ import annotations
16
16
 
17
17
  import itertools
18
18
  import random
19
- from typing import Type, Union
20
19
  from unittest import mock
21
20
 
22
21
  import numpy as np
@@ -56,7 +55,7 @@ def test_invalid_dtype():
56
55
 
57
56
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
58
57
  @pytest.mark.parametrize('split', [True, False])
59
- def test_run_no_measurements(dtype: Type[np.complexfloating], split: bool):
58
+ def test_run_no_measurements(dtype: type[np.complexfloating], split: bool):
60
59
  q0, q1 = cirq.LineQubit.range(2)
61
60
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
62
61
 
@@ -67,7 +66,7 @@ def test_run_no_measurements(dtype: Type[np.complexfloating], split: bool):
67
66
 
68
67
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
69
68
  @pytest.mark.parametrize('split', [True, False])
70
- def test_run_no_results(dtype: Type[np.complexfloating], split: bool):
69
+ def test_run_no_results(dtype: type[np.complexfloating], split: bool):
71
70
  q0, q1 = cirq.LineQubit.range(2)
72
71
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
73
72
 
@@ -78,7 +77,7 @@ def test_run_no_results(dtype: Type[np.complexfloating], split: bool):
78
77
 
79
78
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
80
79
  @pytest.mark.parametrize('split', [True, False])
81
- def test_run_empty_circuit(dtype: Type[np.complexfloating], split: bool):
80
+ def test_run_empty_circuit(dtype: type[np.complexfloating], split: bool):
82
81
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
83
82
  with pytest.raises(ValueError, match="no measurements"):
84
83
  simulator.run(cirq.Circuit())
@@ -86,7 +85,7 @@ def test_run_empty_circuit(dtype: Type[np.complexfloating], split: bool):
86
85
 
87
86
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
88
87
  @pytest.mark.parametrize('split', [True, False])
89
- def test_run_bit_flips(dtype: Type[np.complexfloating], split: bool):
88
+ def test_run_bit_flips(dtype: type[np.complexfloating], split: bool):
90
89
  q0, q1 = cirq.LineQubit.range(2)
91
90
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
92
91
  for b0 in [0, 1]:
@@ -100,7 +99,7 @@ def test_run_bit_flips(dtype: Type[np.complexfloating], split: bool):
100
99
 
101
100
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
102
101
  @pytest.mark.parametrize('split', [True, False])
103
- def test_run_bit_flips_with_dephasing(dtype: Type[np.complexfloating], split: bool):
102
+ def test_run_bit_flips_with_dephasing(dtype: type[np.complexfloating], split: bool):
104
103
  q0, q1 = cirq.LineQubit.range(2)
105
104
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
106
105
  for b0 in [0, 1]:
@@ -114,7 +113,7 @@ def test_run_bit_flips_with_dephasing(dtype: Type[np.complexfloating], split: bo
114
113
 
115
114
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
116
115
  @pytest.mark.parametrize('split', [True, False])
117
- def test_run_qudit_increments(dtype: Type[np.complexfloating], split: bool):
116
+ def test_run_qudit_increments(dtype: type[np.complexfloating], split: bool):
118
117
  q0, q1 = cirq.LineQid.for_qid_shape((3, 4))
119
118
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
120
119
  for b0 in [0, 1, 2]:
@@ -133,7 +132,7 @@ def test_run_qudit_increments(dtype: Type[np.complexfloating], split: bool):
133
132
 
134
133
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
135
134
  @pytest.mark.parametrize('split', [True, False])
136
- def test_run_not_channel_op(dtype: Type[np.complexfloating], split: bool):
135
+ def test_run_not_channel_op(dtype: type[np.complexfloating], split: bool):
137
136
  class BadOp(cirq.Operation):
138
137
  def __init__(self, qubits):
139
138
  self._qubits = qubits
@@ -154,7 +153,7 @@ def test_run_not_channel_op(dtype: Type[np.complexfloating], split: bool):
154
153
 
155
154
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
156
155
  @pytest.mark.parametrize('split', [True, False])
157
- def test_run_mixture(dtype: Type[np.complexfloating], split: bool):
156
+ def test_run_mixture(dtype: type[np.complexfloating], split: bool):
158
157
  q0, q1 = cirq.LineQubit.range(2)
159
158
  circuit = cirq.Circuit(cirq.bit_flip(0.5)(q0), cirq.measure(q0), cirq.measure(q1))
160
159
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -168,7 +167,7 @@ def test_run_mixture(dtype: Type[np.complexfloating], split: bool):
168
167
 
169
168
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
170
169
  @pytest.mark.parametrize('split', [True, False])
171
- def test_run_qudit_mixture(dtype: Type[np.complexfloating], split: bool):
170
+ def test_run_qudit_mixture(dtype: type[np.complexfloating], split: bool):
172
171
  q0, q1 = cirq.LineQid.for_qid_shape((3, 2))
173
172
  mixture = _TestMixture(
174
173
  [
@@ -189,7 +188,7 @@ def test_run_qudit_mixture(dtype: Type[np.complexfloating], split: bool):
189
188
 
190
189
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
191
190
  @pytest.mark.parametrize('split', [True, False])
192
- def test_run_channel(dtype: Type[np.complexfloating], split: bool):
191
+ def test_run_channel(dtype: type[np.complexfloating], split: bool):
193
192
  q0, q1 = cirq.LineQubit.range(2)
194
193
  circuit = cirq.Circuit(
195
194
  cirq.X(q0), cirq.amplitude_damp(0.5)(q0), cirq.measure(q0), cirq.measure(q1)
@@ -206,7 +205,7 @@ def test_run_channel(dtype: Type[np.complexfloating], split: bool):
206
205
 
207
206
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
208
207
  @pytest.mark.parametrize('split', [True, False])
209
- def test_run_decomposable_channel(dtype: Type[np.complexfloating], split: bool):
208
+ def test_run_decomposable_channel(dtype: type[np.complexfloating], split: bool):
210
209
  q0, q1 = cirq.LineQubit.range(2)
211
210
 
212
211
  circuit = cirq.Circuit(
@@ -227,7 +226,7 @@ def test_run_decomposable_channel(dtype: Type[np.complexfloating], split: bool):
227
226
 
228
227
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
229
228
  @pytest.mark.parametrize('split', [True, False])
230
- def test_run_qudit_channel(dtype: Type[np.complexfloating], split: bool):
229
+ def test_run_qudit_channel(dtype: type[np.complexfloating], split: bool):
231
230
  class TestChannel(cirq.Gate):
232
231
  def _qid_shape_(self):
233
232
  return (3,)
@@ -259,7 +258,7 @@ def test_run_qudit_channel(dtype: Type[np.complexfloating], split: bool):
259
258
 
260
259
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
261
260
  @pytest.mark.parametrize('split', [True, False])
262
- def test_run_measure_at_end_no_repetitions(dtype: Type[np.complexfloating], split: bool):
261
+ def test_run_measure_at_end_no_repetitions(dtype: type[np.complexfloating], split: bool):
263
262
  q0, q1 = cirq.LineQubit.range(2)
264
263
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
265
264
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -278,7 +277,7 @@ def test_run_measure_at_end_no_repetitions(dtype: Type[np.complexfloating], spli
278
277
 
279
278
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
280
279
  @pytest.mark.parametrize('split', [True, False])
281
- def test_run_repetitions_measure_at_end(dtype: Type[np.complexfloating], split: bool):
280
+ def test_run_repetitions_measure_at_end(dtype: type[np.complexfloating], split: bool):
282
281
  q0, q1 = cirq.LineQubit.range(2)
283
282
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
284
283
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -297,7 +296,7 @@ def test_run_repetitions_measure_at_end(dtype: Type[np.complexfloating], split:
297
296
 
298
297
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
299
298
  @pytest.mark.parametrize('split', [True, False])
300
- def test_run_qudits_repetitions_measure_at_end(dtype: Type[np.complexfloating], split: bool):
299
+ def test_run_qudits_repetitions_measure_at_end(dtype: type[np.complexfloating], split: bool):
301
300
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
302
301
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
303
302
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -319,7 +318,7 @@ def test_run_qudits_repetitions_measure_at_end(dtype: Type[np.complexfloating],
319
318
 
320
319
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
321
320
  @pytest.mark.parametrize('split', [True, False])
322
- def test_run_measurement_not_terminal_no_repetitions(dtype: Type[np.complexfloating], split: bool):
321
+ def test_run_measurement_not_terminal_no_repetitions(dtype: type[np.complexfloating], split: bool):
323
322
  q0, q1 = cirq.LineQubit.range(2)
324
323
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
325
324
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -343,7 +342,7 @@ def test_run_measurement_not_terminal_no_repetitions(dtype: Type[np.complexfloat
343
342
 
344
343
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
345
344
  @pytest.mark.parametrize('split', [True, False])
346
- def test_run_repetitions_measurement_not_terminal(dtype: Type[np.complexfloating], split: bool):
345
+ def test_run_repetitions_measurement_not_terminal(dtype: type[np.complexfloating], split: bool):
347
346
  q0, q1 = cirq.LineQubit.range(2)
348
347
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
349
348
  with mock.patch.object(simulator, '_core_iterator', wraps=simulator._core_iterator) as mock_sim:
@@ -368,7 +367,7 @@ def test_run_repetitions_measurement_not_terminal(dtype: Type[np.complexfloating
368
367
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
369
368
  @pytest.mark.parametrize('split', [True, False])
370
369
  def test_run_qudits_repetitions_measurement_not_terminal(
371
- dtype: Type[np.complexfloating], split: bool
370
+ dtype: type[np.complexfloating], split: bool
372
371
  ):
373
372
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
374
373
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -393,7 +392,7 @@ def test_run_qudits_repetitions_measurement_not_terminal(
393
392
 
394
393
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
395
394
  @pytest.mark.parametrize('split', [True, False])
396
- def test_run_param_resolver(dtype: Type[np.complexfloating], split: bool):
395
+ def test_run_param_resolver(dtype: type[np.complexfloating], split: bool):
397
396
  q0, q1 = cirq.LineQubit.range(2)
398
397
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
399
398
  for b0 in [0, 1]:
@@ -413,7 +412,7 @@ def test_run_param_resolver(dtype: Type[np.complexfloating], split: bool):
413
412
 
414
413
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
415
414
  @pytest.mark.parametrize('split', [True, False])
416
- def test_run_correlations(dtype: Type[np.complexfloating], split: bool):
415
+ def test_run_correlations(dtype: type[np.complexfloating], split: bool):
417
416
  q0, q1 = cirq.LineQubit.range(2)
418
417
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
419
418
  circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1), cirq.measure(q0, q1))
@@ -425,7 +424,7 @@ def test_run_correlations(dtype: Type[np.complexfloating], split: bool):
425
424
 
426
425
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
427
426
  @pytest.mark.parametrize('split', [True, False])
428
- def test_run_measure_multiple_qubits(dtype: Type[np.complexfloating], split: bool):
427
+ def test_run_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool):
429
428
  q0, q1 = cirq.LineQubit.range(2)
430
429
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
431
430
  for b0 in [0, 1]:
@@ -437,7 +436,7 @@ def test_run_measure_multiple_qubits(dtype: Type[np.complexfloating], split: boo
437
436
 
438
437
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
439
438
  @pytest.mark.parametrize('split', [True, False])
440
- def test_run_measure_multiple_qudits(dtype: Type[np.complexfloating], split: bool):
439
+ def test_run_measure_multiple_qudits(dtype: type[np.complexfloating], split: bool):
441
440
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
442
441
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
443
442
  for b0 in [0, 1]:
@@ -451,7 +450,7 @@ def test_run_measure_multiple_qudits(dtype: Type[np.complexfloating], split: boo
451
450
 
452
451
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
453
452
  @pytest.mark.parametrize('split', [True, False])
454
- def test_run_sweeps_param_resolvers(dtype: Type[np.complexfloating], split: bool):
453
+ def test_run_sweeps_param_resolvers(dtype: type[np.complexfloating], split: bool):
455
454
  q0, q1 = cirq.LineQubit.range(2)
456
455
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
457
456
  for b0 in [0, 1]:
@@ -477,7 +476,7 @@ def test_run_sweeps_param_resolvers(dtype: Type[np.complexfloating], split: bool
477
476
 
478
477
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
479
478
  @pytest.mark.parametrize('split', [True, False])
480
- def test_simulate_no_circuit(dtype: Type[np.complexfloating], split: bool):
479
+ def test_simulate_no_circuit(dtype: type[np.complexfloating], split: bool):
481
480
  q0, q1 = cirq.LineQubit.range(2)
482
481
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
483
482
  circuit = cirq.Circuit()
@@ -490,7 +489,7 @@ def test_simulate_no_circuit(dtype: Type[np.complexfloating], split: bool):
490
489
 
491
490
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
492
491
  @pytest.mark.parametrize('split', [True, False])
493
- def test_simulate(dtype: Type[np.complexfloating], split: bool):
492
+ def test_simulate(dtype: type[np.complexfloating], split: bool):
494
493
  q0, q1 = cirq.LineQubit.range(2)
495
494
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
496
495
  circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1))
@@ -501,7 +500,7 @@ def test_simulate(dtype: Type[np.complexfloating], split: bool):
501
500
 
502
501
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
503
502
  @pytest.mark.parametrize('split', [True, False])
504
- def test_simulate_qudits(dtype: Type[np.complexfloating], split: bool):
503
+ def test_simulate_qudits(dtype: type[np.complexfloating], split: bool):
505
504
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
506
505
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
507
506
  circuit = cirq.Circuit(cirq.H(q0), cirq.XPowGate(dimension=3)(q1) ** 2)
@@ -515,7 +514,7 @@ def test_simulate_qudits(dtype: Type[np.complexfloating], split: bool):
515
514
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
516
515
  @pytest.mark.parametrize('split', [True, False])
517
516
  def test_reset_one_qubit_does_not_affect_partial_trace_of_other_qubits(
518
- dtype: Type[np.complexfloating], split: bool
517
+ dtype: type[np.complexfloating], split: bool
519
518
  ):
520
519
  q0, q1 = cirq.LineQubit.range(2)
521
520
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -534,7 +533,7 @@ def test_reset_one_qubit_does_not_affect_partial_trace_of_other_qubits(
534
533
  [cirq.testing.random_circuit(cirq.LineQubit.range(4), 5, 0.9) for _ in range(20)],
535
534
  ),
536
535
  )
537
- def test_simulate_compare_to_state_vector_simulator(dtype: Type[np.complexfloating], circuit):
536
+ def test_simulate_compare_to_state_vector_simulator(dtype: type[np.complexfloating], circuit):
538
537
  qubits = cirq.LineQubit.range(4)
539
538
  pure_result = (
540
539
  cirq.Simulator(dtype=dtype).simulate(circuit, qubit_order=qubits).density_matrix_of()
@@ -550,7 +549,7 @@ def test_simulate_compare_to_state_vector_simulator(dtype: Type[np.complexfloati
550
549
 
551
550
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
552
551
  @pytest.mark.parametrize('split', [True, False])
553
- def test_simulate_bit_flips(dtype: Type[np.complexfloating], split: bool):
552
+ def test_simulate_bit_flips(dtype: type[np.complexfloating], split: bool):
554
553
  q0, q1 = cirq.LineQubit.range(2)
555
554
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
556
555
  for b0 in [0, 1]:
@@ -567,7 +566,7 @@ def test_simulate_bit_flips(dtype: Type[np.complexfloating], split: bool):
567
566
 
568
567
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
569
568
  @pytest.mark.parametrize('split', [True, False])
570
- def test_simulate_qudit_increments(dtype: Type[np.complexfloating], split: bool):
569
+ def test_simulate_qudit_increments(dtype: type[np.complexfloating], split: bool):
571
570
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
572
571
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
573
572
  for b0 in [0, 1]:
@@ -592,9 +591,9 @@ def test_simulate_qudit_increments(dtype: Type[np.complexfloating], split: bool)
592
591
  [1, cirq.DensityMatrixSimulationState(initial_state=1, qubits=cirq.LineQubit.range(2))],
593
592
  )
594
593
  def test_simulate_initial_state(
595
- dtype: Type[np.complexfloating],
594
+ dtype: type[np.complexfloating],
596
595
  split: bool,
597
- initial_state: Union[int, cirq.DensityMatrixSimulationState],
596
+ initial_state: int | cirq.DensityMatrixSimulationState,
598
597
  ):
599
598
  q0, q1 = cirq.LineQubit.range(2)
600
599
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -609,7 +608,7 @@ def test_simulate_initial_state(
609
608
 
610
609
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
611
610
  @pytest.mark.parametrize('split', [True, False])
612
- def test_simulation_state(dtype: Type[np.complexfloating], split: bool):
611
+ def test_simulation_state(dtype: type[np.complexfloating], split: bool):
613
612
  q0, q1 = cirq.LineQubit.range(2)
614
613
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
615
614
  for b0 in [0, 1]:
@@ -636,7 +635,7 @@ def test_simulate_tps_initial_state():
636
635
 
637
636
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
638
637
  @pytest.mark.parametrize('split', [True, False])
639
- def test_simulate_initial_qudit_state(dtype: Type[np.complexfloating], split: bool):
638
+ def test_simulate_initial_qudit_state(dtype: type[np.complexfloating], split: bool):
640
639
  q0, q1 = cirq.LineQid.for_qid_shape((3, 4))
641
640
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
642
641
  for b0 in [0, 1, 2]:
@@ -656,7 +655,7 @@ def test_simulate_initial_qudit_state(dtype: Type[np.complexfloating], split: bo
656
655
 
657
656
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
658
657
  @pytest.mark.parametrize('split', [True, False])
659
- def test_simulate_qubit_order(dtype: Type[np.complexfloating], split: bool):
658
+ def test_simulate_qubit_order(dtype: type[np.complexfloating], split: bool):
660
659
  q0, q1 = cirq.LineQubit.range(2)
661
660
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
662
661
  for b0 in [0, 1]:
@@ -670,7 +669,7 @@ def test_simulate_qubit_order(dtype: Type[np.complexfloating], split: bool):
670
669
 
671
670
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
672
671
  @pytest.mark.parametrize('split', [True, False])
673
- def test_simulate_param_resolver(dtype: Type[np.complexfloating], split: bool):
672
+ def test_simulate_param_resolver(dtype: type[np.complexfloating], split: bool):
674
673
  q0, q1 = cirq.LineQubit.range(2)
675
674
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
676
675
  for b0 in [0, 1]:
@@ -689,7 +688,7 @@ def test_simulate_param_resolver(dtype: Type[np.complexfloating], split: bool):
689
688
 
690
689
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
691
690
  @pytest.mark.parametrize('split', [True, False])
692
- def test_simulate_measure_multiple_qubits(dtype: Type[np.complexfloating], split: bool):
691
+ def test_simulate_measure_multiple_qubits(dtype: type[np.complexfloating], split: bool):
693
692
  q0, q1 = cirq.LineQubit.range(2)
694
693
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
695
694
  for b0 in [0, 1]:
@@ -701,7 +700,7 @@ def test_simulate_measure_multiple_qubits(dtype: Type[np.complexfloating], split
701
700
 
702
701
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
703
702
  @pytest.mark.parametrize('split', [True, False])
704
- def test_simulate_measure_multiple_qudits(dtype: Type[np.complexfloating], split: bool):
703
+ def test_simulate_measure_multiple_qudits(dtype: type[np.complexfloating], split: bool):
705
704
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
706
705
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
707
706
  for b0 in [0, 1]:
@@ -715,7 +714,7 @@ def test_simulate_measure_multiple_qudits(dtype: Type[np.complexfloating], split
715
714
 
716
715
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
717
716
  @pytest.mark.parametrize('split', [True, False])
718
- def test_simulate_sweeps_param_resolver(dtype: Type[np.complexfloating], split: bool):
717
+ def test_simulate_sweeps_param_resolver(dtype: type[np.complexfloating], split: bool):
719
718
  q0, q1 = cirq.LineQubit.range(2)
720
719
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
721
720
  for b0 in [0, 1]:
@@ -742,7 +741,7 @@ def test_simulate_sweeps_param_resolver(dtype: Type[np.complexfloating], split:
742
741
 
743
742
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
744
743
  @pytest.mark.parametrize('split', [True, False])
745
- def test_simulate_moment_steps(dtype: Type[np.complexfloating], split: bool):
744
+ def test_simulate_moment_steps(dtype: type[np.complexfloating], split: bool):
746
745
  q0, q1 = cirq.LineQubit.range(2)
747
746
  circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1), cirq.H(q0), cirq.H(q1))
748
747
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -756,7 +755,7 @@ def test_simulate_moment_steps(dtype: Type[np.complexfloating], split: bool):
756
755
 
757
756
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
758
757
  @pytest.mark.parametrize('split', [True, False])
759
- def test_simulate_moment_steps_qudits(dtype: Type[np.complexfloating], split: bool):
758
+ def test_simulate_moment_steps_qudits(dtype: type[np.complexfloating], split: bool):
760
759
  q0, q1 = cirq.LineQid.for_qid_shape((2, 3))
761
760
  circuit = cirq.Circuit(
762
761
  cirq.XPowGate(dimension=2)(q0),
@@ -777,7 +776,7 @@ def test_simulate_moment_steps_qudits(dtype: Type[np.complexfloating], split: bo
777
776
 
778
777
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
779
778
  @pytest.mark.parametrize('split', [True, False])
780
- def test_simulate_moment_steps_empty_circuit(dtype: Type[np.complexfloating], split: bool):
779
+ def test_simulate_moment_steps_empty_circuit(dtype: type[np.complexfloating], split: bool):
781
780
  circuit = cirq.Circuit()
782
781
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
783
782
  step = None
@@ -789,7 +788,7 @@ def test_simulate_moment_steps_empty_circuit(dtype: Type[np.complexfloating], sp
789
788
 
790
789
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
791
790
  @pytest.mark.parametrize('split', [True, False])
792
- def test_simulate_moment_steps_sample(dtype: Type[np.complexfloating], split: bool):
791
+ def test_simulate_moment_steps_sample(dtype: type[np.complexfloating], split: bool):
793
792
  q0, q1 = cirq.LineQubit.range(2)
794
793
  circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1))
795
794
  simulator = cirq.DensityMatrixSimulator(dtype=dtype, split_untangled_states=split)
@@ -810,7 +809,7 @@ def test_simulate_moment_steps_sample(dtype: Type[np.complexfloating], split: bo
810
809
 
811
810
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
812
811
  @pytest.mark.parametrize('split', [True, False])
813
- def test_simulate_moment_steps_sample_qudits(dtype: Type[np.complexfloating], split: bool):
812
+ def test_simulate_moment_steps_sample_qudits(dtype: type[np.complexfloating], split: bool):
814
813
  class TestGate(cirq.Gate):
815
814
  """Swaps the 2nd qid |0> and |2> states when the 1st is |1>."""
816
815
 
@@ -840,7 +839,7 @@ def test_simulate_moment_steps_sample_qudits(dtype: Type[np.complexfloating], sp
840
839
  @pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
841
840
  @pytest.mark.parametrize('split', [True, False])
842
841
  def test_simulate_moment_steps_intermediate_measurement(
843
- dtype: Type[np.complexfloating], split: bool
842
+ dtype: type[np.complexfloating], split: bool
844
843
  ):
845
844
  q0 = cirq.LineQubit(0)
846
845
  circuit = cirq.Circuit(cirq.H(q0), cirq.measure(q0), cirq.H(q0))