当前位置: 首页>>代码示例>>Python>>正文


Python fitpack2.UnivariateSpline类代码示例

本文整理汇总了Python中scipy.interpolate.fitpack2.UnivariateSpline的典型用法代码示例。如果您正苦于以下问题:Python UnivariateSpline类的具体用法?Python UnivariateSpline怎么用?Python UnivariateSpline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UnivariateSpline类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_nan

 def test_nan(self):
     # bail out early if the input data contains nans
     x = np.arange(10, dtype=float)
     y = x**3
     w = np.ones_like(x)
     # also test LSQUnivariateSpline [which needs explicit knots]
     spl = UnivariateSpline(x, y, check_finite=True)
     t = spl.get_knots()[3:4]  # interior knots w/ default k=3
     y_end = y[-1]
     for z in [np.nan, np.inf, -np.inf]:
         y[-1] = z
         assert_raises(ValueError, UnivariateSpline,
                 **dict(x=x, y=y, check_finite=True))
         assert_raises(ValueError, InterpolatedUnivariateSpline,
                 **dict(x=x, y=y, check_finite=True))
         assert_raises(ValueError, LSQUnivariateSpline,
                 **dict(x=x, y=y, t=t, check_finite=True))
         y[-1] = y_end  # check valid y but invalid w
         w[-1] = z
         assert_raises(ValueError, UnivariateSpline,
                 **dict(x=x, y=y, w=w, check_finite=True))
         assert_raises(ValueError, InterpolatedUnivariateSpline,
                 **dict(x=x, y=y, w=w, check_finite=True))
         assert_raises(ValueError, LSQUnivariateSpline,
                 **dict(x=x, y=y, t=t, w=w, check_finite=True))
开发者ID:AlgorithmFan,项目名称:scipy,代码行数:25,代码来源:test_fitpack2.py

示例2: test_linear_1d

 def test_linear_1d(self):
     x = [1,2,3]
     y = [0,2,4]
     lut = UnivariateSpline(x,y,k=1)
     assert_array_almost_equal(lut.get_knots(),[1,3])
     assert_array_almost_equal(lut.get_coeffs(),[0,4])
     assert_almost_equal(lut.get_residual(),0.0)
     assert_array_almost_equal(lut([1,1.5,2]),[0,1,2])
开发者ID:NelleV,项目名称:scipy,代码行数:8,代码来源:test_fitpack2.py

示例3: test_derivative_and_antiderivative

    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))
开发者ID:GiladAmar,项目名称:scipy,代码行数:11,代码来源:test_fitpack2.py

示例4: test_increasing_x

 def test_increasing_x(self):
     xx = np.arange(10, dtype=float)
     yy = xx**3
     x = np.arange(10, dtype=float)
     x[1] = x[0]
     y = x**3
     w = np.ones_like(x)
     # also test LSQUnivariateSpline [which needs explicit knots]
     spl = UnivariateSpline(xx, yy, check_finite=True)
     t = spl.get_knots()[3:4]  # interior knots w/ default k=3
     assert_raises(ValueError, UnivariateSpline,
             **dict(x=x, y=y, check_finite=True))
     assert_raises(ValueError, InterpolatedUnivariateSpline,
             **dict(x=x, y=y, check_finite=True))
     assert_raises(ValueError, LSQUnivariateSpline,
             **dict(x=x, y=y, t=t, w=w, check_finite=True))
开发者ID:BranYang,项目名称:scipy,代码行数:16,代码来源:test_fitpack2.py


注:本文中的scipy.interpolate.fitpack2.UnivariateSpline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。