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
cirq/ops/gateset_test.py CHANGED
@@ -56,7 +56,7 @@ q = cirq.NamedQubit("q")
56
56
 
57
57
 
58
58
  @pytest.mark.parametrize('gate', [CustomX, CustomXPowGate])
59
- def test_gate_family_init(gate):
59
+ def test_gate_family_init(gate) -> None:
60
60
  name = 'test_name'
61
61
  description = 'test_description'
62
62
  g = cirq.GateFamily(gate=gate, name=name, description=description)
@@ -75,7 +75,7 @@ def test_gate_family_init(gate):
75
75
  (CustomXPowGate, [], []),
76
76
  ],
77
77
  )
78
- def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_ignore):
78
+ def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_ignore) -> None:
79
79
  g = cirq.GateFamily(gate, tags_to_accept=tags_to_accept, tags_to_ignore=tags_to_ignore)
80
80
  assert re.match('.*GateFamily.*CustomX.*', g.name)
81
81
  assert re.match('Accepts.*instances.*CustomX.*', g.description)
@@ -97,7 +97,7 @@ def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_
97
97
  )
98
98
  def test_gate_family_equality_with_tags(
99
99
  tags_to_accept_fam1, tags_to_ignore_fam1, tags_to_accept_fam2, tags_to_ignore_fam2
100
- ):
100
+ ) -> None:
101
101
  gate_fam1 = cirq.GateFamily(
102
102
  cirq.X, tags_to_accept=tags_to_accept_fam1, tags_to_ignore=tags_to_ignore_fam1
103
103
  )
@@ -108,9 +108,9 @@ def test_gate_family_equality_with_tags(
108
108
  assert gate_fam1 == gate_fam2
109
109
 
110
110
 
111
- def test_invalid_gate_family():
111
+ def test_invalid_gate_family() -> None:
112
112
  with pytest.raises(ValueError, match='instance or subclass of `cirq.Gate`'):
113
- _ = cirq.GateFamily(gate=cirq.Operation)
113
+ _ = cirq.GateFamily(gate=cirq.Operation) # type: ignore[arg-type]
114
114
 
115
115
  with pytest.raises(ValueError, match='non-parameterized instance of `cirq.Gate`'):
116
116
  _ = cirq.GateFamily(gate=CustomX ** sympy.Symbol('theta'))
@@ -119,31 +119,31 @@ def test_invalid_gate_family():
119
119
  _ = cirq.GateFamily(gate=cirq.H, tags_to_accept={'a', 'b'}, tags_to_ignore={'b', 'c'})
120
120
 
121
121
 
122
- def test_gate_family_immutable():
122
+ def test_gate_family_immutable() -> None:
123
123
  g = cirq.GateFamily(CustomX)
124
124
  # Match one of two strings. The second one is message returned since python 3.11.
125
125
  with pytest.raises(
126
126
  AttributeError,
127
127
  match="(can't set attribute)|(property 'gate' of 'GateFamily' object has no setter)",
128
128
  ):
129
- g.gate = CustomXPowGate
129
+ g.gate = CustomXPowGate # type: ignore[misc]
130
130
  with pytest.raises(
131
131
  AttributeError,
132
132
  match="(can't set attribute)|(property 'name' of 'GateFamily' object has no setter)",
133
133
  ):
134
- g.name = 'new name'
134
+ g.name = 'new name' # type: ignore[misc]
135
135
  with pytest.raises(
136
136
  AttributeError,
137
137
  match="(can't set attribute)|(property 'description' of 'GateFamily' object has no setter)",
138
138
  ):
139
- g.description = 'new description'
139
+ g.description = 'new description' # type: ignore[misc]
140
140
 
141
141
 
142
142
  @pytest.mark.parametrize(
143
143
  'gate', [CustomX, CustomXPowGate(exponent=0.5, global_shift=0.1), CustomXPowGate]
144
144
  )
145
145
  @pytest.mark.parametrize('name, description', [(None, None), ('custom_name', 'custom_description')])
146
- def test_gate_family_repr_and_str(gate, name, description):
146
+ def test_gate_family_repr_and_str(gate, name, description) -> None:
147
147
  g = cirq.GateFamily(gate, name=name, description=description)
148
148
  cirq.testing.assert_equivalent_repr(g)
149
149
  assert g.name in str(g)
@@ -152,13 +152,13 @@ def test_gate_family_repr_and_str(gate, name, description):
152
152
 
153
153
  @pytest.mark.parametrize('gate', [cirq.X, cirq.XPowGate(), cirq.XPowGate])
154
154
  @pytest.mark.parametrize('name, description', [(None, None), ('custom_name', 'custom_description')])
155
- def test_gate_family_json(gate, name, description):
155
+ def test_gate_family_json(gate, name, description) -> None:
156
156
  g = cirq.GateFamily(gate, name=name, description=description)
157
157
  g_json = cirq.to_json(g)
158
158
  assert cirq.read_json(json_text=g_json) == g
159
159
 
160
160
 
161
- def test_gate_family_eq():
161
+ def test_gate_family_eq() -> None:
162
162
  eq = cirq.testing.EqualsTester()
163
163
  eq.add_equality_group(cirq.GateFamily(CustomX))
164
164
  eq.add_equality_group(cirq.GateFamily(CustomX**3))
@@ -206,7 +206,7 @@ def test_gate_family_eq():
206
206
  ),
