Skip to content

Commit f218eef

Browse files
committed
Add AnalogDetuneQubit cirq google version (#7430)
In order to keep using unit-style input, I have hacked the _resolve_parameters_ function a little bit. Assume all inputs should either be tunit value or sympy.Symbol. (I.e. no sympy expression is allowed). I have to add this since we don't have SymbolFunc or ExprFunc in cirq world.
1 parent f0c4f50 commit f218eef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cirq-google/cirq_google/experimental/analog_experiments/symbol_util.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import TypeAlias, AbstractSet
1+
from typing import AbstractSet, TypeAlias
22

3-
import cirq
43
import sympy
54
import tunits as tu
65

6+
import cirq
77

88
# The gate is intended for the google internal use, hence the typing style
99
# follows more on the t-unit + symbol instead of float + symbol style.
@@ -12,6 +12,7 @@
1212
# A sentile for not finding the key in resolver.
1313
NOT_FOUND = "__NOT_FOUND__"
1414

15+
1516
def direct_symbol_replacement(x, resolver: cirq.ParamResolver):
1617
"""A shortcut for value resolution to avoid tu.unit compare with float issue."""
1718
if isinstance(x, sympy.Symbol):
@@ -23,14 +24,16 @@ def direct_symbol_replacement(x, resolver: cirq.ParamResolver):
2324
return x # pragma: no cover
2425
return x
2526

27+
2628
def dict_param_name(dict_with_value: dict[str, ValueOrSymbol] | None) -> AbstractSet[str]:
2729
"""Find the names of all parameterized value in a dictionary."""
2830
if dict_with_value is None:
2931
return set()
3032
return {v.name for v in dict_with_value.values() if cirq.is_parameterized(v)}
31-
33+
34+
3235
def is_parameterized_dict(dict_with_value: dict[str, ValueOrSymbol] | None) -> bool:
3336
"""Check if any values in the dictionary is parameterized."""
3437
if dict_with_value is None:
3538
return False # pragma: no cover
36-
return any(cirq.is_parameterized(v) for v in dict_with_value.values())
39+
return any(cirq.is_parameterized(v) for v in dict_with_value.values())

0 commit comments

Comments
 (0)