Пример #1
0
 def test_dot(self):
     """
     f.0 = 0
     f.1 = f.sum()
     """
     p = Chebfun.from_function(np.sin)
     z = p.dot(Chebfun(0.))
     self.assertAlmostEqual(z, 0.)
     s = p.dot(Chebfun(1.))
     self.assertAlmostEqual(s, p.sum())
Пример #2
0
 def test_diff_one(self):
     """
     Derivative of Chebfun(1) close to zero
     """
     one = Chebfun(1.)
     zero = one.differentiate()
     npt.assert_allclose(tools.Zero(tools.xs), 0.)
Пример #3
0
 def test_interp_values(self):
     """
     Instanciate Chebfun from interpolation values.
     """
     p2 = Chebfun(self.p.values())
     npt.assert_almost_equal(self.p.coefficients(), p2.coefficients())
     tools.assert_close(self.p, p2)
Пример #4
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)
Пример #5
0
 def test_list_init(self):
     c = Chebfun([1.])
     npt.assert_array_almost_equal(c.coefficients(), np.array([1.]))
Пример #6
0
 def test_empty_init(self):
     c = Chebfun()
     npt.assert_allclose(c(tools.xs), 0.)
Пример #7
0
 def test_scalar_init_one(self):
     one = Chebfun(1.)
     npt.assert_array_almost_equal(one(tools.xs), 1.)
Пример #8
0
 def test_scalar_init_zero(self):
     c = Chebfun(0.)
     npt.assert_allclose(c(tools.xs), 0.)
Пример #9
0
 def test_init_from_data(self):
     data = np.array([-1, 1.])
     c = Chebfun(data)
Пример #10
0
 def test_intlist(self):
     """
     Initialise with a list of integers
     """
     c = Chebfun([1, 2, 3])