def test_real_imag(self): datar = np.random.rand(10) datai = np.random.rand(10) cc = Chebfun.from_data(datar + 1j*datai) cr = Chebfun.from_data(datar) ci = Chebfun.from_data(datai) tools.assert_close(np.real(cc), cr) tools.assert_close(np.imag(cc), ci)
def test_real_imag(self): datar = np.random.rand(10) datai = np.random.rand(10) cc = Chebfun.from_data(datar + 1j * datai) cr = Chebfun.from_data(datar) ci = Chebfun.from_data(datai) tools.assert_close(np.real(cc), cr) tools.assert_close(np.imag(cc), ci)
def test_roots_of_flat_function(self): """ Check roots() does not fail for extremely flat Chebfuns such as those representing cumulative distribution functions. """ cdf = Chebfun.from_data(flat_chebfun_vals, domain=[-0.7, 0.7]) npt.assert_allclose((cdf - 0.05).roots(), 0.1751682246791747)
def test_roots_of_flat_function(self): """ Check roots() does not fail for extremely flat Chebfuns such as those representing cumulative distribution functions. """ cdf = Chebfun.from_data(flat_chebfun_vals, domain=[-0.7, 0.7]) npt.assert_allclose((cdf-0.05).roots(), 0.1751682246791747)
def test_from_scalar(self): val = np.random.rand() cr = chebfun(val) ce = Chebfun.from_data([val]) tools.assert_close(cr, ce)
def test_from_values(self): values = np.random.randn(10) cr = chebfun(values) ce = Chebfun.from_data(values) tools.assert_close(cr, ce)
def test_complex(self): n = 10 r = np.random.randn(n) + 1j * np.random.randn(n) c = Chebfun.from_data(r) xs = Chebfun.interpolation_points(n) npt.assert_allclose(c(xs), r)
def test_complex(self): n = 10 r = np.random.randn(n) + 1j*np.random.randn(n) c = Chebfun.from_data(r) xs = Chebfun.interpolation_points(n) npt.assert_allclose(c(xs), r)