def test_build_waveform_none_channel(self):
        ppt = PointPulseTemplate([('t1', 'A'), ('t2', 0., 'hold'),
                                  ('t1+t2', 'B+C', 'linear')], [0, 'A', 'C'],
                                 measurements=[('M', 'n', 1), ('L', 'n', 1)])
        parameters = {
            't1': 0.1,
            't2': 1.,
            'A': np.ones(3),
            'B': np.arange(3),
            'C': 19.,
            'n': 0.2
        }

        self.assertIsNone(
            ppt.build_waveform(parameters, {
                0: None,
                'A': None,
                'C': None
            }))

        wf = ppt.build_waveform(parameters, {0: 1, 'A': None, 'C': None})
        self.assertIsInstance(wf, PointWaveform)
        self.assertEqual(wf.defined_channels, {1})

        wf = ppt.build_waveform(parameters, {0: 1, 'A': 2, 'C': None})
        self.assertIsInstance(wf, MultiChannelWaveform)
        self.assertEqual(wf.defined_channels, {1, 2})
    def test_build_waveform_multi_channel_vectorized(self):
        ppt = PointPulseTemplate([('t1', 'A'), ('t2', 0., 'hold'),
                                  ('t1+t2', 'B+C', 'linear')], [0, 'A'],
                                 measurements=[('M', 'n', 1), ('L', 'n', 1)])

        parameters = {
            't1': 0.1,
            't2': 1.,
            'A': np.ones(2),
            'B': np.arange(2),
            'C': 19.,
            'n': 0.2
        }
        wf = ppt.build_waveform(parameters=parameters,
                                channel_mapping={
                                    0: 1,
                                    'A': 'A'
                                })
        expected_1 = PointWaveform(1,
                                   [(0, 1., HoldInterpolationStrategy()),
                                    (0.1, 1., HoldInterpolationStrategy()),
                                    (1., 0., HoldInterpolationStrategy()),
                                    (1.1, 19., LinearInterpolationStrategy())])
        expected_A = PointWaveform('A',
                                   [(0, 1., HoldInterpolationStrategy()),
                                    (0.1, 1., HoldInterpolationStrategy()),
                                    (1., 0., HoldInterpolationStrategy()),
                                    (1.1, 20., LinearInterpolationStrategy())])
        self.assertEqual(wf.defined_channels, {1, 'A'})
        self.assertEqual(wf._sub_waveforms[0].defined_channels, {1})
        self.assertEqual(wf._sub_waveforms[0], expected_1)
        self.assertEqual(wf._sub_waveforms[1].defined_channels, {'A'})
        self.assertEqual(wf._sub_waveforms[1], expected_A)
    def test_build_waveform_single_channel(self):
        ppt = PointPulseTemplate([('t1', 'A'), ('t2', 0., 'hold'),
                                  ('t1+t2', 'B+C', 'linear')], [0])

        parameters = {'t1': 0.1, 't2': 1., 'A': 1., 'B': 2., 'C': 19.}

        wf = ppt.build_waveform(parameters=parameters, channel_mapping={0: 1})
        expected = PointWaveform(1,
                                 [(0, 1., HoldInterpolationStrategy()),
                                  (0.1, 1., HoldInterpolationStrategy()),
                                  (1., 0., HoldInterpolationStrategy()),
                                  (1.1, 21., LinearInterpolationStrategy())])
        self.assertIsInstance(wf, PointWaveform)
        self.assertEqual(wf, expected)