本文整理匯總了Python中pychebfun.Chebfun.identity方法的典型用法代碼示例。如果您正苦於以下問題:Python Chebfun.identity方法的具體用法?Python Chebfun.identity怎麽用?Python Chebfun.identity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pychebfun.Chebfun
的用法示例。
在下文中一共展示了Chebfun.identity方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_scalarvectormult
# 需要導入模塊: from pychebfun import Chebfun [as 別名]
# 或者: from pychebfun.Chebfun import identity [as 別名]
def test_scalarvectormult(self):
"""
Possible to multiply scalar with vector chebfun.
"""
v = Chebfun.from_function(segment)
s = np.sin(Chebfun.identity())
m = s * v
tools.assert_close(m[0], s*v[0])
示例2: test_slice
# 需要導入模塊: from pychebfun import Chebfun [as 別名]
# 或者: from pychebfun.Chebfun import identity [as 別名]
def test_slice(self):
"""
Test slicing: f[0] should return the first component.
"""
s = Chebfun.from_function(segment)
tools.assert_close(s[0], Chebfun.identity())
tools.assert_close(s[1], Chebfun(0.))
tools.assert_close(s[:], s)
示例3: test_restrict
# 需要導入模塊: from pychebfun import Chebfun [as 別名]
# 或者: from pychebfun.Chebfun import identity [as 別名]
def test_restrict(self):
x = Chebfun.identity()
with self.assertRaises(ValueError):
x.restrict([-2,0])
with self.assertRaises(ValueError):
x.restrict([0,2])
示例4: test_mismatch
# 需要導入模塊: from pychebfun import Chebfun [as 別名]
# 或者: from pychebfun.Chebfun import identity [as 別名]
def test_mismatch(self):
c1 = Chebfun.identity()
c2 = Chebfun.from_function(lambda x:x, domain=[2,3])
for op in [operator.add, operator.sub, operator.mul, operator.truediv]:
with self.assertRaises(Chebfun.DomainMismatch):
op(c1, c2)
示例5: test_identity
# 需要導入模塊: from pychebfun import Chebfun [as 別名]
# 或者: from pychebfun.Chebfun import identity [as 別名]
def test_identity(self):
c = Chebfun.identity()
tools.assert_close(c, lambda x:x)