Ejemplo n.º 1
0
 def test_roll(self):
     b = BSplineBasis(4, [-2, -1, -1, 0, 2, 4, 6.5, 7, 8, 8, 9, 11, 13, 15.5], periodic=2)
     b.roll(3)
     self.assertEqual(len(b.knots), 14)
     self.assertAlmostEqual(b.knots[0], 0)
     self.assertAlmostEqual(b.knots[1], 2)
     self.assertAlmostEqual(b.knots[2], 4)
     self.assertAlmostEqual(b.knots[3], 6.5)
     self.assertAlmostEqual(b.knots[4], 7)
     self.assertAlmostEqual(b.knots[5], 8)
     self.assertAlmostEqual(b.knots[6], 8)
     self.assertAlmostEqual(b.knots[7], 9)
     self.assertAlmostEqual(b.knots[8], 11)
     self.assertAlmostEqual(b.knots[9], 13)
     self.assertAlmostEqual(b.knots[10], 15.5)
     self.assertAlmostEqual(b.knots[11], 16)
     self.assertAlmostEqual(b.knots[12], 17)
     self.assertAlmostEqual(b.knots[13], 17)
Ejemplo n.º 2
0
 def test_roll(self):
     b = BSplineBasis(4, [-2, -1, -1, 0, 2, 4, 6.5, 7, 8, 8, 9, 11, 13, 15.5], periodic=2)
     b.roll(3)
     self.assertEqual(len(b.knots), 14)
     self.assertAlmostEqual(b.knots[0], 0)
     self.assertAlmostEqual(b.knots[1], 2)
     self.assertAlmostEqual(b.knots[2], 4)
     self.assertAlmostEqual(b.knots[3], 6.5)
     self.assertAlmostEqual(b.knots[4], 7)
     self.assertAlmostEqual(b.knots[5], 8)
     self.assertAlmostEqual(b.knots[6], 8)
     self.assertAlmostEqual(b.knots[7], 9)
     self.assertAlmostEqual(b.knots[8], 11)
     self.assertAlmostEqual(b.knots[9], 13)
     self.assertAlmostEqual(b.knots[10], 15.5)
     self.assertAlmostEqual(b.knots[11], 16)
     self.assertAlmostEqual(b.knots[12], 17)
     self.assertAlmostEqual(b.knots[13], 17)
Ejemplo n.º 3
0
    def test_roll(self):
        b = BSplineBasis(3, [-1, 0, 0, 2, 3, 4, 4, 6], periodic=0)
        b.roll(3)
        expect = [0, 2, 3, 4, 4, 6, 7, 8]
        self.assertAlmostEqual(np.linalg.norm(b.knots - expect), 0)
        b.roll(2)
        expect = [2, 3, 4, 4, 6, 7, 8, 8]
        self.assertAlmostEqual(np.linalg.norm(b.knots - expect), 0)

        with self.assertRaises(IndexError):
            b.roll(19)
Ejemplo n.º 4
0
    def test_roll(self):
        b = BSplineBasis(3, [-1, 0, 0, 2, 3, 4, 4, 6], periodic=0)
        b.roll(3)
        expect = [0, 2, 3, 4, 4, 6, 7, 8]
        self.assertAlmostEqual(np.linalg.norm(b.knots - expect), 0)
        b.roll(2)
        expect = [2, 3, 4, 4, 6, 7, 8, 8]
        self.assertAlmostEqual(np.linalg.norm(b.knots - expect), 0)

        with self.assertRaises(IndexError):
            b.roll(19)