Exemplo n.º 1
0
 def test_drag_roundtrip_serializable(self):
     """Test round trip JSON serialization"""
     with pulse.build(name="xp") as sched:
         pulse.play(pulse.Drag(160, 0.5, 40, Parameter("β")),
                    pulse.DriveChannel(0))
     exp = RoughDrag(0, backend=self.backend, schedule=sched)
     self.assertRoundTripSerializable(exp, self.json_equiv)
Exemplo n.º 2
0
    def test_transpiled_custom_gates_calibration(self):
        """Test if transpiled calibrations is equal to custom gates circuit calibrations."""
        custom_180 = Gate("mycustom", 1, [3.14])
        custom_90 = Gate("mycustom", 1, [1.57])

        circ = QuantumCircuit(2)
        circ.append(custom_180, [0])
        circ.append(custom_90, [1])

        with pulse.build() as q0_x180:
            pulse.play(pulse.library.Gaussian(20, 1.0, 3.0),
                       pulse.DriveChannel(0))
        with pulse.build() as q1_y90:
            pulse.play(pulse.library.Gaussian(20, -1.0, 3.0),
                       pulse.DriveChannel(1))

        # Add calibration
        circ.add_calibration(custom_180, [0], q0_x180)
        circ.add_calibration(custom_90, [1], q1_y90)

        backend = FakeAlmaden()
        transpiled_circuit = transpile(
            circ,
            backend=backend,
        )
        self.assertEqual(transpiled_circuit.calibrations, circ.calibrations)
        self.assertEqual(list(transpiled_circuit.count_ops().keys()),
                         ['mycustom'])
        self.assertEqual(list(transpiled_circuit.count_ops().values()), [2])
Exemplo n.º 3
0
    def test_ef_circuits(self):
        """Test that we get the expected circuits with calibrations for the EF experiment."""

        test_amps = [-0.5, 0, 0.5]
        rabi_ef = EFRoughXSXAmplitudeCal(0, self.cals, amplitudes=test_amps)

        circs = transpile(rabi_ef.circuits(),
                          self.backend,
                          inst_map=rabi_ef.transpile_options.inst_map)

        for circ, amp in zip(circs, test_amps):

            self.assertEqual(circ.count_ops()["x"], 1)
            self.assertEqual(circ.count_ops()["Rabi"], 1)

            d0 = pulse.DriveChannel(0)
            with pulse.build(name="x") as expected_x:
                pulse.play(pulse.Drag(160, 0.5, 40, 0), d0)

            with pulse.build(name="x12") as expected_x12:
                with pulse.frequency_offset(-300e6, d0):
                    pulse.play(pulse.Drag(160, amp, 40, 0), d0)

            self.assertEqual(circ.calibrations["x"][((0, ), ())], expected_x)
            self.assertEqual(circ.calibrations["Rabi"][((0, ), (amp, ))],
                             expected_x12)
    def test_instruction_schedule_map_export(self):
        """Test that exporting the inst map works as planned."""

        backend = FakeBelem()

        cals = BackendCalibrations(
            backend,
            library=FixedFrequencyTransmon(basis_gates=["sx"]),
        )

        u_chan = pulse.ControlChannel(Parameter("ch0.1"))
        with pulse.build(name="cr") as cr:
            pulse.play(pulse.GaussianSquare(640, 0.5, 64, 384), u_chan)

        cals.add_schedule(cr, num_qubits=2)
        cals.update_inst_map({"cr"})

        for qubit in range(backend.configuration().num_qubits):
            self.assertTrue(cals.default_inst_map.has("sx", (qubit,)))

        # based on coupling map of Belem to keep the test robust.
        expected_pairs = [(0, 1), (1, 0), (1, 2), (2, 1), (1, 3), (3, 1), (3, 4), (4, 3)]
        coupling_map = set(tuple(pair) for pair in backend.configuration().coupling_map)

        for pair in expected_pairs:
            self.assertTrue(pair in coupling_map)
            self.assertTrue(cals.default_inst_map.has("cr", pair), pair)
