cirq-core 1.7.0.dev20250911180224__py3-none-any.whl → 1.7.0.dev20250915211227__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.dev20250911180224"
31
+ __version__ = "1.7.0.dev20250915211227"
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.dev20250911180224"
6
+ assert cirq.__version__ == "1.7.0.dev20250915211227"
@@ -331,6 +331,21 @@ class GateOperation(raw_types.Operation):
331
331
  def __rmul__(self, other: Any) -> Any:
332
332
  return self.gate._rmul_with_qubits(self._qubits, other)
333
333
 
334
+ def __add__(self, other):
335
+ return 1 * self + other
336
+
337
+ def __radd__(self, other):
338
+ return other + 1 * self
339
+
340
+ def __sub__(self, other):
341
+ return 1 * self - other
342
+
343
+ def __rsub__(self, other):
344
+ return other + -self
345
+
346
+ def __neg__(self):
347
+ return -1 * self
348
+
334
349
  def _qasm_(self, args: protocols.QasmArgs) -> str | None:
335
350
  if isinstance(self.gate, ops.GlobalPhaseGate):
336
351
  warnings.warn(
@@ -746,10 +746,6 @@ class PauliSum:
746
746
  other = PauliSum.from_pauli_strings([PauliString(coefficient=other)])
747
747
  elif isinstance(other, PauliString):
748
748
  other = PauliSum.from_pauli_strings([other])
749
- elif isinstance(other, raw_types.Operation) and isinstance(
750
- other.gate, identity.IdentityGate
751
- ):
752
- other = PauliSum.from_pauli_strings([PauliString()])
753
749
 
754
750
  if not isinstance(other, PauliSum):
755
751
  return NotImplemented
@@ -758,10 +754,9 @@ class PauliSum:
758
754
  return self
759
755
 
760
756
  def __add__(self, other):
761
- if not isinstance(other, (numbers.Complex, PauliString, PauliSum, raw_types.Operation)):
762
- return NotImplemented
763
757
  result = self.copy()
764
- result += other
758
+ if result.__iadd__(other) is NotImplemented:
759
+ return NotImplemented
765
760
  return result
766
761
 
767
762
  def __radd__(self, other):
@@ -775,10 +770,6 @@ class PauliSum:
775
770
  other = PauliSum.from_pauli_strings([PauliString(coefficient=other)])
776
771
  elif isinstance(other, PauliString):
777
772
  other = PauliSum.from_pauli_strings([other])
778
- elif isinstance(other, raw_types.Operation) and isinstance(
779
- other.gate, identity.IdentityGate
780
- ):
781
- other = PauliSum.from_pauli_strings([PauliString()])
782
773
 
783
774
  if not isinstance(other, PauliSum):
784
775
  return NotImplemented
@@ -787,10 +778,9 @@ class PauliSum:
787
778
  return self
788
779
 
789
780
  def __sub__(self, other):
790
- if not isinstance(other, (numbers.Complex, PauliString, PauliSum, raw_types.Operation)):
791
- return NotImplemented
792
781
  result = self.copy()
793
- result -= other
782
+ if result.__isub__(other) is NotImplemented:
783
+ return NotImplemented
794
784
  return result
795
785
 
796
786
  def __neg__(self):
@@ -2086,12 +2086,13 @@ def test_resolve(resolve_fn) -> None:
2086
2086
  ids=str,
2087
2087
  )
2088
2088
  def test_pauli_ops_identity_gate_operation(gate1: cirq.Pauli, gate2: cirq.Pauli) -> None:
2089
- # TODO: Issue #7280 - Support addition and subtraction of identity gate operations.
2090
- if gate1 == gate2 == cirq.I:
2091
- pytest.skip('Not yet implemented per #7280')
2092
2089
  q = cirq.LineQubit(0)
2093
2090
  pauli1, pauli2 = gate1.on(q), gate2.on(q)
2094
- unitary1, unitary2 = cirq.unitary(gate1), cirq.unitary(gate2)
2091
+ if gate1 == gate2 == cirq.I:
2092
+ # PauliSum swallows I qubits, so resulting unitaries are dimensionless
2093
+ unitary1 = unitary2 = np.array([[1]])
2094
+ else:
2095
+ unitary1, unitary2 = cirq.unitary(gate1), cirq.unitary(gate2)
2095
2096
  addition = pauli1 + pauli2
2096
2097
  assert isinstance(addition, cirq.PauliSum)
