Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Update `QasmUGate` to support symbols in parameters.

Open ArfatSalman opened this issue 2 years ago • 6 comments

Description of the issue assert_circuits_with_terminal_measurements_are_equivalent throws an error when a QasmUGate uses a Symbol parameter.

How to reproduce the issue

import cirq
from sympy import Symbol
from cirq.circuits.qasm_output import QasmUGate
import numpy as np


qr = [cirq.NamedQubit("q" + str(i)) for i in range(5)]

p_96fafa = Symbol("p_96fafa")

circuit = cirq.Circuit()

circuit.append(
    QasmUGate(5.887184334931191 / np.pi, p_96fafa / np.pi, 1.4112277317699358 / np.pi)(
        qr[4]
    )
)


circuit = cirq.resolve_parameters(
    circuit,
    {
        "p_96fafa": 0.07157463504881167,
    },
)

cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent(circuit, circuit)
# TypeError: cirq.apply_unitaries failed. There was a non-unitary value in the `unitary_values` list.

put long logs in details blocks like this

Cirq version You can get the cirq version by printing cirq.__version__. From the command line:

1.1.0

ArfatSalman avatar Jan 22 '23 22:01 ArfatSalman