Exemplo n.º 5
0
    def test_run_sx_cal(self):
        """Test that we can transpile in the calibrations before and after update.

        If this test passes then we were successful in running a calibration experiment,
        updating a pulse parameter, having this parameter propagated to the schedules
        for use the next time the experiment is run.
        """

        # Initial pulse amplitude
        init_amp = 0.25

        amp_cal = FineSXAmplitudeCal(0, self.cals, "sx")

        circs = transpile(amp_cal.circuits(), self.backend, inst_map=self.cals.default_inst_map)

        with pulse.build(name="sx") as expected_sx:
            pulse.play(pulse.Drag(160, 0.25, 40, 0), pulse.DriveChannel(0))

        self.assertEqual(circs[5].calibrations["sx"][((0,), ())], expected_sx)

        # run the calibration experiment. This should update the amp parameter of x which we test.
        exp_data = amp_cal.run(MockIQBackend(FineAmpHelper(-np.pi * 0.07, np.pi / 2, "sx")))
        self.assertExperimentDone(exp_data)
        d_theta = exp_data.analysis_results(1).value.n
        new_amp = init_amp * (np.pi / 2) / (np.pi / 2 + d_theta)

        circs = transpile(amp_cal.circuits(), self.backend, inst_map=self.cals.default_inst_map)

        sx_cal = circs[5].calibrations["sx"][((0,), ())]

        # Requires allclose due to numerical precision.
        self.assertTrue(np.allclose(sx_cal.blocks[0].pulse.amp, new_amp))
        self.assertFalse(np.allclose(sx_cal.blocks[0].pulse.amp, init_amp))
