def test_parse_pulse(): wf = FlatWaveform(duration=1.0, iq=1.0) parse_equals('PULSE 0 "rf" flat(duration: 1.0, iq: 1.0)', Pulse(Frame([Qubit(0)], "rf"), wf)) parse_equals('PULSE 0 1 "ff" flat(duration: 1.0, iq: 1.0)', Pulse(Frame([Qubit(0), Qubit(1)], "ff"), wf)) parse_equals( 'NONBLOCKING PULSE 0 "rf" flat(duration: 1.0, iq: 1.0)', Pulse(Frame([Qubit(0)], "rf"), wf, nonblocking=True), )
def PULSE(frame: Frame, waveform: Waveform, nonblocking: bool = False) -> Pulse: """ Produce a PULSE instruction. :param frame: The frame on which to apply the pulse. :param waveform: The pulse waveform. :param nonblocking: A flag indicating whether the pulse is NONBLOCKING. :return: A Pulse instance. """ return Pulse(frame, waveform, nonblocking)
def test_parsing_defcal_measure(): parse_equals("DEFCAL MEASURE 0:\n" " NOP\n", DefMeasureCalibration(Qubit(0), None, [NOP])) wf = FlatWaveform(duration=1.0, iq=1.0) # TODO: note that in a calibration body, reference to the formal argument addr parses # as a memoryreference. parse_equals( "DEFCAL MEASURE q addr:\n" ' PULSE q "ro_tx" flat(duration: 1.0, iq: 1.0+0.0*i)\n' ' CAPTURE q "ro_rx" flat(duration: 1.0, iq: 1.0+0*i) addr[0]\n', DefMeasureCalibration( FormalArgument("q"), FormalArgument("addr"), [ Pulse(Frame([FormalArgument("q")], "ro_tx"), wf), Capture(Frame([FormalArgument("q")], "ro_rx"), wf, MemoryReference("addr")), ], ), )
def pulse(self, nonblocking, frame, waveform): p = Pulse(frame, waveform, nonblocking=bool(nonblocking)) return p
def wf_agrees(wf_str: str, wf: TemplateWaveform): frame = Frame([Qubit(0)], "rf") pulse_str = 'PULSE 0 "rf" ' + wf_str parse_equals(pulse_str, Pulse(frame, wf))