Exemplo n.º 1
0
    def test_constant_samples(self):
        """Test the constant pulse and its sampled construction."""
        const = Constant(duration=150, amp=0.1 + 0.4j)
        self.assertEqual(const.get_waveform().samples[0], 0.1 + 0.4j)
        self.assertEqual(len(const.get_waveform().samples), 150)

        with self.assertRaises(PulseError):
            const = Constant(duration=150, amp=1.1 + 0.4j)

        with patch("qiskit.pulse.library.parametric_pulses.Pulse.limit_amplitude", new=False):
            const = qiskit.pulse.library.parametric_pulses.Constant(duration=150, amp=0.1 + 0.4j)
Exemplo n.º 2
0
 def test_gauss_square_extremes(self):
     """Test that the gaussian square pulse can build a gaussian."""
     duration = 125
     sigma = 4
     amp = 0.5j
     gaus_square = GaussianSquare(duration=duration, sigma=sigma, amp=amp, width=0)
     gaus = Gaussian(duration=duration, sigma=sigma, amp=amp)
     np.testing.assert_almost_equal(gaus_square.get_waveform().samples,
                                    gaus.get_waveform().samples)
     gaus_square = GaussianSquare(duration=duration, sigma=sigma, amp=amp, width=121)
     const = Constant(duration=duration, amp=amp)
     np.testing.assert_almost_equal(gaus_square.get_waveform().samples[2:-2],
                                    const.get_waveform().samples[2:-2])
Exemplo n.º 3
0
 def test_constant_samples(self):
     """Test the constant pulse and its sampled construction."""
     const = Constant(duration=150, amp=0.1 + 0.4j)
     self.assertEqual(const.get_waveform().samples[0], 0.1 + 0.4j)
     self.assertEqual(len(const.get_waveform().samples), 150)