cirq-core 1.7.0.dev20251014004317__py3-none-any.whl → 1.7.0.dev20251015163408__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 +1 -1
- cirq/_version_test.py +1 -1
- cirq/ops/eigen_gate.py +6 -5
- cirq/ops/phased_x_gate.py +2 -2
- cirq/ops/phased_x_z_gate.py +5 -3
- cirq/protocols/resolve_parameters.py +11 -10
- cirq/study/resolver.py +10 -10
- {cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/METADATA +1 -1
- {cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/RECORD +12 -12
- {cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/ops/eigen_gate.py
CHANGED
|
@@ -346,11 +346,12 @@ class EigenGate(raw_types.Gate):
|
|
|
346
346
|
|
|
347
347
|
def _resolve_parameters_(self, resolver: cirq.ParamResolver, recursive: bool) -> EigenGate:
|
|
348
348
|
exponent = resolver.value_of(self._exponent, recursive)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
349
|
+
# Note that int/float checking is purposely done first,
|
|
350
|
+
# since numbers instance checking is somewhat slow.
|
|
351
|
+
if isinstance(exponent, (int, float)) or isinstance(exponent, numbers.Real): # noqa: SIM101
|
|
352
|
+
exponent = float(exponent)
|
|
353
|
+
elif isinstance(exponent, numbers.Complex):
|
|
354
|
+
raise ValueError(f'Complex exponent {exponent} not supported for EigenGate')
|
|
354
355
|
return self._with_exponent(exponent=exponent)
|
|
355
356
|
|
|
356
357
|
def _equal_up_to_global_phase_(self, other, atol):
|
cirq/ops/phased_x_gate.py
CHANGED
|
@@ -176,12 +176,12 @@ class PhasedXPowGate(raw_types.Gate):
|
|
|
176
176
|
"""See `cirq.SupportsParameterization`."""
|
|
177
177
|
phase_exponent = resolver.value_of(self._phase_exponent, recursive)
|
|
178
178
|
exponent = resolver.value_of(self._exponent, recursive)
|
|
179
|
-
if isinstance(phase_exponent, numbers.Complex):
|
|
179
|
+
if not isinstance(phase_exponent, float) and isinstance(phase_exponent, numbers.Complex):
|
|
180
180
|
if isinstance(phase_exponent, numbers.Real):
|
|
181
181
|
phase_exponent = float(phase_exponent)
|
|
182
182
|
else:
|
|
183
183
|
raise ValueError(f'PhasedXPowGate does not support complex value {phase_exponent}')
|
|
184
|
-
if isinstance(exponent, numbers.Complex):
|
|
184
|
+
if not isinstance(exponent, float) and isinstance(exponent, numbers.Complex):
|
|
185
185
|
if isinstance(exponent, numbers.Real):
|
|
186
186
|
exponent = float(exponent)
|
|
187
187
|
else:
|
cirq/ops/phased_x_z_gate.py
CHANGED
|
@@ -231,17 +231,19 @@ class PhasedXZGate(raw_types.Gate):
|
|
|
231
231
|
z_exponent = resolver.value_of(self._z_exponent, recursive)
|
|
232
232
|
x_exponent = resolver.value_of(self._x_exponent, recursive)
|
|
233
233
|
axis_phase_exponent = resolver.value_of(self._axis_phase_exponent, recursive)
|
|
234
|
-
if isinstance(z_exponent, numbers.Complex):
|
|
234
|
+
if not isinstance(z_exponent, float) and isinstance(z_exponent, numbers.Complex):
|
|
235
235
|
if isinstance(z_exponent, numbers.Real):
|
|
236
236
|
z_exponent = float(z_exponent)
|
|
237
237
|
else:
|
|
238
238
|
raise ValueError(f'Complex exponent {z_exponent} not allowed in cirq.PhasedXZGate')
|
|
239
|
-
if isinstance(x_exponent, numbers.Complex):
|
|
239
|
+
if not isinstance(x_exponent, float) and isinstance(x_exponent, numbers.Complex):
|
|
240
240
|
if isinstance(x_exponent, numbers.Real):
|
|
241
241
|
x_exponent = float(x_exponent)
|
|
242
242
|
else:
|
|
243
243
|
raise ValueError(f'Complex exponent {x_exponent} not allowed in cirq.PhasedXZGate')
|
|
244
|
-
if isinstance(axis_phase_exponent,
|
|
244
|
+
if not isinstance(axis_phase_exponent, float) and isinstance(
|
|
245
|
+
axis_phase_exponent, numbers.Complex
|
|
246
|
+
):
|
|
245
247
|
if isinstance(axis_phase_exponent, numbers.Real):
|
|
246
248
|
axis_phase_exponent = float(axis_phase_exponent)
|
|
247
249
|
else:
|
|
@@ -169,14 +169,8 @@ def resolve_parameters(
|
|
|
169
169
|
return val
|
|
170
170
|
|
|
171
171
|
# Ensure it is a dictionary wrapped in a ParamResolver.
|
|
172
|
-
param_resolver
|
|
173
|
-
|
|
174
|
-
# Handle special cases for sympy expressions and sequences.
|
|
175
|
-
# These may not in fact preserve types, but we pretend they do by casting.
|
|
176
|
-
if isinstance(val, sympy.Expr):
|
|
177
|
-
return cast(T, param_resolver.value_of(val, recursive))
|
|
178
|
-
if isinstance(val, (list, tuple)):
|
|
179
|
-
return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val))
|
|
172
|
+
if not isinstance(param_resolver, study.ParamResolver):
|
|
173
|
+
param_resolver = study.ParamResolver(param_resolver)
|
|
180
174
|
|
|
181
175
|
is_parameterized = (
|
|
182
176
|
val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented
|
|
@@ -192,8 +186,15 @@ def resolve_parameters(
|
|
|
192
186
|
|
|
193
187
|
if result is not NotImplemented:
|
|
194
188
|
return result
|
|
195
|
-
|
|
196
|
-
|
|
189
|
+
|
|
190
|
+
# Handle special cases for sympy expressions and sequences.
|
|
191
|
+
# These may not in fact preserve types, but we pretend they do by casting.
|
|
192
|
+
if isinstance(val, sympy.Expr):
|
|
193
|
+
return cast(T, param_resolver.value_of(val, recursive))
|
|
194
|
+
if isinstance(val, (list, tuple)):
|
|
195
|
+
return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val))
|
|
196
|
+
|
|
197
|
+
return val
|
|
197
198
|
|
|
198
199
|
|
|
199
200
|
def resolve_parameters_once(val: T, param_resolver: cirq.ParamResolverOrSimilarType) -> T:
|
cirq/study/resolver.py
CHANGED
|
@@ -118,21 +118,16 @@ class ParamResolver:
|
|
|
118
118
|
sympy.SympifyError: If the resulting value cannot be interpreted.
|
|
119
119
|
"""
|
|
120
120
|
|
|
121
|
-
# Input is a pass through type, no resolution needed: return early
|
|
122
|
-
v = _resolve_value(value)
|
|
123
|
-
if v is not NotImplemented:
|
|
124
|
-
return v
|
|
125
|
-
|
|
126
121
|
# Handle string or symbol
|
|
127
122
|
if isinstance(value, (str, sympy.Symbol)):
|
|
128
123
|
string = value if isinstance(value, str) else value.name
|
|
129
|
-
symbol = value if isinstance(value, sympy.Symbol) else sympy.Symbol(value)
|
|
130
124
|
param_value = self._param_dict.get(string, _NOT_FOUND)
|
|
131
125
|
if param_value is _NOT_FOUND:
|
|
126
|
+
symbol = value if isinstance(value, sympy.Symbol) else sympy.Symbol(value)
|
|
132
127
|
param_value = self._param_dict.get(symbol, _NOT_FOUND)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
if param_value is _NOT_FOUND:
|
|
129
|
+
# Symbol or string cannot be resolved if not in param dict; return as symbol.
|
|
130
|
+
return symbol
|
|
136
131
|
v = _resolve_value(param_value)
|
|
137
132
|
if v is not NotImplemented:
|
|
138
133
|
return v
|
|
@@ -144,6 +139,11 @@ class ParamResolver:
|
|
|
144
139
|
param_value = self._value_of_recursive(value)
|
|
145
140
|
return param_value
|
|
146
141
|
|
|
142
|
+
# Input is a pass through type, no resolution needed: return early
|
|
143
|
+
v = _resolve_value(value)
|
|
144
|
+
if v is not NotImplemented:
|
|
145
|
+
return v
|
|
146
|
+
|
|
147
147
|
if not isinstance(value, sympy.Basic):
|
|
148
148
|
# No known way to resolve this variable, return unchanged.
|
|
149
149
|
return value
|
|
@@ -278,7 +278,7 @@ class ParamResolver:
|
|
|
278
278
|
|
|
279
279
|
|
|
280
280
|
def _resolve_value(val: Any) -> Any:
|
|
281
|
-
if val is None:
|
|
281
|
+
if val is None or isinstance(val, float):
|
|
282
282
|
return val
|
|
283
283
|
if isinstance(val, numbers.Number) and not isinstance(val, sympy.Basic):
|
|
284
284
|
return val
|
{cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.7.0.
|
|
3
|
+
Version: 1.7.0.dev20251015163408
|
|
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
|
{cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
|
|
|
4
4
|
cirq/_doc.py,sha256=28ZskY9ZtZ_4GS1oXPUgklKnJqmAE-rkUfzcsJ0--nA,2941
|
|
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=
|
|
8
|
-
cirq/_version_test.py,sha256
|
|
7
|
+
cirq/_version.py,sha256=c5ZeIHOWJZrUCXn3gn88r-qLqp9FbzhrJIJP_wqwDwM,1206
|
|
8
|
+
cirq/_version_test.py,sha256=-pmMHgmLb0_cTfy7ToIGkWjXExGEO1H8isgOEKdV-BA,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
|
|
@@ -312,7 +312,7 @@ cirq/ops/dense_pauli_string.py,sha256=sRf2O62YXSedbOYyKSfS5qQbTaunC6BH6AobmX72nP
|
|
|
312
312
|
cirq/ops/dense_pauli_string_test.py,sha256=t4kl_8QdXnAbM3Bs-RpO-_fjtGZ1LSRl1UbXWJMX8Kc,23159
|
|
313
313
|
cirq/ops/diagonal_gate.py,sha256=HNMxcgKgfZ2ZcXGaPhcBp6yOwu_stpSN3_GtNeWnR5s,8909
|
|
314
314
|
cirq/ops/diagonal_gate_test.py,sha256=JRQWrL4cEYzVjwal-EewyIPgThUwLdrE6f9i7ifd6Rk,6319
|
|
315
|
-
cirq/ops/eigen_gate.py,sha256=
|
|
315
|
+
cirq/ops/eigen_gate.py,sha256=A8WcBS3AVCbZ3KcJ2f39liCMOn59uhmTn4h0sSzxDyw,17938
|
|
316
316
|
cirq/ops/eigen_gate_test.py,sha256=k48rIbYKUErElQBfiV8cNGcKRnO6_vSJtghDxm-rflA,16772
|
|
317
317
|
cirq/ops/fourier_transform.py,sha256=JMledJB0tPjLlIlG9bfapJSqass94rXkAheXragQxq8,7455
|
|
318
318
|
cirq/ops/fourier_transform_test.py,sha256=fum4Kyxqb8AcAsELZsZcmkzbyzB7zf3cH1b32R5LFQ4,6331
|
|
@@ -368,9 +368,9 @@ cirq/ops/permutation_gate.py,sha256=mTCKrLSNP3nm2hPebfBJNR5mHO6qb1ZqDT3pFA0zM_M,
|
|
|
368
368
|
cirq/ops/permutation_gate_test.py,sha256=HgXqFoDbhl0EcFbpr0Lj7dA0UxleQ_m_JZ96HfdCZyc,3381
|
|
369
369
|
cirq/ops/phased_iswap_gate.py,sha256=AQIPHurGVx4ccinrT8UZc9bZT9yX53Q4PlBk4uaqrGw,8939
|
|
370
370
|
cirq/ops/phased_iswap_gate_test.py,sha256=hRcyf2QHCExKO-XmZ9_2TV8DePBESEgM-CEB5bn-ZfY,7516
|
|
371
|
-
cirq/ops/phased_x_gate.py,sha256=
|
|
371
|
+
cirq/ops/phased_x_gate.py,sha256=fShc7xTIY6dnVmc6iC7L7XId1yDHLiE_iCzm5oQdKxg,9325
|
|
372
372
|
cirq/ops/phased_x_gate_test.py,sha256=lQ6UV9X52joByV_SLzNceO785uVY5wSqlba8tMpzHSA,10976
|
|
373
|
-
cirq/ops/phased_x_z_gate.py,sha256=
|
|
373
|
+
cirq/ops/phased_x_z_gate.py,sha256=fQmWXhqH9xISfTeLUA9scLsvnVD3jTA4wKDpj2P8EVI,11591
|
|
374
374
|
cirq/ops/phased_x_z_gate_test.py,sha256=ZmV0NdJJMzile88bRHYGYPXxOP785fW_Tn4tCxbphPY,10876
|
|
375
375
|
cirq/ops/projector.py,sha256=xxt3YhomvLfQjFWlU7yeKHTbPlgBHGQUcfiSbMxlIQk,5645
|
|
376
376
|
cirq/ops/projector_test.py,sha256=vphfIBPkrEPXj4I6B_IPM84wOW-DsETSR9ua4lDioF4,9232
|
|
@@ -447,7 +447,7 @@ cirq/protocols/qasm.py,sha256=njxlAUNwzQfyZXn3Uwk4z6HvcXb6vgcRsRpFRLTNutY,7186
|
|
|
447
447
|
cirq/protocols/qasm_test.py,sha256=HirWOanvVpqd9aT9s8etKBvfjbEKfpnro8Vyrq7WELc,2277
|
|
448
448
|
cirq/protocols/qid_shape_protocol.py,sha256=JTzhzsz_hNe7QYMLSoJbLacolXj8WrtF5_3Xim_mctc,7652
|
|
449
449
|
cirq/protocols/qid_shape_protocol_test.py,sha256=qCocF8pVb6U27lnHJiRkRRDQSgA59KvwXr6RxGEixXI,2347
|
|
450
|
-
cirq/protocols/resolve_parameters.py,sha256=
|
|
450
|
+
cirq/protocols/resolve_parameters.py,sha256=5E2PzG317AdSeYXwu8lNj3PT7xNu3px_-sZsljgl3Ys,7453
|
|
451
451
|
cirq/protocols/resolve_parameters_test.py,sha256=2R2T2p4NkbD4IV2_4i8WkvSHu3OqjXo-Bf856Rwb-3w,4933
|
|
452
452
|
cirq/protocols/trace_distance_bound.py,sha256=xF_qfkFV_T7O3-5lBITupq6ulBYuzFXDHaYDv7it96E,4150
|
|
453
453
|
cirq/protocols/trace_distance_bound_test.py,sha256=0bI9uYttJj5eayM05kShPh9qkxeKG1egcZ9fXJPZWNU,1980
|
|
@@ -982,7 +982,7 @@ cirq/sim/clifford/stabilizer_state_ch_form_test.py,sha256=UuvgpwexGB5LzMfaa3Gws2
|
|
|
982
982
|
cirq/study/__init__.py,sha256=OyJhZjBiEkNbtSuSZaOwHGwwnOIGgnn-W8ec0xHhHBI,1647
|
|
983
983
|
cirq/study/flatten_expressions.py,sha256=q9U-AukDri63yC4pF_dEKCX81RfquK4z31ktLkL0gz0,15528
|
|
984
984
|
cirq/study/flatten_expressions_test.py,sha256=ONYcsFoL7Re7IsySwXgnnIlrWCuUu1ds2f90-2uNj1c,6202
|
|
985
|
-
cirq/study/resolver.py,sha256=
|
|
985
|
+
cirq/study/resolver.py,sha256=KDaG4kK3iO3Y3DFgEZZpKi4Lnco9sKSHm-xydMbP6X4,11789
|
|
986
986
|
cirq/study/resolver_test.py,sha256=LY1h8RCPY4d_8O5hprRcIf3HFhzODQrMbUrmwmt1fbM,10727
|
|
987
987
|
cirq/study/result.py,sha256=ci9Pg9IW4OMR4aZ4SaQ7TPVTgoSU-1WarjKEXBv2F2g,19214
|
|
988
988
|
cirq/study/result_test.py,sha256=VdzUNYcyIwFmoaaj9Ahi8jzepwH3TrN4JEY-JHECgBs,15805
|
|
@@ -1244,8 +1244,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
|
|
|
1244
1244
|
cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
|
|
1245
1245
|
cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
|
|
1246
1246
|
cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
|
|
1247
|
-
cirq_core-1.7.0.
|
|
1248
|
-
cirq_core-1.7.0.
|
|
1249
|
-
cirq_core-1.7.0.
|
|
1250
|
-
cirq_core-1.7.0.
|
|
1251
|
-
cirq_core-1.7.0.
|
|
1247
|
+
cirq_core-1.7.0.dev20251015163408.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1248
|
+
cirq_core-1.7.0.dev20251015163408.dist-info/METADATA,sha256=gOS7HmBv-_0l_iUcbO_zbpQZdLLSQQz4F4HazS4JPLU,4757
|
|
1249
|
+
cirq_core-1.7.0.dev20251015163408.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1250
|
+
cirq_core-1.7.0.dev20251015163408.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1251
|
+
cirq_core-1.7.0.dev20251015163408.dist-info/RECORD,,
|
{cirq_core-1.7.0.dev20251014004317.dist-info → cirq_core-1.7.0.dev20251015163408.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|