cirq-core 1.6.0.dev20250520231246__py3-none-any.whl → 1.6.0.dev20250521011052__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.6.0.dev20250520231246"
31
+ __version__ = "1.6.0.dev20250521011052"
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.6.0.dev20250520231246"
6
+ assert cirq.__version__ == "1.6.0.dev20250521011052"
@@ -146,6 +146,17 @@ class ControlledGate(raw_types.Gate):
146
146
  self, qubits: tuple[cirq.Qid, ...], context: cirq.DecompositionContext | None = None
147
147
  ) -> None | NotImplementedType | cirq.OP_TREE:
148
148
  control_qubits = list(qubits[: self.num_controls()])
149
+ controlled_sub_gate = self.sub_gate.controlled(
150
+ self.num_controls(), self.control_values, self.control_qid_shape
151
+ )
152
+ # Prefer the subgate controlled version if available
153
+ if self != controlled_sub_gate:
154
+ # Prevent 2-cycle from appearing in the recursive decomposition
155
+ # TODO: Remove after #7241 is resolved
156
+ if not isinstance(controlled_sub_gate, ControlledGate) or not isinstance(
157
+ controlled_sub_gate.sub_gate, common_gates.CZPowGate
158
+ ):
159
+ return controlled_sub_gate.on(*qubits)
149
160
  if (
150
161
  protocols.has_unitary(self.sub_gate)
151
162
  and protocols.num_qubits(self.sub_gate) == 1
@@ -496,6 +496,40 @@ def _test_controlled_gate_is_consistent(
496
496
  np.testing.assert_allclose(cirq.unitary(cgate), cirq.unitary(circuit), atol=1e-13)
497
497
 
498
498
 
499
+ @pytest.mark.parametrize(
500
+ 'sub_gate, expected_decomposition',
501
+ [
502
+ (cirq.X, [cirq.CX]),
503
+ (cirq.CX, [cirq.CCX]),
504
+ (cirq.XPowGate(), [cirq.CXPowGate()]),
505
+ (cirq.CXPowGate(), [cirq.CCXPowGate()]),
506
+ (cirq.Z, [cirq.CZ]),
507
+ (cirq.CZ, [cirq.CCZ]),
508
+ (cirq.ZPowGate(), [cirq.CZPowGate()]),
509
+ (cirq.CZPowGate(), [cirq.CCZPowGate()]),
510
+ ],
511
+ )
512
+ def test_controlled_gate_decomposition_uses_canonical_version(
513
+ sub_gate: cirq.Gate, expected_decomposition: list[cirq.Gate]
514
+ ):
515
+ cgate = cirq.ControlledGate(sub_gate, num_controls=1)
516
+ qubits = cirq.LineQubit.range(1 + sub_gate.num_qubits())
517
+ dec = cirq.decompose_once(cgate.on(*qubits))
518
+ assert dec == [gate.on(*qubits) for gate in expected_decomposition]
519
+
520
+
521
+ @pytest.mark.parametrize(
522
+ 'sub_gate, expected_decomposition', [(cirq.Z, [cirq.CZ]), (cirq.ZPowGate(), [cirq.CZPowGate()])]
523
+ )
524
+ def test_controlled_gate_full_decomposition(
525
+ sub_gate: cirq.Gate, expected_decomposition: list[cirq.Gate]
526
+ ):
527
+ cgate = cirq.ControlledGate(sub_gate, num_controls=1)
528
+ qubits = cirq.LineQubit.range(1 + sub_gate.num_qubits())
529
+ dec = cirq.decompose(cgate.on(*qubits))
530
+ assert dec == [gate.on(*qubits) for gate in expected_decomposition]
531
+
532
+
499
533
  def test_pow_inverse():
500
534
  assert cirq.inverse(CRestricted, None) is None
501
535
  assert cirq.pow(CRestricted, 1.5, None) is None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250520231246
3
+ Version: 1.6.0.dev20250521011052
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=ZSmenkbqEfRJpGsvutmV8vgIlfZCWj8GAVgi3t5YRso,34635
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=F_zNYYfbEI2zjnyFTxHFFrdMY10yUHp_FcGQF9b441U,1206
8
- cirq/_version_test.py,sha256=GU1UbKl0AW0YzXtwCvt54PTStiCR-HkyIjHcAltW4bs,155
7
+ cirq/_version.py,sha256=_uNO2BKllGN5pj9qTvaRaW19sPwuvLQ3g5yjVb3uYzM,1206
8
+ cirq/_version_test.py,sha256=TAGxxTypArmXct7YiRlGNLy6AhURrqf2z0ilQ_-IlZo,155
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=S-zUVI4D_XnAxyR6z7WHDImCVmB_awJp6EStD1-CNPU,13621
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -287,8 +287,8 @@ cirq/ops/common_gates.py,sha256=swHOtGrUEfwwQEJhSortO_5-PiaZr0f9dTkMYk0YMno,5789
287
287
  cirq/ops/common_gates_test.py,sha256=0q09MBVhYuLpfi1xejTrmzgyP4QaeCS-oW_aHOLKje8,46909
288
288
  cirq/ops/control_values.py,sha256=GrNi8YJZSZDCl8Su6Ocimvd1R1SejFJjVu2thcJ8VLI,13346
289
289
  cirq/ops/control_values_test.py,sha256=JYaFLJSIqZSaQ94y0kyWRRVzcQ9mgc6-s1ws2q4EiAg,12943
290
- cirq/ops/controlled_gate.py,sha256=SconRAuvWq4DM_hZtmEhvyIUz3Nv5hOw1qgXDQXNOvY,15036
291
- cirq/ops/controlled_gate_test.py,sha256=bBYBMiylGkD3885JmX0ytoSrAxpqVHSRJUfL5p2TewU,25532
290
+ cirq/ops/controlled_gate.py,sha256=YzHEkJdR0lFQPJee8ITcQQtRMmRv3I8tjHCtzEtsKSA,15632
291
+ cirq/ops/controlled_gate_test.py,sha256=j-W7ZUO_5JA3xFwiaUV664AFte51QhIw2oLOSgNwdDM,26777
292
292
  cirq/ops/controlled_operation.py,sha256=l0pjUfru39HBuAbBkRCqJmrJDxah0JOFxXXILcUt0v8,13978
293
293
  cirq/ops/controlled_operation_test.py,sha256=RTGRBGbobrUUB6Z_lFp6M2m7XN-b5A294rySWXVqXzc,16558
294
294
  cirq/ops/dense_pauli_string.py,sha256=1TijNu1D2HIbbnwLbT_f546R2L4OCQtm1bKjqhno1Kg,24234
@@ -1220,8 +1220,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1220
1220
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1221
1221
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1222
1222
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1223
- cirq_core-1.6.0.dev20250520231246.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
- cirq_core-1.6.0.dev20250520231246.dist-info/METADATA,sha256=_bjHe8YX1xQ07gOUPWPWCnnf3TpujsVlJQwQfoEwV94,4857
1225
- cirq_core-1.6.0.dev20250520231246.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1226
- cirq_core-1.6.0.dev20250520231246.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
- cirq_core-1.6.0.dev20250520231246.dist-info/RECORD,,
1223
+ cirq_core-1.6.0.dev20250521011052.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
+ cirq_core-1.6.0.dev20250521011052.dist-info/METADATA,sha256=VpBNgk_ex3upszTEojRmyekBT7XD0AyTBi62Ajw7_I4,4857
1225
+ cirq_core-1.6.0.dev20250521011052.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1226
+ cirq_core-1.6.0.dev20250521011052.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
+ cirq_core-1.6.0.dev20250521011052.dist-info/RECORD,,