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_lspb(self): s1 = 1 s2 = 2 # no boundary conditions tg = tr.lspb(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(np.sum(sdd), 0) # time vector version t = np.linspace(0, 1, 11) tg = tr.lspb(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) self.assertTrue(np.all(sd >= -10 * _eps)) # velocity is >= 0 self.assertAlmostEqual(sd[0], 0) self.assertAlmostEqual(sd[-1], 0) self.assertAlmostEqual(np.sum(sdd), 0) # specify velocity tg = tr.lspb(s1, s2, 11, 0.2) s = tg.y sd = tg.yd sdd = tg.ydd self.assertAlmostEqual(s[0], s1) self.assertAlmostEqual(s[-1], s2) self.assertAlmostEqual(sd[5], 0.2) tr.lspb(s1, s1, 1) with self.assertRaises(TypeError): tr.lspb(s1, s2, 'not time') with self.assertRaises(ValueError): tr.lspb(s1, s2, 1, V=0.000000001) with self.assertRaises(ValueError): tr.lspb(s1, s1 * 2, 0.1, V=10000000000000000000)
def test_lspb_plot(self): t = tr.lspb(0, 1, 50) t.plot() t = tr.lspb(0, 1, np.linspace(0, 1, 50)) t.plot()