本文整理汇总了Python中scipy.interpolate.KroghInterpolator.derivatives方法的典型用法代码示例。如果您正苦于以下问题:Python KroghInterpolator.derivatives方法的具体用法?Python KroghInterpolator.derivatives怎么用?Python KroghInterpolator.derivatives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.interpolate.KroghInterpolator
的用法示例。
在下文中一共展示了KroghInterpolator.derivatives方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shapes_scalarvalue_derivative
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_shapes_scalarvalue_derivative(self):
P = KroghInterpolator(self.xs,self.ys)
n = P.n
assert_array_equal(np.shape(P.derivatives(0)), (n,))
assert_array_equal(np.shape(P.derivatives(np.array(0))), (n,))
assert_array_equal(np.shape(P.derivatives([0])), (n,1))
assert_array_equal(np.shape(P.derivatives([0,1])), (n,2))
示例2: test_wrapper
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_wrapper(self):
P = KroghInterpolator(self.xs, self.ys)
assert_almost_equal(P(self.test_xs), krogh_interpolate(self.xs, self.ys, self.test_xs))
assert_almost_equal(P.derivative(self.test_xs, 2), krogh_interpolate(self.xs, self.ys, self.test_xs, der=2))
assert_almost_equal(
P.derivatives(self.test_xs, 2), krogh_interpolate(self.xs, self.ys, self.test_xs, der=[0, 1])
)
示例3: test_derivatives_complex
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_derivatives_complex(self):
# regression test for gh-7381: krogh.derivatives(0) fails complex y
x, y = np.array([-1, -1, 0, 1, 1]), np.array([1, 1.0j, 0, -1, 1.0j])
func = KroghInterpolator(x, y)
cmplx = func.derivatives(0)
cmplx2 = (KroghInterpolator(x, y.real).derivatives(0) +
1j*KroghInterpolator(x, y.imag).derivatives(0))
assert_allclose(cmplx, cmplx2, atol=1e-15)
示例4: test_vector
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_vector(self):
xs = [0, 1, 2]
ys = np.array([[0, 1], [1, 0], [2, 1]])
P = KroghInterpolator(xs, ys)
Pi = [KroghInterpolator(xs, ys[:, i]) for i in xrange(ys.shape[1])]
test_xs = np.linspace(-1, 3, 100)
assert_almost_equal(P(test_xs), np.rollaxis(np.asarray([p(test_xs) for p in Pi]), -1))
assert_almost_equal(
P.derivatives(test_xs), np.transpose(np.asarray([p.derivatives(test_xs) for p in Pi]), (1, 2, 0))
)
示例5: test_shapes_vectorvalue_derivative
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_shapes_vectorvalue_derivative(self):
P = KroghInterpolator(self.xs,np.outer(self.ys,np.arange(3)))
n = P.n
assert_array_equal(np.shape(P.derivatives(0)), (n,3))
assert_array_equal(np.shape(P.derivatives([0])), (n,1,3))
assert_array_equal(np.shape(P.derivatives([0,1])), (n,2,3))
示例6: test_derivative
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_derivative(self):
P = KroghInterpolator(self.xs,self.ys)
m = 10
r = P.derivatives(self.test_xs,m)
for i in xrange(m):
assert_almost_equal(P.derivative(self.test_xs,i),r[i])
示例7: test_low_derivatives
# 需要导入模块: from scipy.interpolate import KroghInterpolator [as 别名]
# 或者: from scipy.interpolate.KroghInterpolator import derivatives [as 别名]
def test_low_derivatives(self):
P = KroghInterpolator(self.xs,self.ys)
D = P.derivatives(self.test_xs,len(self.xs)+2)
for i in xrange(D.shape[0]):
assert_almost_equal(self.true_poly.deriv(i)(self.test_xs),
D[i])