cirq-core 1.7.0.dev20250911065757__py3-none-any.whl → 1.7.0.dev20250911070206__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.

cirq/_version.py CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 11, 0): # pragma: no cover
28
28
  'of Cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.7.0.dev20250911065757"
31
+ __version__ = "1.7.0.dev20250911070206"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.7.0.dev20250911065757"
6
+ assert cirq.__version__ == "1.7.0.dev20250911070206"
cirq/circuits/circuit.py CHANGED
@@ -1666,8 +1666,14 @@ class AbstractCircuit(abc.ABC):
1666
1666
  )
1667
1667
 
1668
1668
  def _control_keys_(self) -> frozenset[cirq.MeasurementKey]:
1669
- controls = frozenset(k for op in self.all_operations() for k in protocols.control_keys(op))
1670
- return controls - protocols.measurement_key_objs(self)
1669
+ measures: set[cirq.MeasurementKey] = set()
1670
+ controls: set[cirq.MeasurementKey] = set()
1671
+ for op in self.all_operations():
1672
+ # Only require keys that haven't already been measured earlier
1673
+ controls.update(k for k in protocols.control_keys(op) if k not in measures)
1674
+ # Record any measurement keys produced by this op
1675
+ measures.update(protocols.measurement_key_objs(op))
1676
+ return frozenset(controls)
1671
1677
 
1672
1678
 