207
207
  ],
208
208
  )
209
- def test_gate_family_predicate_and_containment(gate_family, gates_to_check):
209
+ def test_gate_family_predicate_and_containment(gate_family, gates_to_check) -> None:
210
210
  for gate, result in gates_to_check:
211
211
  assert gate_family._predicate(gate) == result
212
212
  assert (gate in gate_family) == result
@@ -265,7 +265,7 @@ def test_gate_family_predicate_and_containment(gate_family, gates_to_check):
265
265
  ),
266
266
  ],
267
267
  )
268
- def test_gate_family_tagged_operations(gate_family, gates_to_check):
268
+ def test_gate_family_tagged_operations(gate_family, gates_to_check) -> None:
269
269
  for gate, result in gates_to_check:
270
270
  assert (gate in gate_family) == result
271
271
 
@@ -296,7 +296,7 @@ gateset = cirq.Gateset(
296
296
  )
297
297
 
298
298
 
299
- def test_gateset_init():
299
+ def test_gateset_init() -> None:
300
300
  assert gateset.name == 'custom gateset'
301
301
  assert gateset.gates == frozenset(
302
302
  [
@@ -308,7 +308,7 @@ def test_gateset_init():
308
308
 
309
309
 
310
310
  @pytest.mark.parametrize('g', [gateset, cirq.Gateset(name='empty gateset')])
311
- def test_gateset_repr_and_str(g):
311
+ def test_gateset_repr_and_str(g) -> None:
312
312
  cirq.testing.assert_equivalent_repr(g)
313
313
  assert g.name in str(g)
314
314
  for gate_family in g.gates:
@@ -328,7 +328,7 @@ def test_gateset_repr_and_str(g):
328
328
  (cirq.testing.TwoQubitGate(), True),
329
329
  ],
330
330
  )
331
- def test_gateset_contains(gate, result):
331
+ def test_gateset_contains(gate, result) -> None:
332
332
  assert (gate in gateset) is result
333
333
  op = gate(*cirq.LineQubit.range(gate.num_qubits()))
334
334
  assert (op in gateset) is result
@@ -339,7 +339,7 @@ def test_gateset_contains(gate, result):
339
339
 
340
340
 
341
341
  @pytest.mark.parametrize('use_circuit_op', [True, False])
342
- def test_gateset_validate(use_circuit_op):
342
+ def test_gateset_validate(use_circuit_op) -> None:
343
343
  def optree_and_circuit(optree):
344
344
  yield optree
345
345
  yield cirq.Circuit(optree)
@@ -374,14 +374,14 @@ def test_gateset_validate(use_circuit_op):
374
374
  )
375
375
 
376
376
 
377
- def test_gateset_validate_circuit_op_negative_reps():
377
+ def test_gateset_validate_circuit_op_negative_reps() -> None:
378
378
  gate = CustomXPowGate(exponent=0.5)
379
379
  op = cirq.CircuitOperation(cirq.FrozenCircuit(gate.on(cirq.LineQubit(0))), repetitions=-1)
380
380
  assert op not in cirq.Gateset(gate)
381
381
  assert op**-1 in cirq.Gateset(gate)
382
382
 
383
383
 
384
- def test_with_params():
384
+ def test_with_params() -> None:
385
385
  assert gateset.with_params() is gateset
386
386
  assert (
387
387
  gateset.with_params(name=gateset.name, unroll_circuit_op=gateset._unroll_circuit_op)
@@ -392,7 +392,7 @@ def test_with_params():
392
392
  assert gateset_with_params._unroll_circuit_op is False
393
393
 
394
394
 
395
- def test_gateset_eq():
395
+ def test_gateset_eq() -> None:
396
396
  eq = cirq.testing.EqualsTester()
397
397
  eq.add_equality_group(cirq.Gateset(CustomX))
398
398
  eq.add_equality_group(cirq.Gateset(CustomX**3))
@@ -427,7 +427,7 @@ def test_gateset_eq():
427
427
  )
428
428
 
429
429
 
430
- def test_gateset_contains_with_tags():
430
+ def test_gateset_contains_with_tags() -> None:
431
431
  tag = "PhysicalZTag"
432
432
  gf_accept = cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[tag])
433
433
  gf_ignore = cirq.GateFamily(cirq.ZPowGate, tags_to_ignore=[tag])
@@ -447,7 +447,7 @@ def test_gateset_contains_with_tags():
447
447
  assert op_with_tag in cirq.Gateset(gf_accept, gf_ignore)
448
448
 
449
449
 
450
- def test_gateset_contains_op_with_no_gate():
450
+ def test_gateset_contains_op_with_no_gate() -> None:
451
451
  gf = cirq.GateFamily(cirq.ZPowGate)
452
452
  op = cirq.X(cirq.q(1)).with_classical_controls('a')
453
453
  assert op.gate is None
@@ -473,7 +473,7 @@ class PauliSum:
473
473
 
474
474
  @classmethod
475
475
  def from_boolean_expression(
476
- cls, boolean_expr: sympy.Expr, qubit_map: dict[str, cirq.Qid]
476
+ cls, boolean_expr: sympy.Expr, qubit_map: Mapping[str, cirq.Qid]
477
477
  ) -> PauliSum:
478
478
  """Builds the Hamiltonian representation of a Boolean expression.
479
479