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())
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.)
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)
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)
def test_list_init(self): c = Chebfun([1.]) npt.assert_array_almost_equal(c.coefficients(), np.array([1.]))
def test_empty_init(self): c = Chebfun() npt.assert_allclose(c(tools.xs), 0.)
def test_scalar_init_one(self): one = Chebfun(1.) npt.assert_array_almost_equal(one(tools.xs), 1.)
def test_scalar_init_zero(self): c = Chebfun(0.) npt.assert_allclose(c(tools.xs), 0.)
def test_init_from_data(self): data = np.array([-1, 1.]) c = Chebfun(data)
def test_intlist(self): """ Initialise with a list of integers """ c = Chebfun([1, 2, 3])