コード例 #1
0
ファイル: test_chebfun.py プロジェクト: hjrrockies/pychebfun
 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)
コード例 #2
0
 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
0
ファイル: test_chebfun.py プロジェクト: hjrrockies/pychebfun
 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])
コード例 #4
0
 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])
コード例 #5
0
ファイル: test_chebfun.py プロジェクト: hjrrockies/pychebfun
 def test_identity(self):
     c = Chebfun.identity()
     tools.assert_close(c, lambda x: x)
コード例 #6
0
 def test_restrict(self):
     x = Chebfun.identity()
     with self.assertRaises(ValueError):
         x.restrict([-2,0])
     with self.assertRaises(ValueError):
         x.restrict([0,2])
コード例 #7
0
 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)
コード例 #8
0
 def test_identity(self):
     c = Chebfun.identity()
     tools.assert_close(c, lambda x:x)
コード例 #9
0
ファイル: test_domain.py プロジェクト: shyams2/pychebfun
 def test_restrict(self):
     x = Chebfun.identity()
     with self.assertRaises(ValueError):
         x.restrict([-2, 0])
     with self.assertRaises(ValueError):
         x.restrict([0, 2])
コード例 #10
0
ファイル: test_domain.py プロジェクト: shyams2/pychebfun
 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)