def test_parametric_quil():
    """Convert a program which uses parameters and expressions."""
    program = Program(QUIL_PROGRAM_WITH_PARAMETERS)

    circuit = circuit_from_quil(program)

    q0, q1, q2, q3, q4 = LineQubit.range(5)
    theta_0, theta_1, theta_2, theta_3 = (
        sympy.Symbol("theta_0"),
        sympy.Symbol("theta_1"),
        sympy.Symbol("theta_2"),
        sympy.Symbol("theta_3"),
    )
    cirq_circuit = Circuit(
        [
            XPowGate(exponent=1, global_shift=-0.5)(q0),
            XPowGate(exponent=theta_0 / np.pi, global_shift=-0.5)(q1),
            XPowGate(exponent=(2 / np.pi) * theta_1, global_shift=-0.5)(q3),
            XPowGate(exponent=(2 / np.pi) * theta_2 + 1 / np.pi, global_shift=-0.5)(q2),
            XPowGate(
                exponent=(2 / np.pi) * sympy.cos(theta_3) * sympy.exp(1j * theta_3),
                global_shift=-0.5,
            )(q4),
        ]
    )

    assert cirq_circuit == circuit
Convert a program which uses parameters and expressions.
cirq-rigetti/cirq_rigetti/quil_input_test.py