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


Python UnivariateSpline.get_knots方法代码示例

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


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

示例1: test_nan

# 需要导入模块: from scipy.interpolate.fitpack2 import UnivariateSpline [as 别名]
# 或者: from scipy.interpolate.fitpack2.UnivariateSpline import get_knots [as 别名]
 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,代码行数:27,代码来源:test_fitpack2.py

示例2: test_linear_1d

# 需要导入模块: from scipy.interpolate.fitpack2 import UnivariateSpline [as 别名]
# 或者: from scipy.interpolate.fitpack2.UnivariateSpline import get_knots [as 别名]
 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,代码行数:10,代码来源:test_fitpack2.py

示例3: test_increasing_x

# 需要导入模块: from scipy.interpolate.fitpack2 import UnivariateSpline [as 别名]
# 或者: from scipy.interpolate.fitpack2.UnivariateSpline import get_knots [as 别名]
 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,代码行数:18,代码来源:test_fitpack2.py


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