Пример #1
0
 def test_integral_out_of_bounds(self):
     # Regression test for gh-7906: .integral(a, b) is wrong if both
     # a and b are out-of-bounds
     x = np.linspace(0., 1., 7)
     for ext in range(4):
         f = UnivariateSpline(x, x, s=0, ext=ext)
         for (a, b) in [(1, 1), (1, 5), (2, 5), (0, 0), (-2, 0), (-2, -1)]:
             assert_allclose(f.integral(a, b), 0, atol=1e-15)
Пример #2
0
    def test_derivative_and_antiderivative(self):
        # Thin wrappers to splder/splantider, so light smoke test only.
        x = np.linspace(0, 1, 70)**3
        y = np.cos(x)

        spl = UnivariateSpline(x, y, s=0)
        spl2 = spl.antiderivative(2).derivative(2)
        assert_allclose(spl(0.3), spl2(0.3))

        spl2 = spl.antiderivative(1)
        assert_allclose(spl2(0.6) - spl2(0.2), spl.integral(0.2, 0.6))
Пример #3
0
    def test_derivative_and_antiderivative(self):
        # Thin wrappers to splder/splantider, so light smoke test only.
        x = np.linspace(0, 1, 70) ** 3
        y = np.cos(x)

        spl = UnivariateSpline(x, y, s=0)
        spl2 = spl.antiderivative(2).derivative(2)
        assert_allclose(spl(0.3), spl2(0.3))

        spl2 = spl.antiderivative(1)
        assert_allclose(spl2(0.6) - spl2(0.2), spl.integral(0.2, 0.6))