Example #1
0
 def test_constant(self):
     """Test discrete sampled constant pulse."""
     amp = 0.5j
     duration = 10
     times = np.arange(0, duration) + 0.5  # to match default midpoint sampling strategy
     constant_ref = continuous.constant(times, amp=amp)
     constant_pulse = library.constant(duration, amp=amp)
     self.assertIsInstance(constant_pulse, Waveform)
     np.testing.assert_array_almost_equal(constant_pulse.samples, constant_ref)
Example #2
0
    def test_constant(self):
        """Test constant pulse."""
        amp = 0.5j
        samples = 50
        times = np.linspace(0, 10, samples)

        constant_arr = continuous.constant(times, amp=amp)

        self.assertEqual(constant_arr.dtype, np.complex_)
        np.testing.assert_equal(constant_arr, amp)
        self.assertEqual(len(constant_arr), samples)