1673
1679
  def _overlap_collision_time(
@@ -1324,3 +1324,17 @@ def test_has_unitary_protocol_returns_true_if_all_params_resolve() -> None:
1324
1324
  exp = sympy.Symbol('exp')
1325
1325
  op = cirq.CircuitOperation(cirq.FrozenCircuit(cirq.X(q) ** exp), param_resolver={exp: 0.5})
1326
1326
  assert protocols.has_unitary(op)
1327
+
1328
+
1329
+ def test_control_keys_respects_internal_measurement_order() -> None:
1330
+ q = cirq.LineQubit(0)
1331
+
1332
+ # Control BEFORE measurement inside the subcircuit: external key required
1333
+ fc_before = cirq.FrozenCircuit(cirq.X(q).with_classical_controls('a'), cirq.measure(q, key='a'))
1334
+ op_before = cirq.CircuitOperation(fc_before)
1335
+ assert cirq.control_keys(op_before) == {cirq.MeasurementKey('a')}
1336
+
1337
+ # Measurement BEFORE control inside the subcircuit: no external key required
1338
+ fc_after = cirq.FrozenCircuit(cirq.measure(q, key='a'), cirq.X(q).with_classical_controls('a'))
1339
+ op_after = cirq.CircuitOperation(fc_after)
1340
+ assert cirq.control_keys(op_after) == set()
@@ -53,6 +53,13 @@ def control_keys(val: Any) -> frozenset[cirq.MeasurementKey]:
53
53
  Returns:
54
54
  The measurement keys the value is controlled by. If the value is not
55
55
  classically controlled, the result is the empty tuple.
56
+
57
+ Notes:
58
+ For composite operations (e.g. CircuitOperation), only control keys that
59
+ have not already been measured earlier in the subcircuit are returned.
60
+ Control keys that are satisfied by measurements **after** their use in
61
+ the subcircuit are still required externally and thus appear in the
62
+ result.
56
63
  """
57
64
  getter = getattr(val, '_control_keys_', None)
58
65
  result = NotImplemented if getter is None else getter()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20250911065757
3
+ Version: 1.7.0.dev20250911070206
4
4
  Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
5
5
  Home-page: http://github.com/quantumlib/cirq
6
6
  Author: The Cirq Developers
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
4
4
  cirq/_doc.py,sha256=BrnoABo1hk5RgB3Cgww4zLHUfiyFny0F1V-tOMCbdaU,2909
5
5
  cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
6
6
  cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
7
- cirq/_version.py,sha256=zPtfQD35EquRA4kxlb2EC-SfCGx7i76rCpSq_57IEKo,1206
8
- cirq/_version_test.py,sha256=8OMhOpd1sKUe8_uUh2e6dKVgYrYE6e0EjB_9uExd7jo,155
7
+ cirq/_version.py,sha256=JVq3XyWok9yeOK1H682f3S7y9xBiwyyX--njnMgHF9I,1206
8
+ cirq/_version_test.py,sha256=dzDdyWPBZoNP7e52Fif6y9yqcw-THoOa79zkaT0CzP4,155
9
9
  cirq/conftest.py,sha256=wSDKNdIQRDfLnXvOCWD3erheOw8JHRhdfQ53EyTUIXg,1239
10
10
  cirq/json_resolver_cache.py,sha256=A5DIgFAY1hUNt9vai_C3-gGBv24116CJMzQxMcXOax4,13726
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -16,9 +16,9 @@ cirq/circuits/_box_drawing_character_data.py,sha256=hExbMJHm9LGORhlhNiUvPiHquv4p
16
16
  cirq/circuits/_box_drawing_character_data_test.py,sha256=GyiNQDtiu_drzEe_y8DOXCFRYDKr2k8KetXN5RVDp18,1668
17
17
  cirq/circuits/_bucket_priority_queue.py,sha256=U564r2mou4aZsOlpVYiZCgirqS6mVznG3ESyawBt4gE,6749
18
18
  cirq/circuits/_bucket_priority_queue_test.py,sha256=MOby-UKYZQMe2n4KhqkfDCPrz-T_3eBbWDEa0_nadJQ,5627
19
- cirq/circuits/circuit.py,sha256=sBUG4Tm2KXYkwiPPJ_HDYBJM6fkhb_Qxfny93wXANCw,122960
19
+ cirq/circuits/circuit.py,sha256=y3QNLrJtgltpEOyBOADaQHayB6F92HeHIzuJDXZsJEM,123264
20
20
  cirq/circuits/circuit_operation.py,sha256=vvLk30okWhimdJRFhFOpwoHDkyOHzR2I9OIggZaqmVk,36338
21
- cirq/circuits/circuit_operation_test.py,sha256=ZoYvAIsURx9yPWiLcPeX3--lkCOFJkXLxHafUJaZf1U,50425
21
+ cirq/circuits/circuit_operation_test.py,sha256=oBecDWETbLYp5Br7aN1BoWA73VbNbhhtlkydDhnk5z8,51098
22
22
  cirq/circuits/circuit_test.py,sha256=fT08nAEf-aiA5cvboBYnfLPGJHxauGIzJ2_Iw0fWT40,167182
23
23
  cirq/circuits/frozen_circuit.py,sha256=UXwABQqBSnSKqSWmRluQPD09xZU0orSW3b3IHvDqxUw,7903
24
24
  cirq/circuits/frozen_circuit_test.py,sha256=1Uk3g9St_nJFmu3IJ5hAcXWJjLfWFUXTCKQU1b0JJrE,5321
@@ -409,7 +409,7 @@ cirq/protocols/circuit_diagram_info_protocol.py,sha256=Bj7zAAxFZZ7VhJWk8eLmCWVX-
409
409
  cirq/protocols/circuit_diagram_info_protocol_test.py,sha256=r-kNamR6QPdu-Q9to2DKLrDP9J8rWOA7IxfMVvcO0qE,12074
410
410
  cirq/protocols/commutes_protocol.py,sha256=DPwB_xKiqj3MW8uxEksjWDd6c163zgNMNMDjE2N9Xbw,7368
411
411
  cirq/protocols/commutes_protocol_test.py,sha256=INP3i39_3Xqh8oDTDNdY546fqD3eqnVzW_TO0zUVCeg,5911
412
- cirq/protocols/control_key_protocol.py,sha256=OhMkglGhP0_Of1Z-pMkEs6pYDTKzmu23pVyZunqyBBk,2591
412
+ cirq/protocols/control_key_protocol.py,sha256=a_yEw9vk7nlfJ-lADHIJPf0RhuxfM7KYcRvuG-prtXg,2934
413
413
  cirq/protocols/control_key_protocol_test.py,sha256=fNDDkf4mQpA_tKuhX1e2BJN72v9HdGftgd79sOqREJE,1014
414
414
  cirq/protocols/decompose_protocol.py,sha256=73wGRdSf4o_K8MJ0i-DPJIBiNlq6fRGrF9E90NqxhwY,18941
415
415
  cirq/protocols/decompose_protocol_test.py,sha256=JJexKMKYdSW1K1S4wkTyR1Wy80Ku_jHslSJx3gJ5REs,18130
@@ -1234,8 +1234,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1234
1234
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1235
1235
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1236
1236
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1237
- cirq_core-1.7.0.dev20250911065757.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
- cirq_core-1.7.0.dev20250911065757.dist-info/METADATA,sha256=LLlO9EvQfJkle_JCjuv0leIAKBPhIn3aqZUTE2bUWCs,4758
1239
- cirq_core-1.7.0.dev20250911065757.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
- cirq_core-1.7.0.dev20250911065757.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
- cirq_core-1.7.0.dev20250911065757.dist-info/RECORD,,
1237
+ cirq_core-1.7.0.dev20250911070206.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
+ cirq_core-1.7.0.dev20250911070206.dist-info/METADATA,sha256=UOrxXFQdQJv-z8m05_YpZdWsIRjGTYykdJcH-LO76XE,4758
1239
+ cirq_core-1.7.0.dev20250911070206.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
+ cirq_core-1.7.0.dev20250911070206.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
+ cirq_core-1.7.0.dev20250911070206.dist-info/RECORD,,