Esempio n. 1
0
def test_apply_match_shift_phase():
    settings = {FormalArgument("q"): Qubit(0), Parameter("theta"): np.pi}

    instr = ShiftPhase(Frame([FormalArgument("q")], "ff"), Parameter("theta") / (2.0 * np.pi))

    actual = fill_placeholders(instr, settings)

    expected = ShiftPhase(Frame([Qubit(0)], "ff"), 0.5)

    assert actual == expected
Esempio n. 2
0
def SHIFT_PHASE(frame: Frame, phase: ParameterDesignator) -> ShiftPhase:
    """
    Produce a SHIFT-PHASE instruction.

    :param frame: The frame on which to shift the phase.
    :param phase: The value, in radians, to add to the existing phase.
    :returns: A ShiftPhase instance.
    """
    return ShiftPhase(frame, phase)
Esempio n. 3
0
def test_parsing_defcal():
    parse_equals("DEFCAL X 0:\n" "    NOP\n", DefCalibration("X", [], [Qubit(0)], [NOP]))
    parse_equals(
        "DEFCAL X q:\n" "    NOP\n" "    NOP\n",
        DefCalibration("X", [], [FormalArgument("q")], [NOP, NOP]),
    )
    parse_equals(
        "DEFCAL RZ(%theta) 0:\n" '    SHIFT-PHASE 0 "rf" %theta/(-2*pi)\n',
        DefCalibration(
            "RZ",
            [Parameter("theta")],
            [Qubit(0)],
            [ShiftPhase(Frame([Qubit(0)], "rf"), Div(Parameter("theta"), -2 * np.pi))],
        ),
    )