Exemplo n.º 6
0
    def test_calibrations_with_control_gates(self):
        """Test calibrations annotations
        See https://github.com/Qiskit/qiskit-terra/issues/5920
        """

        circuit = QuantumCircuit(2, 2)
        circuit.cx(0, 1)
        circuit.ch(0, 1)

        from qiskit import pulse

        with pulse.build(name="cnot") as cx_q01:
            pulse.play(pulse.library.Gaussian(duration=128, amp=0.1, sigma=16),
                       pulse.DriveChannel(1))

        circuit.add_calibration("cx", [0, 1], cx_q01)

        with pulse.build(name="ch") as ch_q01:
            pulse.play(pulse.library.Gaussian(duration=128, amp=0.1, sigma=16),
                       pulse.DriveChannel(1))

        circuit.add_calibration("ch", [0, 1], ch_q01)

        self.circuit_drawer(circuit,
                            filename="calibrations_with_control_gates.png")
    def test_dd_with_calibrations_with_parameters(self, param_value):
        """Check that calibrations in a circuit with parameters work fine."""

        circ = QuantumCircuit(2)
        circ.x(0)
        circ.cx(0, 1)
        circ.rx(param_value, 1)

        rx_duration = int(param_value * 1000)

        with pulse.build() as rx:
            pulse.play(pulse.Gaussian(rx_duration, 0.1, rx_duration // 4),
                       pulse.DriveChannel(1))

        circ.add_calibration("rx", (1, ), rx, params=[param_value])

        durations = InstructionDurations([("x", None, 100), ("cx", None, 300)])

        dd_sequence = [XGate(), XGate()]
        pm = PassManager([
            ALAPScheduleAnalysis(durations),
            PadDynamicalDecoupling(durations, dd_sequence)
        ])

        self.assertEqual(pm.run(circ).duration, rx_duration + 100 + 300)
Exemplo n.º 8
0
    def test_calibrations_with_swap_and_reset(self):
        """Test calibrations annotations
        See https://github.com/Qiskit/qiskit-terra/issues/5920
        """

        circuit = QuantumCircuit(2, 2)
        circuit.swap(0, 1)
        circuit.reset(0)

        from qiskit import pulse

        with pulse.build(name="swap") as swap_q01:
            pulse.play(pulse.library.Gaussian(duration=128, amp=0.1, sigma=16),
                       pulse.DriveChannel(1))

        circuit.add_calibration("swap", [0, 1], swap_q01)

        with pulse.build(name="reset") as reset_q0:
            pulse.play(pulse.library.Gaussian(duration=128, amp=0.1, sigma=16),
                       pulse.DriveChannel(1))

        circuit.add_calibration("reset", [0], reset_q0)

        self.circuit_drawer(circuit,
                            filename="calibrations_with_swap_and_reset.png")
    def _schedule(self) -> Tuple[pulse.ScheduleBlock, Parameter]:
        """Create the spectroscopy schedule."""

        dt, granularity = self._dt, self._granularity

        duration = int(granularity *
                       (self.experiment_options.duration / dt // granularity))
        sigma = granularity * (self.experiment_options.sigma / dt //
                               granularity)
        width = granularity * (self.experiment_options.width / dt //
                               granularity)

        qubit = self.physical_qubits[0]

        freq_param = Parameter("frequency")

        with pulse.build(backend=self.backend,
                         name="spectroscopy") as schedule:
            pulse.shift_frequency(freq_param, pulse.MeasureChannel(qubit))
            pulse.play(
                pulse.GaussianSquare(
                    duration=duration,
                    amp=self.experiment_options.amp,
                    sigma=sigma,
                    width=width,
                ),
                pulse.MeasureChannel(qubit),
            )
            pulse.acquire(duration, qubit, pulse.MemorySlot(0))

        return schedule, freq_param
Exemplo n.º 10
0
    def test_disassemble_single_schedule(self):
        """Test disassembling a single schedule.
        """
        d0 = pulse.DriveChannel(0)
        d1 = pulse.DriveChannel(1)
        with pulse.build(self.backend) as sched:
            with pulse.align_right():
                pulse.play(pulse.library.Constant(10, 1.0), d0)
                pulse.set_phase(1.0, d0)
                pulse.shift_phase(3.11, d0)
                pulse.set_frequency(1e9, d0)
                pulse.shift_frequency(1e7, d0)
                pulse.delay(20, d0)
                pulse.delay(10, d1)
                pulse.play(pulse.library.Constant(8, 0.1), d1)
                pulse.measure_all()

        qobj = assemble(sched, backend=self.backend, shots=2000)
        scheds, run_config_out, _ = disassemble(qobj)
        run_config_out = RunConfig(**run_config_out)
        self.assertEqual(run_config_out.memory_slots, 2)
        self.assertEqual(run_config_out.shots, 2000)
        self.assertEqual(run_config_out.memory, False)
        self.assertEqual(run_config_out.meas_level, 2)
        self.assertEqual(run_config_out.meas_lo_freq,
                         self.backend.defaults().meas_freq_est)
        self.assertEqual(run_config_out.qubit_lo_freq,
                         self.backend.defaults().qubit_freq_est)
        self.assertEqual(run_config_out.rep_time, 99)
        self.assertEqual(len(scheds), 1)
        self.assertEqual(scheds[0], sched)
Exemplo n.º 11
0
    def test_calibrations(self):
        """Test that the calibrations are preserved and that the circuit transpiles."""

        experiments = []
        for qubit in range(3):
            with pulse.build() as sched:
                pulse.play(pulse.Gaussian(160, Parameter("amp"), 40),
                           pulse.DriveChannel(qubit))

            experiments.append(Rabi(qubit, sched, amplitudes=[0.5]))

        par_exp = ParallelExperiment(experiments)
        par_circ = par_exp.circuits()[0]

        # If the calibrations are not there we will not be able to transpile
        try:
            transpile(par_circ, basis_gates=["rz", "sx", "x", "cx"])
        except QiskitError as error:
            self.fail("Failed to transpile with error: " + str(error))

        # Assert that the calibration keys are in the calibrations of the composite circuit.
        for qubit in range(3):
            rabi_circuit = experiments[qubit].circuits()[0]
            cal_key = next(iter(rabi_circuit.calibrations["Rabi"].keys()))

            self.assertEqual(cal_key[0], (qubit, ))
            self.assertTrue(cal_key in par_circ.calibrations["Rabi"])
Exemplo n.º 12
0
    def test_parametric_pulse_circuit_calibrations(self):
        """Test that disassembler parses parametric pulses back to pulse gates."""
        with pulse.build() as h_sched:
            pulse.play(pulse.library.Drag(50, 0.15, 4, 2), pulse.DriveChannel(0))

        qc = QuantumCircuit(2)
        qc.h(0)
        qc.add_calibration("h", [0], h_sched)

        backend = FakeOpenPulse2Q()
        backend.configuration().parametric_pulses = ["drag"]

        qobj = assemble(qc, backend)
        output_circuits, _, _ = disassemble(qobj)
        out_qc = output_circuits[0]

        self.assertCircuitCalibrationsEqual([qc], output_circuits)
        self.assertTrue(
            all(
                qc_sched.instructions == out_qc_sched.instructions
                for (_, qc_gate), (_, out_qc_gate) in zip(
                    qc.calibrations.items(), out_qc.calibrations.items()
                )
                for qc_sched, out_qc_sched in zip(qc_gate.values(), out_qc_gate.values())
            ),
        )
    def test_calibrations_basis_gates(self):
        """Check if the calibrations for basis gates provided are added correctly."""
        circ = QuantumCircuit(2)

        with pulse.build() as q0_x180:
            pulse.play(pulse.library.Gaussian(20, 1.0, 3.0),
                       pulse.DriveChannel(0))
        with pulse.build() as q1_y90:
            pulse.play(pulse.library.Gaussian(20, -1.0, 3.0),
                       pulse.DriveChannel(1))

        # Add calibration
        circ.add_calibration(RXGate(3.14), [0], q0_x180)
        circ.add_calibration(RYGate(1.57), [1], q1_y90)

        self.assertEqual(set(circ.calibrations.keys()), {"rx", "ry"})
        self.assertEqual(set(circ.calibrations["rx"].keys()),
                         {((0, ), (3.14, ))})
        self.assertEqual(set(circ.calibrations["ry"].keys()),
                         {((1, ), (1.57, ))})
        self.assertEqual(
            circ.calibrations["rx"][((0, ), (3.14, ))].instructions,
            q0_x180.instructions)
        self.assertEqual(
            circ.calibrations["ry"][((1, ), (1.57, ))].instructions,
            q1_y90.instructions)
Exemplo n.º 14
0
    def test_transpiled_custom_gates_calibration(self):
        """Test if transpiled calibrations is equal to custom gates circuit calibrations."""
        custom_180 = Gate("mycustom", 1, [3.14])
        custom_90 = Gate("mycustom", 1, [1.57])

        circ = QuantumCircuit(2)
        circ.append(custom_180, [0])
        circ.append(custom_90, [1])

        with pulse.build() as q0_x180:
            pulse.play(pulse.library.Gaussian(20, 1.0, 3.0),
                       pulse.DriveChannel(0))
        with pulse.build() as q1_y90:
            pulse.play(pulse.library.Gaussian(20, -1.0, 3.0),
                       pulse.DriveChannel(1))

        # Add calibration
        circ.add_calibration(custom_180, [0], q0_x180)
        circ.add_calibration(custom_90, [1], q1_y90)

        backend = FakeAlmaden()
        # TODO: Remove L783-L784 in the next PR
        transpiled_circuit = transpile(
            circ,
            backend=backend,
            basis_gates=backend.configuration().basis_gates +
            list(circ.calibrations.keys()),
        )
        self.assertEqual(transpiled_circuit.calibrations, circ.calibrations)
    def test_calibrations_with_rzz_and_rxx(self):
        """Test calibrations annotations
        See https://github.com/Qiskit/qiskit-terra/issues/5920
        """
        circuit = QuantumCircuit(2, 2)
        circuit.rzz(pi, 0, 1)
        circuit.rxx(pi, 0, 1)

        from qiskit import pulse

        with pulse.build(name="rzz") as rzz_q01:
            pulse.play(
                pulse.library.Gaussian(duration=128, amp=0.1, sigma=16), pulse.DriveChannel(1)
            )

        circuit.add_calibration("rzz", [0, 1], rzz_q01)

        with pulse.build(name="rxx") as rxx_q01:
            pulse.play(
                pulse.library.Gaussian(duration=128, amp=0.1, sigma=16), pulse.DriveChannel(1)
            )

        circuit.add_calibration("rxx", [0, 1], rxx_q01)

        self.circuit_drawer(circuit, filename="calibrations_with_rzz_and_rxx.png")
Exemplo n.º 16
0
 def test_drag_experiment_config(self):
     """Test RoughDrag config can roundtrip"""
     with pulse.build(name="xp") as sched:
         pulse.play(pulse.Drag(160, 0.5, 40, Parameter("β")), pulse.DriveChannel(0))
     exp = RoughDrag(0, backend=self.backend, schedule=sched)
     loaded_exp = RoughDrag.from_config(exp.config())
     self.assertNotEqual(exp, loaded_exp)
     self.assertTrue(self.json_equiv(exp, loaded_exp))
Exemplo n.º 17
0
    def setUp(self):
        """Setup test variables."""
        super().setUp()

        with pulse.build(name="Drag") as schedule:
            pulse.play(pulse.Drag(160, 0.5, 40, 0.3), pulse.DriveChannel(0))

        self.schedule = schedule
Exemplo n.º 18
0
    def setUp(self):
        """Setup tests."""
        super().setUp()

        with pulse.build() as sched:
            pulse.play(pulse.Gaussian(160, Parameter("amp"), 40),
                       pulse.DriveChannel(2))

        self.sched = sched
Exemplo n.º 19
0
    def test_play_name_argument(self):
        """Test name argument for play instruction."""
        d0 = pulse.DriveChannel(0)
        test_pulse = library.Constant(10, 1.0)

        with pulse.build() as schedule:
            pulse.play(test_pulse, channel=d0, name='new_name')

        self.assertEqual(schedule.instructions[0][1].name, 'new_name')
    def _build_cr_schedule(
        self,
        backend: Backend,
        flat_top_width: float,
        sigma: float,
    ) -> pulse.ScheduleBlock:
        """GaussianSquared cross resonance pulse.

        Args:
            backend: The target backend.
            flat_top_width: Total length of flat top part of the pulse in units of dt.
            sigma: Sigma of Gaussian edges in units of dt.

        Returns:
            A schedule definition for the cross resonance pulse to measure.
        """
        opt = self.experiment_options

        # Compute valid integer duration
        cr_duration = round_pulse_duration(backend=backend,
                                           duration=flat_top_width +
                                           2 * sigma * opt.risefall)

        with pulse.build(backend, default_alignment="left",
                         name="cr") as cross_resonance:

            # add cross resonance tone
            pulse.play(
                pulse.GaussianSquare(
                    duration=cr_duration,
                    amp=opt.amp,
                    sigma=sigma,
                    width=flat_top_width,
                ),
                pulse.control_channels(*self.physical_qubits)[0],
            )
            # add cancellation tone
            if not np.isclose(opt.amp_t, 0.0):
                pulse.play(
                    pulse.GaussianSquare(
                        duration=cr_duration,
                        amp=opt.amp_t,
                        sigma=sigma,
                        width=flat_top_width,
                    ),
                    pulse.drive_channel(self.physical_qubits[1]),
                )
            else:
                pulse.delay(cr_duration,
                            pulse.drive_channel(self.physical_qubits[1]))

            # place holder for empty drive channels. this is necessary due to known pulse gate bug.
            pulse.delay(cr_duration,
                        pulse.drive_channel(self.physical_qubits[0]))

        return cross_resonance
 def test_scheduler_with_params_not_bound(self):
     """Test scheduler with parameters defined but not bound"""
     x = Parameter("amp")
     qc = QuantumCircuit(2)
     qc.append(Gate("pulse_gate", 1, [x]), [0])
     with build() as expected_schedule:
         play(Gaussian(duration=160, amp=x, sigma=40), DriveChannel(0))
     qc.add_calibration(gate="pulse_gate", qubits=[0], schedule=expected_schedule, params=[x])
     sched = schedule(qc, self.backend)
     self.assertEqual(sched, transforms.target_qobj_transform(expected_schedule))
Exemplo n.º 22
0
    def test_call_with_not_existing_parameter(self):
        """Test call subroutine with parameter not defined."""
        amp = circuit.Parameter('amp1')

        with pulse.build() as subroutine:
            pulse.play(pulse.Gaussian(160, amp, 40), pulse.DriveChannel(0))

        with self.assertRaises(exceptions.PulseError):
            with pulse.build():
                pulse.call(subroutine, amp=0.1)
Exemplo n.º 23
0
    def setUp(self):
        """Setup some schedules."""
        super().setUp()

        beta = Parameter("β")

        with pulse.build(name="xp") as xp:
            pulse.play(Drag(duration=160, amp=0.208519, sigma=40, beta=beta), DriveChannel(0))

        self.x_plus = xp
Exemplo n.º 24
0
    def test_execute_block(self):
        """Test executing a ScheduleBlock on a Pulse backend"""

        with pulse.build(name="test_block") as sched_block:
            pulse.play(pulse.Constant(160, 1.0), pulse.DriveChannel(0))
            pulse.acquire(50, pulse.MeasureChannel(0), pulse.MemorySlot(0))

        backend = FakeArmonk()
        test_result = backend.run(sched_block).result()
        self.assertDictEqual(test_result.get_counts(), {"0": 1024})
    def test_cx_cz_case(self):
        """Test the case where the coupling map has CX and CZ on different qubits.

        We use FakeBelem which has a linear coupling map and will restrict ourselves to
        qubits 0, 1, and 2. The Cals will define a template schedule for CX and CZ. We will
        mock this with GaussianSquare and Gaussian pulses since the nature of the schedules
        is irrelevant here. The parameters for CX will only have values for qubis 0 and 1 while
        the parameters for CZ will only have values for qubis 1 and 2. We therefore will have
        a CX on qubits 0, 1 in the inst. map and a CZ on qubits 1, 2.
        """

        cals = BackendCalibrations(FakeBelem())

        sig = Parameter("σ")
        dur = Parameter("duration")
        width = Parameter("width")
        amp_cx = Parameter("amp")
        amp_cz = Parameter("amp")
        uchan = Parameter("ch1.0")

        with pulse.build(name="cx") as cx:
            pulse.play(
                pulse.GaussianSquare(duration=dur, amp=amp_cx, sigma=sig, width=width),
                pulse.ControlChannel(uchan),
            )

        with pulse.build(name="cz") as cz:
            pulse.play(
                pulse.Gaussian(duration=dur, amp=amp_cz, sigma=sig), pulse.ControlChannel(uchan)
            )

        cals.add_schedule(cx, num_qubits=2)
        cals.add_schedule(cz, num_qubits=2)

        cals.add_parameter_value(640, "duration", schedule="cx")
        cals.add_parameter_value(64, "σ", schedule="cx")
        cals.add_parameter_value(320, "width", qubits=(0, 1), schedule="cx")
        cals.add_parameter_value(320, "width", qubits=(1, 0), schedule="cx")
        cals.add_parameter_value(0.1, "amp", qubits=(0, 1), schedule="cx")
        cals.add_parameter_value(0.8, "amp", qubits=(1, 0), schedule="cx")
        cals.add_parameter_value(0.1, "amp", qubits=(2, 1), schedule="cz")
        cals.add_parameter_value(0.8, "amp", qubits=(1, 2), schedule="cz")

        # CX only defined for qubits (0, 1) and (1,0)?
        self.assertTrue(cals.default_inst_map.has("cx", (0, 1)))
        self.assertTrue(cals.default_inst_map.has("cx", (1, 0)))
        self.assertFalse(cals.default_inst_map.has("cx", (2, 1)))
        self.assertFalse(cals.default_inst_map.has("cx", (1, 2)))

        # CZ only defined for qubits (2, 1) and (1,2)?
        self.assertTrue(cals.default_inst_map.has("cz", (2, 1)))
        self.assertTrue(cals.default_inst_map.has("cz", (1, 2)))
        self.assertFalse(cals.default_inst_map.has("cz", (0, 1)))
        self.assertFalse(cals.default_inst_map.has("cz", (1, 0)))
Exemplo n.º 26
0
    def _build_schedules(
            self, basis_gates: Set[str]) -> Dict[str, pulse.ScheduleBlock]:
        """Dummy schedule building."""
        with pulse.build(name="x") as schedule:
            pulse.play(pulse.Drag(160, 0.1, 40, 0), pulse.DriveChannel(0))

        schedules = dict()
        if "x" in basis_gates:
            schedules["x"] = schedule

        return schedules
Exemplo n.º 27
0
    def setUp(self):
        """Setup the tests."""
        super().setUp()

        self.qubit = 1

        with pulse.build(name="x") as sched:
            pulse.play(pulse.Drag(160, Parameter("amp"), 40, 0.4),
                       pulse.DriveChannel(self.qubit))

        self.sched = sched
Exemplo n.º 28
0
    def test_raise_multiple_parameter(self):
        """Check that the experiment raises with unassigned parameters."""

        beta = Parameter("β")
        amp = Parameter("amp")

        with pulse.build(name="xp") as xp:
            pulse.play(Drag(duration=160, amp=amp, sigma=40, beta=beta), DriveChannel(0))

        with self.assertRaises(QiskitError):
            RoughDrag(1, xp, betas=np.linspace(-3, 3, 21))
Exemplo n.º 29
0
    def test_play_parametric_pulse(self):
        """Test play instruction with parametric pulse."""
        d0 = pulse.DriveChannel(0)
        test_pulse = library.Constant(10, 1.0)

        with pulse.build() as schedule:
            pulse.play(test_pulse, d0)

        reference = pulse.Schedule()
        reference += instructions.Play(test_pulse, d0)

        self.assertEqual(schedule, reference)
Exemplo n.º 30
0
    def test_play_sample_pulse(self):
        """Test play instruction with sample pulse."""
        d0 = pulse.DriveChannel(0)
        test_pulse = library.Waveform([0.0, 0.0])

        with pulse.build() as schedule:
            pulse.play(test_pulse, d0)

        reference = pulse.Schedule()
        reference += instructions.Play(test_pulse, d0)

        self.assertEqual(schedule, reference)