def test_constant(self):
     """Test discrete sampled constant pulse."""
     amp = 0.5j
     duration = 10
     times = np.arange(0, duration)
     constant_ref = continuous.constant(times, amp=amp)
     constant_pulse = pulse_lib.constant(duration, amp=amp)
     self.assertIsInstance(constant_pulse, SamplePulse)
     np.testing.assert_array_almost_equal(constant_pulse.samples, constant_ref)
    def test_schedule_generator(self):
        """Test schedule generator functionalty."""

        x_test = 10
        amp_test = 1.0

        def test_func(x):
            sched = Schedule()
            sched += pulse_lib.constant(int(x), amp_test)(DriveChannel(0))
            return sched

        ref_sched = Schedule()
        ref_sched += pulse_lib.constant(x_test, amp_test)(DriveChannel(0))

        inst_map = InstructionScheduleMap()
        inst_map.add('f', (0,), test_func)
        self.assertEqual(inst_map.get('f', (0,), x_test), ref_sched)

        self.assertEqual(inst_map.get_parameters('f', (0,)), ('x',))
 def test_func(x):
     sched = Schedule()
     sched += pulse_lib.constant(int(x), amp_test)(DriveChannel(0))
     return sched
Esempio n. 4
0
 def get_sample_pulse(self) -> SamplePulse:
     return constant(duration=self.duration, amp=self.amp)