Skip to content

cirq.X**"text" half works #2936

Open
@Strilanc

Description

@Strilanc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/parametersparameter resolution, parameterized gates, operationscomplexity/lowintroduces/modifies 1-2 concepts, should take 1-2 days max for an advanced contributorgood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onunitaryhack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions