Cirq
Cirq copied to clipboard
cirq.X**"text" half works
To my surprise, if you write cirq.X**"text"
instead of cirq.X**sympy.Symbol("text")
, thing mostly work. For example, you can run a sweep over the circuit with a dictionary mapping "text"
to a value and you'll get samples back. This is because cirq.resolve_parameters
treats strings as a shorthand for sympy.Symbol
, as a way of removing boilerplate when specifying sweeps.
However, cirq.is_parameterized
often does not recognize gates with string parameters as being parameterized. For example it fails on the case I gave above.
I think treating strings as implicitly being symbols is a reasonable idea, and I propose we codify this. Fixing it would involve finding all places with isinstance sympy.Basic
checks and replacing them with is_parameterized
calls, and then is_parameterized
would also handle the string case.
Hey, I would like to work on this issue!
I like the idea, don't see a reason why not. Should be relatively straightforward to implement. @MrSaral did you take a crack at this?
Hey @balopat , yes I am working on this! Are you on the discord channel?
@MrSaral, did you mean Gitter? yeah, I tend to hangout there!
This is a feature addition and doesn't require changes to the existing API (exponentiating with symbols), so marking as after-1.0.