Пример #1
0
 def test_from_array_1D(self) -> None:
     times = numpy.array([0, 1, 3])
     voltages = numpy.array([5, 0, 5])
     pulse = TablePulseTemplate.from_array(times, voltages, [0])
     entries = []
     for (time, voltage) in zip(times, voltages):
         entries.append(TableEntry(time, voltage, HoldInterpolationStrategy()))
     self.assertEqual({0: entries}, pulse.entries)
Пример #2
0
 def test_from_array_multi_one_voltage(self) -> None:
     times = numpy.array([[0, 1, 3], [2, 3, 4]])
     voltages = numpy.array([1, 2, 3])
     pulse = TablePulseTemplate.from_array(times, voltages, [0, 1])
     entries = {
         i: [TableEntry(time, voltage, HoldInterpolationStrategy())
             for (time, voltage) in zip(times[i, :], voltages)]
         for i in range(2)}
     self.assertEqual(entries, pulse.entries)
Пример #3
0
    def test_from_array_exceptions(self):
        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.arange(0), numpy.arange(1),
                                          [0])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.arange(1), numpy.arange(0),
                                          [0])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(
                numpy.array(numpy.ndindex((1, 2, 1))), numpy.arange(2), [0])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.zeros(3), numpy.zeros(
                (3, 2, 3)), [3, 4, 5])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.zeros((4, 2)),
                                          numpy.zeros((3, 4)), [3, 4, 5])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.zeros((3, 2)),
                                          numpy.array(numpy.ndindex((4, 6))),
                                          [3, 4, 5])

        with self.assertRaises(ValueError):
            TablePulseTemplate.from_array(numpy.zeros((3, 5)),
                                          numpy.array(numpy.ndindex((3, 6))),
                                          [3, 4, 5])