2097
2098
  assert np.array_equal(addition.matrix(), unitary1 + unitary2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20250911180224
3
+ Version: 1.7.0.dev20250915211227
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=TZ4F8lzW_VdtsCJbbO5yLDTDyLfxEbTiLpwlOGvlqHs,1206
8
- cirq/_version_test.py,sha256=ghMi4mZLjN4m73SABwZh9DRcYkaSIH84DwGtlupb_F4,155
7
+ cirq/_version.py,sha256=u2RmkSm_BuozAsCkB9HdSsol3N1sgoBA1gH0FJxl9lc,1206
8
+ cirq/_version_test.py,sha256=ts7jz9x61F91_Gb3KqXmiCwxJN2u_vMWOHQvxqZeoC0,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
@@ -315,7 +315,7 @@ cirq/ops/fsim_gate.py,sha256=Qs7FLsNXR7K2jNVZ8I9o9YLvOb6cC6iBnAvZAHERNk0,20037
315
315
  cirq/ops/fsim_gate_test.py,sha256=QgckC2fij30grZJoO6HnQHdGkKcwtiegedEBRid3wF0,25858
316
316
  cirq/ops/gate_features.py,sha256=OfjsIGftnGpNUDAYwSP4obG0FsMrHYfp49ZOjbvbmNE,1085
317
317
  cirq/ops/gate_features_test.py,sha256=JYPunTBr48CQoIOB1wk2QEdPwtnmE-FxUoF6a4ZeRB8,2407
318
- cirq/ops/gate_operation.py,sha256=ODltw3E7o5ffL2EOTLGj4MUzenBjq6rs_kUVQj4iP0M,13332
318
+ cirq/ops/gate_operation.py,sha256=tyQOHZ_A_kGy6Yzn1fDTkHBNyzyvPmxbnueG6e5yOGM,13632
319
319
  cirq/ops/gate_operation_test.py,sha256=4QwWxCjGXNM__6QGw1kYSbBMh_4783jBZVBJD1ERGPk,18020
320
320
  cirq/ops/gateset.py,sha256=h_lCF6-SeUOprqulklRwBZg77kr_zNG_gvNuvPQc0pg,21786
321
321
  cirq/ops/gateset_test.py,sha256=oeJ0zLgknWxgW39_bc_8Ii_5_g5VNxiJWicZkkS-TaE,17651
@@ -327,7 +327,7 @@ cirq/ops/identity.py,sha256=jWPE3jWLduXF5JgA0qol2blHXRvFUndClukG6nwGvUE,5862
327
327
  cirq/ops/identity_test.py,sha256=doObedJYSIb2v_ZnsL1iBsaRnX8jn5ZriqV8eoOvBzw,8161
328
328
  cirq/ops/kraus_channel.py,sha256=uSLq2AG72zbwzcbiEETFOAZ35KNR9U9KIFO31HYzLKA,5072
329
329
  cirq/ops/kraus_channel_test.py,sha256=FhgCyCKa4bIgGc4yAQbqDKB80910TEVVWRknyyGbILg,4955
330
- cirq/ops/linear_combinations.py,sha256=YNSEAMBhlacvVvXy3MS-36uKlv9By18IWfipG8VLNYk,39886
330
+ cirq/ops/linear_combinations.py,sha256=dqeUgrSN81Bvo8hcx2lg4HRvDuY8gY4rwN294B5w1vw,39370
331
331
  cirq/ops/linear_combinations_test.py,sha256=a-tk0Cd7zhlWXb_o8IrLkabimOqXLgYPJAwNgY8rh7o,68322
332
332
  cirq/ops/matrix_gates.py,sha256=or8Kc3kP1NFjLbAHemmrZIqYFgEeeteMogNVEzYjosk,10238
333
333
  cirq/ops/matrix_gates_test.py,sha256=GEb2QTC2cNTQGVNXCXHL5PstrQLVpFEfQ3eGMZHe8z8,15006
@@ -356,7 +356,7 @@ cirq/ops/pauli_string_phasor.py,sha256=5Tm_OoR_v44Kb3AQAw5XIxpcmKtompdbq5ZefYGEU
356
356
  cirq/ops/pauli_string_phasor_test.py,sha256=ZIoraHH3kOFjtEfThXDS-sxUvSU8MYZ2avtdiPcyN6w,28309
357
357
  cirq/ops/pauli_string_raw_types.py,sha256=mBOAwfBT_y7yiSyC6Hr-ofLyIkjyOH5urmK-gitD3-Y,2226
358
358
  cirq/ops/pauli_string_raw_types_test.py,sha256=ZcOZ31KSVIc7ReZoO8WZEX8MOyPOhUWaYLppvGTE4-8,2761
359
- cirq/ops/pauli_string_test.py,sha256=YoYcJxJZCDJjRx1ULxy_8_PkMsj8wGgpLs71iAVfLmg,79620
359
+ cirq/ops/pauli_string_test.py,sha256=yotnkSxOyV0eVjDGzNs2WGuBu__65miWhx8zW7m4d7A,79618
360
360
  cirq/ops/pauli_sum_exponential.py,sha256=Zq8YBMZ7sLLEPQuoX4uR95I9VY4C38Ma8FtOEjQGr3k,4861
361
361
  cirq/ops/pauli_sum_exponential_test.py,sha256=u9fVBUMuiIb6xOPC2GRTR3zFUeO6N3vanejUk5_u9_8,5485
362
362
  cirq/ops/permutation_gate.py,sha256=mTCKrLSNP3nm2hPebfBJNR5mHO6qb1ZqDT3pFA0zM_M,4218
@@ -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.dev20250911180224.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
- cirq_core-1.7.0.dev20250911180224.dist-info/METADATA,sha256=NYW2hvOgm6hBw-De4z_GhnSIckj3pfADLpcLY4Q0AuQ,4758
1239
- cirq_core-1.7.0.dev20250911180224.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
- cirq_core-1.7.0.dev20250911180224.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
- cirq_core-1.7.0.dev20250911180224.dist-info/RECORD,,
1237
+ cirq_core-1.7.0.dev20250915211227.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
+ cirq_core-1.7.0.dev20250915211227.dist-info/METADATA,sha256=Jq30FYKdJD6WDi-Lqk9m8cjYVMEmKVALgEUrcAfoUNU,4758
1239
+ cirq_core-1.7.0.dev20250915211227.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
+ cirq_core-1.7.0.dev20250915211227.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
+ cirq_core-1.7.0.dev20250915211227.dist-info/RECORD,,