ops.SqrtPauliX(0),
 ops.InvSqrtPauliX(0),
 ops.RotateX(0, 0.01),
 ops.RotateY(0, 0.01),
 ops.RotateZ(0, 0.01),
 ops.RotateAroundSphericalAxis(0, 0.01, 0.02, 0.03),
 ops.PragmaSetNumberOfMeasurements(20, 'ro'),
 ops.PragmaSetStateVector(np.array([0, 1], dtype=complex)),
 ops.PragmaSetDensityMatrix(np.array([[0, 0], [0, 1]], dtype=complex)),
 ops.PragmaDamping(0, 0.005, 0.02),
 ops.PragmaDephasing(0, 0.005, 0.02),
 ops.PragmaDepolarising(0, 0.005, 0.02),
 ops.PragmaRandomNoise(0, 0.005, 0.02, 0.01),
 ops.PragmaGeneralNoise(
     0, 0.005, np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=float)),
 ops.PragmaConditional('ro', 0, Circuit()),
 ops.PragmaRepeatGate(3),
 ops.PragmaBoostNoise(0.004),
 ops.PragmaStopParallelBlock([0, 1], 0.002),
 ops.PragmaSleep([0, 1], 0.002),
 ops.PragmaActiveReset(0),
 ops.PragmaGlobalPhase(0.03),
 ops.MeasureQubit(0, 'ro', 0),
 ops.PragmaRepeatedMeasurement('ro', 20, {}),
 ops.PragmaGetStateVector('ro', Circuit()),
 ops.PragmaGetDensityMatrix('ro', Circuit()),
 ops.PragmaGetOccupationProbability('ro', Circuit()),
 ops.PragmaGetPauliProduct({}, 'ro', Circuit()),
 ops.PragmaStartDecompositionBlock([0, 1], {}),
 ops.PragmaStopDecompositionBlock([0, 1]),
 ops.InputSymbolic('other', 0),
def test_conditional_pragma():
    """Test PRAGMA conditional operation"""
    test_dict = {'ro': [False, False],
                 'cond': [True, False]}

    circuit0 = Circuit()
    circuit0 += ops.PauliX(qubit=0)
    circuit0 += ops.MeasureQubit(readout='ro', qubit=0, readout_index=0)

    circuit1 = Circuit()
    circuit1 += ops.PauliX(qubit=1)
    circuit1 += ops.MeasureQubit(readout='ro', qubit=1, readout_index=1)

    operation = ops.PragmaConditional(
        condition_register='cond',
        condition_index=0,
        circuit=circuit0)

    env = utils.createQuestEnv()()
    qureg = utils.createQureg()(2, env)
    test_dict = {'ro': [False, False],
                 'cond': [True, False]}
    pyquest_call_operation(operation=operation,
                           qureg=qureg,
                           classical_bit_registers=test_dict,
                           classical_float_registers=dict(),
                           classical_complex_registers=dict(),
                           output_bit_register_dict=dict(),
                           )

    utils.destroyQureg().call_interactive(qureg, env)
    utils.destroyQuestEnv().call_interactive(env)

    assert test_dict['ro'] == [True, False]

    operation = ops.PragmaConditional(
        condition_register='cond',
        condition_index=0,
        circuit=circuit1)

    env = utils.createQuestEnv()()
    qureg = utils.createQureg()(2, env)
    test_dict = {'ro': [False, False],
                 'cond': [True, False]}
    pyquest_call_operation(operation=operation,
                           qureg=qureg,
                           classical_bit_registers=test_dict,
                           classical_float_registers=dict(),
                           classical_complex_registers=dict(),
                           output_bit_register_dict=dict(),
                           )

    utils.destroyQureg().call_interactive(qureg, env)
    utils.destroyQuestEnv().call_interactive(env)

    assert test_dict['ro'] == [False, True]

    operation = ops.PragmaConditional(
        condition_register='not_in',
        condition_index=0,
        circuit=circuit1)


    env = utils.createQuestEnv()()
    qureg = utils.createQureg()(2, env)
    with pytest.raises(RuntimeError):
        pyquest_call_operation(operation=operation,
                               qureg=qureg,
                               classical_bit_registers=dict(),
                               classical_float_registers=dict(),
                               classical_complex_registers=test_dict,
                               output_bit_register_dict=dict(),
                               )

    utils.destroyQureg().call_interactive(qureg, env)
    utils.destroyQuestEnv().call_interactive(env)