def test_tg1plot(self):
        s1 = 1
        s2 = 2

        tg = tr.tpoly(s1, s2, 11)
        tg.plot(block=False)

        tg = tr.lspb(s1, s2, 11)
        tg.plot(block=False)

        tg = tr.tpoly(s1, s2, [1, 2])
        tg.plot(block=False)
    def test_tg1plot(self):
        s1 = 1
        s2 = 2

        tg = tr.tpoly(s1, s2, 11)
        tr.t1plot(tg, block=False)

        tg = tr.lspb(s1, s2, 11)
        tr.t1plot(tg, block=False)

        tg = tr.tpoly(s1, s2, [1, 2])
        tr.t1plot(tg, block=False)

        with self.assertRaises(TypeError):
            tr.t1plot('abcdefg', block=False)
    def test_tpoly(self):

        s1 = 1
        s2 = 2
        # no boundary conditions

        tg = tr.tpoly(s1, s2, 11)
        s = tg.y
        sd = tg.yd
        sdd = tg.ydd

        self.assertTrue(np.all(np.diff(s) > 0))  # output is monotonic
        self.assertAlmostEqual(s[0], s1)
        self.assertAlmostEqual(s[-1], s2)
        self.assertAlmostEqual(s[5], 1.5)

        self.assertTrue(np.all(sd >= -10 * _eps))  # velocity is >= 0
        self.assertAlmostEqual(sd[0], 0)
        self.assertAlmostEqual(sd[-1], 0)

        self.assertAlmostEqual(sdd[0], 0)
        self.assertAlmostEqual(sdd[5], 0)
        self.assertAlmostEqual(sdd[-1], 0)
        self.assertAlmostEqual(sum(sdd), 0)

        # time vector version
        t = np.linspace(0, 1, 11)

        tg = tr.tpoly(s1, s2, t)
        s = tg.y
        sd = tg.yd
        sdd = tg.ydd

        self.assertTrue(np.all(np.diff(s) > 0))  # output is monotonic
        self.assertAlmostEqual(s[0], s1)
        self.assertAlmostEqual(s[-1], s2)
        self.assertAlmostEqual(s[5], 1.5)

        # velocity is >= 0, some numeric issues hence the possible small
        # negative allowance
        self.assertTrue(np.all(sd >= -1000 * _eps))
        self.assertAlmostEqual(sd[0], 0)
        self.assertAlmostEqual(sd[-1], 0)

        self.assertAlmostEqual(sdd[0], 0)
        self.assertAlmostEqual(sdd[5], 0)
        self.assertAlmostEqual(sdd[-1], 0)
        self.assertAlmostEqual(sum(sdd), 0)

        # boundary conditions
        tg = tr.tpoly(s1, s2, 11, -1, 1)
        s = tg.y
        sd = tg.yd
        sdd = tg.ydd

        self.assertAlmostEqual(s[0], s1)
        self.assertAlmostEqual(s[-1], s2)

        self.assertAlmostEqual(sd[0], -1)
        self.assertAlmostEqual(sd[-1], 1)

        self.assertAlmostEqual(sdd[0], 0)
        self.assertAlmostEqual(sdd[-1], 0)

        with self.assertRaises(TypeError):
            tr.tpoly(s1, s2, 'not time')
    def test_tpoly_plot(self):
        t = tr.tpoly(0, 1, 50)
        t.plot()

        t = tr.tpoly(0, 1, np.linspace(0, 1, 50))
        t.plot()