cirq-core 1.6.0.dev20250605164716__py3-none-any.whl → 1.6.0.dev20250609212300__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.dev20250605164716"
31
+ __version__ = "1.6.0.dev20250609212300"
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.dev20250605164716"
6
+ assert cirq.__version__ == "1.6.0.dev20250609212300"
cirq/ops/eigen_gate.py CHANGED
@@ -103,9 +103,15 @@ class EigenGate(raw_types.Gate):
103
103
  `cirq.unitary(cirq.rx(pi))` equals -iX instead of X.
104
104
 
105
105
  Raises:
106
+ TypeError: If the supplied exponent is a string.
106
107
  ValueError: If the supplied exponent is a complex number with an
107
108
  imaginary component.
108
109
  """
110
+ if not isinstance(exponent, (numbers.Number, sympy.Expr)):
111
+ raise TypeError(
112
+ "Gate exponent must be a number or sympy expression. "
113
+ f"Invalid type: {type(exponent).__name__!r}"
114
+ )
109
115
  if isinstance(exponent, complex):
110
116
  if exponent.imag:
111
117
  raise ValueError(f"Gate exponent must be real. Invalid Value: {exponent}")
@@ -286,7 +292,12 @@ class EigenGate(raw_types.Gate):
286
292
  real_periods = [abs(2 / e) for e in exponents if e != 0]
287
293
  return _approximate_common_period(real_periods)
288
294
 
289
- def __pow__(self, exponent: float | sympy.Symbol) -> EigenGate:
295
+ def __pow__(self, exponent: value.TParamVal) -> EigenGate:
296
+ if not isinstance(exponent, (numbers.Number, sympy.Expr)):
297
+ raise TypeError(
298
+ "Gate exponent must be a number or sympy expression. "
299
+ f"Invalid type: {type(exponent).__name__!r}"
300
+ )
290
301
  new_exponent = protocols.mul(self._exponent, exponent, NotImplemented)
291
302
  if new_exponent is NotImplemented:
292
303
  return NotImplemented # pragma: no cover
@@ -248,10 +248,19 @@ def test_pow() -> None:
248
248
  assert ZGateDef(exponent=0.25, global_shift=0.5) ** 2 == ZGateDef(
249
249
  exponent=0.5, global_shift=0.5
250
250
  )
251
- with pytest.raises(ValueError, match="real"):
251
+ with pytest.raises(ValueError, match="Gate exponent must be real."):
252
252
  assert ZGateDef(exponent=0.5) ** 0.5j
253
253
  assert ZGateDef(exponent=0.5) ** (1 + 0j) == ZGateDef(exponent=0.5)
254
254
 
255
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
256
+ assert ZGateDef(exponent=0.5) ** "text"
257
+
258
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
259
+ assert ZGateDef(exponent="text")
260
+
261
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
262
+ assert ZGateDef(exponent=sympy.Symbol('a')) ** "text"
263
+
255
264
 
256
265
  def test_inverse() -> None:
257
266
  assert cirq.inverse(CExpZinGate(0.25)) == CExpZinGate(-0.25)
@@ -225,3 +225,10 @@ def test_powers() -> None:
225
225
  assert isinstance(cirq.X**1, cirq.Pauli)
226
226
  assert isinstance(cirq.Y**1, cirq.Pauli)
227
227
  assert isinstance(cirq.Z**1, cirq.Pauli)
228
+
229
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
230
+ assert cirq.X ** 'text'
231
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
232
+ assert cirq.Y ** 'text'
233
+ with pytest.raises(TypeError, match="Gate exponent must be a number or sympy expression."):
234
+ assert cirq.Z ** 'text'
@@ -222,7 +222,9 @@ def test_noise_applied_measurement_gate():
222
222
  def test_parameterized_copies_all_but_last():
223
223
  sim = CountingSimulator()
224
224
  n = 4
225
- rs = sim.simulate_sweep(cirq.Circuit(cirq.X(q0) ** 'a'), [{'a': i} for i in range(n)])
225
+ rs = sim.simulate_sweep(
226
+ cirq.Circuit(cirq.X(q0) ** sympy.Symbol('a')), [{'a': i} for i in range(n)]
227
+ )
226
228
  for i in range(n):
227
229
  r = rs[i]
228
230
  assert r._final_simulator_state.gate_count == 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250605164716
3
+ Version: 1.6.0.dev20250609212300
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=05AfYsnU6FPiM47YQ_b6tN2hxV67GXD7vkxYT9FOybI,34032
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=3XaC56Xm3dSFyYRjs_VWwqfFqkt0tr12qg8zOow_BYw,1206
8
- cirq/_version_test.py,sha256=F5NTCqm8MNWTvxOrY8SqE7AXRhPtLbiEUrnn1VpE0UA,155
7
+ cirq/_version.py,sha256=CNokdeXiHpaSf09MLWfJr0s3oIlo9ikn1q6BI65RV0Y,1206
8
+ cirq/_version_test.py,sha256=ONdh35jLKEzD_xPUrrlmAUPhjMCbKJie5d6YhL-PFXI,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
@@ -295,8 +295,8 @@ cirq/ops/dense_pauli_string.py,sha256=1TijNu1D2HIbbnwLbT_f546R2L4OCQtm1bKjqhno1K
295
295
  cirq/ops/dense_pauli_string_test.py,sha256=JLfTLO13Qnr9c5jZOPBTJWD4409vm7uV6vi8R7m1kOg,21517
296
296
  cirq/ops/diagonal_gate.py,sha256=HNMxcgKgfZ2ZcXGaPhcBp6yOwu_stpSN3_GtNeWnR5s,8909
297
297
  cirq/ops/diagonal_gate_test.py,sha256=JRQWrL4cEYzVjwal-EewyIPgThUwLdrE6f9i7ifd6Rk,6319
298
- cirq/ops/eigen_gate.py,sha256=BLooTrKX1tJiBjIVMfC1w7LLYbAco78oJW3Z4hcJLrc,17310
299
- cirq/ops/eigen_gate_test.py,sha256=gk0EPzOLY_KEJxVvp6HyDGHGg3ybcbhUtEj1OETaWCA,16444
298
+ cirq/ops/eigen_gate.py,sha256=xO_lVLwTbCjBk7jicYLCmG4waER5OrJ7l0JaONyzLkE,17850
299
+ cirq/ops/eigen_gate_test.py,sha256=3ZN7texyQ_svk8YAaH3liZiGAgq_SBpNb46nIzKYfWM,16909
300
300
  cirq/ops/fourier_transform.py,sha256=JMledJB0tPjLlIlG9bfapJSqass94rXkAheXragQxq8,7455
301
301
  cirq/ops/fourier_transform_test.py,sha256=sX5TfZd9-n1WTyZcqOQ0x6yyI8k6rasywijMo3bc1ls,6426
302
302
  cirq/ops/fsim_gate.py,sha256=xsk5xfEaUTcGeGV852KTuoE7mxlCHEXg2HZlyiszkd0,20035
@@ -334,7 +334,7 @@ cirq/ops/parallel_gate_test.py,sha256=ruFdVnB8PS9LOPQLPZACdf0nh3l-sApQe9bk10EDBJ
334
334
  cirq/ops/parity_gates.py,sha256=hcF2jtrX-ay46UyiXpH9DT-5ihWhGkhN6fH5454FmKA,14289
335
335
  cirq/ops/parity_gates_test.py,sha256=-hnUpof7lKrBz1i06wQ8H3RsIy03gFczaVq3xK8s-HY,11587
336
336
  cirq/ops/pauli_gates.py,sha256=06NzsMKEjBPFUOK6uAKBF5M9vfLOS1owaF7RV_R2Cek,6769
337
- cirq/ops/pauli_gates_test.py,sha256=yotABJBrDgn83VeVOFIRarqU3FKvAWpZ90rqmgEpyPQ,8035
337
+ cirq/ops/pauli_gates_test.py,sha256=EL2NG43h-hlnXcAy54Vz6JrTtUNcT_GY3aH_Hp1ZJsw,8420
338
338
  cirq/ops/pauli_interaction_gate.py,sha256=1drxD57PLCmp7dI9p5oDX2HPzsqwh0rrqHltUjtbWZU,5539
339
339
  cirq/ops/pauli_interaction_gate_test.py,sha256=9IGQjf4cRNe1EAsxVJjTMysoO2TxUhDlp-6lXJuAYD8,4643
340
340
  cirq/ops/pauli_measurement_gate.py,sha256=OzbQeMzr9cHQsai8K-usg3Il74o8gdXZLksLuYr8RcU,7113
@@ -937,7 +937,7 @@ cirq/sim/simulation_utils.py,sha256=KWg_hbVyxhXK7e0r4DF8yHKcYSDmFqRIIxkF_l4O0Qg,
937
937
  cirq/sim/simulation_utils_test.py,sha256=T3fGLpB3OAQtWBA6zuPQH1UlKLqpGR_5DAkxiUyKjGA,1380
938
938
  cirq/sim/simulator.py,sha256=IwFY1865IyqZTvm_AvCVKkCXthrcfqcIjv3H1zYyKxM,41783
939
939
  cirq/sim/simulator_base.py,sha256=YtP27aAGiyqNXyCK1ibKpaNvExyEzZgi-PBr-rFdHjM,18182
940
- cirq/sim/simulator_base_test.py,sha256=agR_nrIS7hqY_Z_GRw_kXfYLW76LjJ6N2nW4SpM_lf4,14951
940
+ cirq/sim/simulator_base_test.py,sha256=ag_1DIA82vEBLrXlwxWBvtobJa9E6SqBT46F6aPZESc,14979
941
941
  cirq/sim/simulator_test.py,sha256=bPcjADGo1AzA5m_zvaap38NJ6n-IGKBRSAVgFmu8-ek,18799
942
942
  cirq/sim/sparse_simulator.py,sha256=d0chp2JPvvcc0DovfmHxPGII4b1wQBPvuh76_VQTv9I,12922
943
943
  cirq/sim/sparse_simulator_test.py,sha256=7P9LEeu6359slpvRJhVW4_gCKSnxpCTQVzpkvB_s0bo,53790
@@ -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.dev20250605164716.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
- cirq_core-1.6.0.dev20250605164716.dist-info/METADATA,sha256=TdzuTTPe4sBLTnS8lP8f1SYOlYTXuZPYiqN-Arj6Rkw,4857
1225
- cirq_core-1.6.0.dev20250605164716.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1226
- cirq_core-1.6.0.dev20250605164716.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
- cirq_core-1.6.0.dev20250605164716.dist-info/RECORD,,
1223
+ cirq_core-1.6.0.dev20250609212300.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
+ cirq_core-1.6.0.dev20250609212300.dist-info/METADATA,sha256=N1VgdjXVP8QefVdL_XPZc6r_Qy8T-IT2xPzCwZLiDMc,4857
1225
+ cirq_core-1.6.0.dev20250609212300.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1226
+ cirq_core-1.6.0.dev20250609212300.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
+ cirq_core-1.6.0.dev20250609212300.dist-info/RECORD,,