def test_inverse(self):
     # Check that antiderivative + derivative is identity.
     for n in range(5):
         spl2 = splantider(self.spl, n)
         spl3 = splder(spl2, n)
         assert_allclose(self.spl[0], spl3[0])
         assert_allclose(self.spl[1], spl3[1])
         assert_equal(self.spl[2], spl3[2])
示例#2
0
 def test_inverse(self):
     # Check that antiderivative + derivative is identity.
     for n in range(5):
         spl2 = splantider(self.spl, n)
         spl3 = splder(spl2, n)
         assert_allclose(self.spl[0], spl3[0])
         assert_allclose(self.spl[1], spl3[1])
         assert_equal(self.spl[2], spl3[2])
    def test_splantider_vs_splint(self):
        # Check antiderivative vs. FITPACK
        spl2 = splantider(self.spl)

        # no extrapolation, splint assumes function is zero outside
        # range
        xx = np.linspace(0, 1, 20)

        for x1 in xx:
            for x2 in xx:
                y1 = splint(x1, x2, self.spl)
                y2 = splev(x2, spl2) - splev(x1, spl2)
                assert_allclose(y1, y2)
示例#4
0
    def test_splantider_vs_splint(self):
        # Check antiderivative vs. FITPACK
        spl2 = splantider(self.spl)

        # no extrapolation, splint assumes function is zero outside
        # range
        xx = np.linspace(0, 1, 20)

        for x1 in xx:
            for x2 in xx:
                y1 = splint(x1, x2, self.spl)
                y2 = splev(x2, spl2) - splev(x1, spl2)
                assert_allclose(y1, y2)
示例#5
0
    def test_multidim(self):
        # c can have trailing dims
        for n in range(3):
            t, c, k = self.spl
            c2 = np.c_[c, c, c]
            c2 = np.dstack((c2, c2))

            spl2 = splantider((t, c2, k), n)
            spl3 = splder(spl2, n)

            assert_allclose(t, spl3[0])
            assert_allclose(c2, spl3[1])
            assert_equal(k, spl3[2])
示例#6
0
    def test_multidim(self):
        # c can have trailing dims
        for n in range(3):
            t, c, k = self.spl
            c2 = np.c_[c, c, c]
            c2 = np.dstack((c2, c2))

            spl2 = splantider((t, c2, k), n)
            spl3 = splder(spl2, n)

            assert_allclose(t, spl3[0])
            assert_allclose(c2, spl3[1])
            assert_equal(k, spl3[2])
示例#7
0
 def antiderivative(self, n=1):
     tck = fitpack.splantider(self._eval_args, n)
     return PeriodicSpline._from_tck(tck)