-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
kind/feature-requestDescribes new functionalityDescribes new functionalitytriage/needs-more-evidence[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet
Description
Is your feature request related to a use case or problem? Please explain
Minimal example:
import cirq
import cirq_google as cg
import tunits as tu
import sympy
q = cirq.q(0, 0)
c = cirq.Circuit(cirq.X(q)** sympy.Symbol("a"))
# !!!!! I know this is not a valid usage case. The point is just for showing the error.!!!
cirq.resolve_parameters(c, {"a": 10*tu.ns})
We will get the following error see that line f = lambda x: x if symbolic(x) else float(x)
File ~/.virtualenvs/pyle3/lib/python3.12/site-packages/cirq/ops/eigen_gate.py:316, in EigenGate._value_equality_values_.<locals>.<lambda>(x)
307 """The phases by which we multiply the eigenspaces.
308
309 The default implementation assumes that the eigenspaces are constant
(...)
313 fields that affect the eigenspaces.
314 """
315 symbolic = lambda x: isinstance(x, sympy.Expr) and x.free_symbols
--> 316 f = lambda x: x if symbolic(x) else float(x)
317 shifts = (f(self._exponent) * f(self._global_shift + e) for e in self._eigen_shifts())
318 return tuple(s if symbolic(s) else value.PeriodicValue(f(s), 2) for s in shifts)
File ~/.virtualenvs/pyle3/lib/python3.12/site-packages/tunits/core/cython/with_unit.pyx:399, in tunits_core.WithUnit.__float__()
UnitMismatchError: '10 ns' can't be stripped into a float; not dimensionless.
Describe the solution you would prefer
Is that possible that we can avoid this casting to float and allow tunit.Value
as another possible case? This can unblock lots of internal gate usages.
How urgent is this for you? Is it blocking important work?
P2 – we should do it in the next couple of quarters
Metadata
Metadata
Assignees
Labels
kind/feature-requestDescribes new functionalityDescribes new functionalitytriage/needs-more-evidence[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet