cirq-core 1.7.0.dev20250819195403__py3-none-any.whl → 1.7.0.dev20250821232720__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 (95) hide show
  1. cirq/_version.py +1 -1
  2. cirq/_version_test.py +1 -1
  3. cirq/circuits/circuit.py +1 -1
  4. cirq/circuits/moment.py +1 -1
  5. cirq/devices/grid_qubit.py +1 -2
  6. cirq/devices/line_qubit.py +1 -3
  7. cirq/experiments/z_phase_calibration_test.py +8 -7
  8. cirq/interop/quirk/cells/arithmetic_cells.py +1 -1
  9. cirq/interop/quirk/cells/cell_test.py +5 -5
  10. cirq/interop/quirk/cells/composite_cell_test.py +5 -3
  11. cirq/interop/quirk/cells/control_cells.py +2 -2
  12. cirq/interop/quirk/cells/input_cells.py +3 -3
  13. cirq/interop/quirk/cells/input_rotation_cells.py +2 -2
  14. cirq/interop/quirk/cells/swap_cell.py +2 -2
  15. cirq/interop/quirk/cells/testing.py +1 -1
  16. cirq/interop/quirk/url_to_circuit.py +2 -2
  17. cirq/interop/quirk/url_to_circuit_test.py +11 -11
  18. cirq/linalg/decompositions.py +1 -1
  19. cirq/linalg/decompositions_test.py +52 -50
  20. cirq/linalg/diagonalize_test.py +2 -2
  21. cirq/linalg/predicates.py +1 -1
  22. cirq/linalg/predicates_test.py +24 -24
  23. cirq/linalg/transformations.py +6 -4
  24. cirq/neutral_atoms/neutral_atom_devices.py +1 -1
  25. cirq/ops/arithmetic_operation.py +1 -2
  26. cirq/ops/classically_controlled_operation.py +2 -2
  27. cirq/ops/clifford_gate.py +1 -1
  28. cirq/ops/common_channels_test.py +1 -1
  29. cirq/ops/common_gates.py +2 -2
  30. cirq/ops/controlled_operation.py +2 -2
  31. cirq/ops/controlled_operation_test.py +17 -16
  32. cirq/ops/dense_pauli_string.py +1 -1
  33. cirq/ops/dense_pauli_string_test.py +41 -37
  34. cirq/ops/eigen_gate_test.py +0 -7
  35. cirq/ops/gate_operation.py +11 -3
  36. cirq/ops/gateset.py +3 -3
  37. cirq/ops/gateset_test.py +23 -23
  38. cirq/ops/linear_combinations.py +1 -1
  39. cirq/ops/linear_combinations_test.py +103 -89
  40. cirq/ops/matrix_gates_test.py +31 -31
  41. cirq/ops/measure_util_test.py +11 -10
  42. cirq/ops/measurement_gate_test.py +23 -22
  43. cirq/ops/parity_gates.py +1 -2
  44. cirq/ops/pauli_gates.py +1 -1
  45. cirq/ops/pauli_measurement_gate_test.py +12 -12
  46. cirq/ops/pauli_string_phasor_test.py +45 -40
  47. cirq/ops/pauli_string_raw_types.py +1 -3
  48. cirq/ops/pauli_string_raw_types_test.py +5 -4
  49. cirq/ops/pauli_string_test.py +190 -118
  50. cirq/ops/permutation_gate.py +1 -1
  51. cirq/ops/raw_types.py +3 -4
  52. cirq/ops/raw_types_test.py +1 -1
  53. cirq/ops/three_qubit_gates.py +3 -3
  54. cirq/protocols/act_on_protocol.py +2 -4
  55. cirq/protocols/act_on_protocol_test.py +5 -6
  56. cirq/protocols/apply_channel_protocol.py +1 -2
  57. cirq/protocols/apply_channel_protocol_test.py +19 -18
  58. cirq/protocols/apply_mixture_protocol.py +1 -2
  59. cirq/protocols/apply_mixture_protocol_test.py +20 -19
  60. cirq/protocols/apply_unitary_protocol.py +1 -2
  61. cirq/protocols/apply_unitary_protocol_test.py +31 -23
  62. cirq/protocols/approximate_equality_protocol.py +1 -2
  63. cirq/protocols/approximate_equality_protocol_test.py +22 -16
  64. cirq/protocols/circuit_diagram_info_protocol.py +4 -5
  65. cirq/protocols/commutes_protocol.py +1 -2
  66. cirq/protocols/commutes_protocol_test.py +4 -4
  67. cirq/protocols/control_key_protocol.py +1 -3
  68. cirq/protocols/decompose_protocol.py +1 -2
  69. cirq/protocols/equal_up_to_global_phase_protocol.py +1 -2
  70. cirq/protocols/has_unitary_protocol.py +1 -2
  71. cirq/protocols/json_serialization.py +1 -2
  72. cirq/protocols/kraus_protocol.py +1 -2
  73. cirq/protocols/measurement_key_protocol.py +1 -3
  74. cirq/protocols/mixture_protocol.py +1 -2
  75. cirq/protocols/pauli_expansion_protocol.py +1 -3
  76. cirq/protocols/phase_protocol.py +1 -3
  77. cirq/protocols/qasm.py +1 -3
  78. cirq/protocols/qid_shape_protocol.py +1 -3
  79. cirq/protocols/resolve_parameters.py +1 -2
  80. cirq/protocols/trace_distance_bound.py +1 -2
  81. cirq/protocols/unitary_protocol.py +1 -2
  82. cirq/qis/quantum_state_representation.py +1 -2
  83. cirq/sim/simulation_state.py +1 -2
  84. cirq/sim/simulation_state_base.py +1 -3
  85. cirq/study/sweepable.py +1 -3
  86. cirq/transformers/transformer_api.py +1 -3
  87. cirq/value/classical_data.py +1 -3
  88. cirq/value/linear_dict.py +1 -1
  89. cirq/value/value_equality_attr.py +1 -3
  90. cirq/work/collector.py +1 -2
  91. {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/METADATA +1 -2
  92. {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/RECORD +95 -95
  93. {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/WHEEL +0 -0
  94. {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/licenses/LICENSE +0 -0
  95. {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/top_level.txt +0 -0
@@ -51,7 +51,7 @@ round_to_2_prec = cirq.CircuitDiagramInfoArgs(
51
51
  )
52
52
 
53
53
 
54
- def assert_mixtures_equal(actual, expected):
54
+ def assert_mixtures_equal(actual, expected) -> None:
55
55
  """Assert equal for tuple of mixed scalar and array types."""
56
56
  for a, e in zip(actual, expected):
57
57
  np.testing.assert_almost_equal(a[0], e[0])
cirq/ops/common_gates.py CHANGED
@@ -274,7 +274,7 @@ class XPowGate(eigen_gate.EigenGate):
274
274
  return args.format('rx({0:half_turns}) {1};\n', self._exponent, qubits[0])
275
275
 
276
276
  @property
277
- def phase_exponent(self):
277
+ def phase_exponent(self) -> float:
278
278
  return 0.0
279
279
 
280
280
  def _phase_by_(self, phase_turns, qubit_index):
@@ -467,7 +467,7 @@ class YPowGate(eigen_gate.EigenGate):
467
467
  return args.format('ry({0:half_turns}) {1};\n', self._exponent, qubits[0])
468
468
 
469
469
  @property
470
- def phase_exponent(self):
470
+ def phase_exponent(self) -> float:
471
471
  return 0.5
472
472
 
473
473
  def _phase_by_(self, phase_turns, qubit_index):
@@ -124,10 +124,10 @@ class ControlledOperation(raw_types.Operation):
124
124
  )
125
125
 
126
126
  @property
127
- def qubits(self):
127
+ def qubits(self) -> tuple[cirq.Qid, ...]:
128
128
  return self.controls + self.sub_operation.qubits
129
129
 
130
- def with_qubits(self, *new_qubits):
130
+ def with_qubits(self, *new_qubits) -> ControlledOperation:
131
131
  n = len(self.controls)
132
132
  return ControlledOperation(
133
133
  new_qubits[:n], self.sub_operation.with_qubits(*new_qubits[n:]), self.control_values
@@ -17,7 +17,7 @@ from __future__ import annotations
17
17
  import itertools
18
18
  import re
19
19
  from types import EllipsisType, NotImplementedType
20
- from typing import cast
20
+ from typing import cast, Sequence
21
21
 
22
22
  import numpy as np
23
23
  import pytest
@@ -74,7 +74,7 @@ class GateAllocatingNewSpaceForResult(cirq.testing.SingleQubitGate):
74
74
  return 'cirq.ops.controlled_operation_test.GateAllocatingNewSpaceForResult()'
75
75
 
76
76
 
77
- def test_controlled_operation_init():
77
+ def test_controlled_operation_init() -> None:
78
78
  class G(cirq.testing.SingleQubitGate):
79
79
  def _has_mixture_(self):
80
80
  return True
@@ -123,7 +123,7 @@ def test_controlled_operation_init():
123
123
  _ = cirq.ControlledOperation([cb], cirq.PhaseDampingChannel(1)(q))
124
124
 
125
125
 
126
- def test_controlled_operation_eq():
126
+ def test_controlled_operation_eq() -> None:
127
127
  c1 = cirq.NamedQubit('c1')
128
128
  q1 = cirq.NamedQubit('q1')
129
129
  c2 = cirq.NamedQubit('c2')
@@ -148,7 +148,7 @@ def test_controlled_operation_eq():
148
148
  )
149
149
 
150
150
 
151
- def test_str():
151
+ def test_str() -> None:
152
152
  c1 = cirq.NamedQubit('c1')
153
153
  c2 = cirq.NamedQubit('c2')
154
154
  q2 = cirq.NamedQubit('q2')
@@ -190,7 +190,7 @@ def test_str():
190
190
  )
191
191
 
192
192
 
193
- def test_repr():
193
+ def test_repr() -> None:
194
194
  a, b, c, d = cirq.LineQubit.range(4)
195
195
 
196
196
  ch = cirq.H(a).controlled_by(b)
@@ -231,7 +231,8 @@ class MultiH(cirq.Gate):
231
231
  return True
232
232
 
233
233
 
234
- def test_circuit_diagram():
234
+ def test_circuit_diagram() -> None:
235
+ qubits: Sequence[cirq.Qid]
235
236
  qubits = cirq.LineQubit.range(3)
236
237
  c = cirq.Circuit()
237
238
  c.append(cirq.ControlledOperation(qubits[:1], MultiH(2)(*qubits[1:])))
@@ -302,7 +303,7 @@ class MockGate(cirq.testing.TwoQubitGate):
302
303
  return True
303
304
 
304
305
 
305
- def test_controlled_diagram_exponent():
306
+ def test_controlled_diagram_exponent() -> None:
306
307
  for q in itertools.permutations(cirq.LineQubit.range(5)):
307
308
  for idx in [None, 0, 1]:
308
309
  op = MockGate(idx)(*q[:2]).controlled_by(*q[2:])
@@ -310,7 +311,7 @@ def test_controlled_diagram_exponent():
310
311
  assert cirq.circuit_diagram_info(op).exponent_qubit_index == len(q[2:]) + add
311
312
 
312
313
 
313
- def test_uninformed_circuit_diagram_info():
314
+ def test_uninformed_circuit_diagram_info() -> None:
314
315
  qbits = cirq.LineQubit.range(3)
315
316
  mock_gate = MockGate()
316
317
  c_op = cirq.ControlledOperation(qbits[:1], mock_gate(*qbits[1:]))
@@ -323,7 +324,7 @@ def test_uninformed_circuit_diagram_info():
323
324
  assert mock_gate.captured_diagram_args == args
324
325
 
325
326
 
326
- def test_non_diagrammable_subop():
327
+ def test_non_diagrammable_subop() -> None:
327
328
  qbits = cirq.LineQubit.range(2)
328
329
 
329
330
  class UndiagrammableGate(cirq.testing.SingleQubitGate):
@@ -369,7 +370,7 @@ def test_non_diagrammable_subop():
369
370
  )
370
371
  def test_controlled_operation_is_consistent(
371
372
  gate: cirq.GateOperation, should_decompose_to_target: bool
372
- ):
373
+ ) -> None:
373
374
  cb = cirq.NamedQubit('ctr')
374
375
  cgate = cirq.ControlledOperation([cb], gate)
375
376
  cirq.testing.assert_implements_consistent_protocols(cgate)
@@ -395,7 +396,7 @@ def test_controlled_operation_is_consistent(
395
396
  cirq.testing.assert_decompose_ends_at_default_gateset(cgate)
396
397
 
397
398
 
398
- def test_controlled_circuit_operation_is_consistent():
399
+ def test_controlled_circuit_operation_is_consistent() -> None:
399
400
  op = cirq.CircuitOperation(
400
401
  cirq.FrozenCircuit(
401
402
  cirq.XXPowGate(exponent=0.25, global_shift=-0.5).on(*cirq.LineQubit.range(2))
@@ -416,7 +417,7 @@ def test_controlled_circuit_operation_is_consistent():
416
417
 
417
418
 
418
419
  @pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
419
- def test_parameterizable(resolve_fn):
420
+ def test_parameterizable(resolve_fn) -> None:
420
421
  a = sympy.Symbol('a')
421
422
  qubits = cirq.LineQubit.range(3)
422
423
 
@@ -434,7 +435,7 @@ def test_parameterizable(resolve_fn):
434
435
  resolve_fn(cchan, cirq.ParamResolver({'a': 0.1}))
435
436
 
436
437
 
437
- def test_bounded_effect():
438
+ def test_bounded_effect() -> None:
438
439
  qubits = cirq.LineQubit.range(3)
439
440
  cy = cirq.ControlledOperation(qubits[:1], cirq.Y(qubits[1]))
440
441
  assert cirq.trace_distance_bound(cy**0.001) < 0.01
@@ -444,8 +445,8 @@ def test_bounded_effect():
444
445
  assert cirq.approx_eq(cirq.trace_distance_bound(cy), 1.0)
445
446
 
446
447
 
447
- def test_controlled_operation_gate():
448
- gate = cirq.X.controlled(control_values=[0, 1], control_qid_shape=[2, 3])
448
+ def test_controlled_operation_gate() -> None:
449
+ gate = cirq.X.controlled(control_values=[0, 1], control_qid_shape=(2, 3))
449
450
  op = gate.on(cirq.LineQubit(0), cirq.LineQid(1, 3), cirq.LineQubit(2))
450
451
  assert op.gate == gate
451
452
 
@@ -464,7 +465,7 @@ def test_controlled_operation_gate():
464
465
  assert op.gate is None
465
466
 
466
467
 
467
- def test_controlled_mixture():
468
+ def test_controlled_mixture() -> None:
468
469
  a, b = cirq.LineQubit.range(2)
469
470
  c_yes = cirq.ControlledOperation(controls=[b], sub_operation=cirq.phase_flip(0.25).on(a))
470
471
  assert cirq.has_mixture(c_yes)
@@ -25,13 +25,13 @@ from typing import (
25
25
  Iterable,
26
26
  Iterator,
27
27
  overload,
28
+ Self,
28
29
  Sequence,
29
30
  TYPE_CHECKING,
30
31
  )
31
32
 
32
33
  import numpy as np
33
34
  import sympy
34
- from typing_extensions import Self
35
35
 
36
36
  from cirq import linalg, protocols, value
37
37
  from cirq._compat import proper_repr
@@ -24,7 +24,7 @@ import cirq
24
24
  from cirq.ops.dense_pauli_string import _vectorized_pauli_mul_phase
25
25
 
26
26
 
27
- def test_init():
27
+ def test_init() -> None:
28
28
  mask = np.array([0, 3, 1, 2], dtype=np.uint8)
29
29
  p = cirq.DensePauliString(coefficient=2, pauli_mask=mask)
30
30
  m = cirq.MutableDensePauliString(coefficient=3, pauli_mask=mask)
@@ -50,10 +50,10 @@ def test_init():
50
50
  assert cirq.DensePauliString([1, 'X', cirq.X]) == cirq.DensePauliString('XXX')
51
51
  assert list(cirq.DensePauliString('XXX')) == [cirq.X, cirq.X, cirq.X]
52
52
  with pytest.raises(TypeError, match='Expected a cirq.PAULI_GATE_LIKE'):
53
- _ = cirq.DensePauliString([object()])
53
+ _ = cirq.DensePauliString([object()]) # type: ignore[list-item]
54
54
 
55
55
 
56
- def test_value_to_char_correspondence():
56
+ def test_value_to_char_correspondence() -> None:
57
57
  d = cirq.DensePauliString
58
58
  assert [d.I_VAL, d.X_VAL, d.Y_VAL, d.Z_VAL] == [0, 1, 2, 3]
59
59
  assert list(d([cirq.I, cirq.X, cirq.Y, cirq.Z]).pauli_mask) == [0, 1, 2, 3]
@@ -69,7 +69,7 @@ def test_value_to_char_correspondence():
69
69
  assert d('Z') * d('Y') == -1j * d('X')
70
70
 
71
71
 
72
- def test_from_text():
72
+ def test_from_text() -> None:
73
73
  d = cirq.DensePauliString
74
74
  m = cirq.MutableDensePauliString
75
75
 
@@ -86,7 +86,7 @@ def test_from_text():
86
86
  _ = d('2')
87
87
 
88
88
 
89
- def test_immutable_eq():
89
+ def test_immutable_eq() -> None:
90
90
  eq = cirq.testing.EqualsTester()
91
91
 
92
92
  # Immutables
@@ -103,7 +103,7 @@ def test_immutable_eq():
103
103
  eq.make_equality_group(lambda: cirq.MutableDensePauliString(coefficient=2, pauli_mask=[2]))
104
104
 
105
105
 
106
- def test_eye():
106
+ def test_eye() -> None:
107
107
  f = cirq.DensePauliString
108
108
  m = cirq.MutableDensePauliString
109
109
  assert cirq.BaseDensePauliString.eye(4) == f('IIII')
@@ -111,7 +111,7 @@ def test_eye():
111
111
  assert cirq.MutableDensePauliString.eye(4) == m('IIII')
112
112
 
113
113
 
114
- def test_sparse():
114
+ def test_sparse() -> None:
115
115
  a, b, c = cirq.LineQubit.range(3)
116
116
  p = -cirq.DensePauliString('XYZ')
117
117
  assert p.sparse() == cirq.PauliString(-1, cirq.X(a), cirq.Y(b), cirq.Z(c))
@@ -122,12 +122,14 @@ def test_sparse():
122
122
  _ = p.sparse(cirq.GridQubit.rect(2, 2))
123
123
 
124
124
 
125
- def test_mul_vectorized_pauli_mul_phase():
125
+ def test_mul_vectorized_pauli_mul_phase() -> None:
126
126
  f = _vectorized_pauli_mul_phase
127
127
  paulis = [cirq.I, cirq.X, cirq.Y, cirq.Z]
128
128
  q = cirq.LineQubit(0)
129
129
 
130
130
  # Check single qubit cases.
131
+ sparse1: cirq.PauliString
132
+ sparse2: cirq.PauliString
131
133
  for i in range(4):
132
134
  for j in range(4):
133
135
  sparse1 = cirq.PauliString(paulis[i].on(q))
@@ -146,7 +148,7 @@ def test_mul_vectorized_pauli_mul_phase():
146
148
  )
147
149
 
148
150
 
149
- def test_mul():
151
+ def test_mul() -> None:
150
152
  f = cirq.DensePauliString
151
153
 
152
154
  # Scalar.
@@ -193,22 +195,23 @@ def test_mul():
193
195
 
194
196
  # Unknown number type
195
197
  class UnknownNumber(numbers.Number):
196
- pass
198
+ def __hash__(self):
199
+ return hash(complex(self)) # pragma: no cover
197
200
 
198
201
  with pytest.raises(TypeError):
199
202
  _ = UnknownNumber() * f('I')
200
203
 
201
204
 
202
- def test_imul():
205
+ def test_imul() -> None:
203
206
  f = cirq.DensePauliString
204
207
  m = cirq.MutableDensePauliString
205
208
 
206
209
  # Immutable not modified by imul.
207
- p = f('III')
208
- p2 = p
209
- p2 *= 2
210
- assert p.coefficient == 1
211
- assert p is not p2
210
+ pf = f('III')
211
+ pf2 = pf
212
+ pf2 *= 2
213
+ assert pf.coefficient == 1
214
+ assert pf is not pf2
212
215
 
213
216
  # Mutable is modified by imul.
214
217
  p = m('III')
@@ -239,19 +242,20 @@ def test_imul():
239
242
 
240
243
  # Unknown number type
241
244
  class UnknownNumber(numbers.Number):
242
- pass
245
+ def __hash__(self):
246
+ return hash(complex(self)) # pragma: no cover
243
247
 
244
248
  with pytest.raises(TypeError):
245
249
  p *= UnknownNumber()
246
250
 
247
251
 
248
- def test_pos_neg():
252
+ def test_pos_neg() -> None:
249
253
  p = 1j * cirq.DensePauliString('XYZ')
250
254
  assert +p == p
251
255
  assert -p == -1 * p
252
256
 
253
257
 
254
- def test_abs():
258
+ def test_abs() -> None:
255
259
  f = cirq.DensePauliString
256
260
  m = cirq.DensePauliString
257
261
  assert abs(-f('XX')) == f('XX')
@@ -259,7 +263,7 @@ def test_abs():
259
263
  assert abs(2j * m('XX')) == 2 * f('XX')
260
264
 
261
265
 
262
- def test_approx_eq():
266
+ def test_approx_eq() -> None:
263
267
  f = cirq.DensePauliString
264
268
  m = cirq.MutableDensePauliString
265
269
 
@@ -278,7 +282,7 @@ def test_approx_eq():
278
282
  assert not cirq.approx_eq(f('X'), f('Y'), atol=500)
279
283
 
280
284
 
281
- def test_pow():
285
+ def test_pow() -> None:
282
286
  f = cirq.DensePauliString
283
287
  m = cirq.DensePauliString
284
288
  p = 1j * f('IXYZ')
@@ -314,7 +318,7 @@ def test_pow():
314
318
  assert m('X') ** 3 == f('X')
315
319
 
316
320
 
317
- def test_div():
321
+ def test_div() -> None:
318
322
  f = cirq.DensePauliString
319
323
  t = sympy.Symbol('t')
320
324
  assert f('X') / 2 == 0.5 * f('X')
@@ -323,7 +327,7 @@ def test_div():
323
327
  _ = f('X') / object()
324
328
 
325
329
 
326
- def test_str():
330
+ def test_str() -> None:
327
331
  f = cirq.DensePauliString
328
332
  m = cirq.MutableDensePauliString
329
333
 
@@ -338,7 +342,7 @@ def test_str():
338
342
  assert str(f('XX', coefficient=sympy.Symbol('t'))) == 't*XX'
339
343
 
340
344
 
341
- def test_repr():
345
+ def test_repr() -> None:
342
346
  f = cirq.DensePauliString
343
347
  m = cirq.MutableDensePauliString
344
348
  cirq.testing.assert_equivalent_repr(f(''))
@@ -351,7 +355,7 @@ def test_repr():
351
355
  cirq.testing.assert_equivalent_repr(m(coefficient=sympy.Symbol('c'), pauli_mask=[0, 3, 2, 1]))
352
356
 
353
357
 
354
- def test_one_hot():
358
+ def test_one_hot() -> None:
355
359
  f = cirq.DensePauliString
356
360
  m = cirq.MutableDensePauliString
357
361
 
@@ -374,7 +378,7 @@ def test_one_hot():
374
378
  _ = cirq.BaseDensePauliString.one_hot(index=0, length=0, pauli=cirq.X)
375
379
 
376
380
 
377
- def test_protocols():
381
+ def test_protocols() -> None:
378
382
  t = sympy.Symbol('t')
379
383
  cirq.testing.assert_implements_consistent_protocols(cirq.DensePauliString('Y'))
380
384
  cirq.testing.assert_implements_consistent_protocols(-cirq.DensePauliString('Z'))
@@ -400,7 +404,7 @@ def test_protocols():
400
404
 
401
405
 
402
406
  @pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
403
- def test_parameterizable(resolve_fn):
407
+ def test_parameterizable(resolve_fn) -> None:
404
408
  t = sympy.Symbol('t')
405
409
  x = cirq.DensePauliString('X')
406
410
  xt = x * t
@@ -415,7 +419,7 @@ def test_parameterizable(resolve_fn):
415
419
  assert resolve_fn(xt(q).gate, {'t': 2}) == x2
416
420
 
417
421
 
418
- def test_item_immutable():
422
+ def test_item_immutable() -> None:
419
423
  p = -cirq.DensePauliString('XYIZ')
420
424
  assert p[-1] == cirq.Z
421
425
  assert p[0] == cirq.X
@@ -437,7 +441,7 @@ def test_item_immutable():
437
441
  assert p[::2] == cirq.DensePauliString('XI')
438
442
 
439
443
 
440
- def test_item_mutable():
444
+ def test_item_mutable() -> None:
441
445
  m = cirq.MutableDensePauliString
442
446
  p = m('XYIZ', coefficient=-1)
443
447
  assert p[-1] == cirq.Z
@@ -448,9 +452,9 @@ def test_item_mutable():
448
452
  with pytest.raises(IndexError):
449
453
  _ = p[4]
450
454
  with pytest.raises(TypeError):
451
- _ = p["test"]
455
+ _ = p["test"] # type: ignore[call-overload]
452
456
  with pytest.raises(TypeError):
453
- p["test"] = 'X'
457
+ p["test"] = 'X' # type: ignore[call-overload]
454
458
 
455
459
  p[2] = cirq.X
456
460
  assert p == m('XYXZ', coefficient=-1)
@@ -482,7 +486,7 @@ def test_item_mutable():
482
486
  assert p == m('ZYXX', coefficient=-1)
483
487
 
484
488
 
485
- def test_tensor_product():
489
+ def test_tensor_product() -> None:
486
490
  f = cirq.DensePauliString
487
491
  m = cirq.MutableDensePauliString
488
492
  assert (2 * f('XX')).tensor_product(-f('XI')) == -2 * f('XXXI')
@@ -491,7 +495,7 @@ def test_tensor_product():
491
495
  assert m('XX', coefficient=2).tensor_product(m('XI', coefficient=-1)) == -2 * m('XXXI')
492
496
 
493
497
 
494
- def test_commutes():
498
+ def test_commutes() -> None:
495
499
  f = cirq.DensePauliString
496
500
  m = cirq.MutableDensePauliString
497
501
 
@@ -507,7 +511,7 @@ def test_commutes():
507
511
  assert cirq.commutes(f('XX'), "test", default=NotImplemented) is NotImplemented
508
512
 
509
513
 
510
- def test_copy():
514
+ def test_copy() -> None:
511
515
  p = -cirq.DensePauliString('XYZ')
512
516
  m = cirq.MutableDensePauliString('XYZ', coefficient=-1)
513
517
 
@@ -545,7 +549,7 @@ def test_copy():
545
549
  assert cirq.MutableDensePauliString('XYZ').copy(pauli_mask=mask).pauli_mask is mask
546
550
 
547
551
 
548
- def test_gaussian_elimination():
552
+ def test_gaussian_elimination() -> None:
549
553
  def table(*rows: str) -> list[cirq.MutableDensePauliString]:
550
554
  coefs = {'i': 1j, '-': -1, '+': 1}
551
555
  return [
@@ -626,7 +630,7 @@ def test_gaussian_elimination():
626
630
  )
627
631
 
628
632
 
629
- def test_idiv():
633
+ def test_idiv() -> None:
630
634
  p = cirq.MutableDensePauliString('XYZ', coefficient=2)
631
635
  p /= 2
632
636
  assert p == cirq.MutableDensePauliString('XYZ')
@@ -635,7 +639,7 @@ def test_idiv():
635
639
  p /= object()
636
640
 
637
641
 
638
- def test_symbolic():
642
+ def test_symbolic() -> None:
639
643
  t = sympy.Symbol('t')
640
644
  r = sympy.Symbol('r')
641
645
  m = cirq.MutableDensePauliString('XYZ', coefficient=t)
@@ -34,10 +34,6 @@ class CExpZinGate(cirq.EigenGate, cirq.testing.TwoQubitGate):
34
34
  def __init__(self, quarter_turns: value.TParamVal) -> None:
35
35
  super().__init__(exponent=quarter_turns)
36
36
 
37
- @property
38
- def exponent(self):
39
- return self._exponent
40
-
41
37
  def _with_exponent(self, exponent):
42
38
  return CExpZinGate(exponent)
43
39
 
@@ -50,9 +46,6 @@ class CExpZinGate(cirq.EigenGate, cirq.testing.TwoQubitGate):
50
46
 
51
47
 
52
48
  class ZGateDef(cirq.EigenGate, cirq.testing.SingleQubitGate):
53
- @property
54
- def exponent(self):
55
- return self._exponent
56
49
 
57
50
  def _eigen_components(self) -> list[tuple[float, np.ndarray]]:
58
51
  return [(0, np.diag([1, 0])), (1, np.diag([0, 1]))]
@@ -19,9 +19,17 @@ from __future__ import annotations
19
19
  import re
20
20
  import warnings
21
21
  from types import NotImplementedType
22
- from typing import AbstractSet, Any, cast, Collection, Mapping, Sequence, TYPE_CHECKING, TypeVar
23
-
24
- from typing_extensions import Self
22
+ from typing import (
23
+ AbstractSet,
24
+ Any,
25
+ cast,
26
+ Collection,
27
+ Mapping,
28
+ Self,
29
+ Sequence,
30
+ TYPE_CHECKING,
31
+ TypeVar,
32
+ )
25
33
 
26
34
  from cirq import ops, protocols, value
27
35
  from cirq.ops import control_values as cv, gate_features, raw_types
cirq/ops/gateset.py CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  from __future__ import annotations
18
18
 
19
- from typing import Any, Callable, cast, Hashable, Sequence, TYPE_CHECKING
19
+ from typing import Any, Callable, cast, Hashable, Iterable, TYPE_CHECKING
20
20
 
21
21
  from cirq import protocols, value
22
22
  from cirq.ops import global_phase_op, op_tree, raw_types
@@ -105,8 +105,8 @@ class GateFamily:
105
105
  name: str | None = None,
106
106
  description: str | None = None,
107
107
  ignore_global_phase: bool = True,
108
- tags_to_accept: Sequence[Hashable] = (),
109
- tags_to_ignore: Sequence[Hashable] = (),
108
+ tags_to_accept: Iterable[Hashable] = (),
109
+ tags_to_ignore: Iterable[Hashable] = (),
110
110
  ) -> None:
111
111
  """Init GateFamily.
112
112