MCPcopy Create free account
hub / github.com/numpy/numpy / test_chebval

Method test_chebval

numpy/polynomial/tests/test_chebyshev.py:134–153  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

132 y = polyval(x, [1., 2., 3.])
133
134 def test_chebval(self):
135 #check empty input
136 assert_equal(cheb.chebval([], [1]).size, 0)
137
138 #check normal input)
139 x = np.linspace(-1, 1)
140 y = [polyval(x, c) for c in Tlist]
141 for i in range(10):
142 msg = f"At i={i}"
143 tgt = y[i]
144 res = cheb.chebval(x, [0]*i + [1])
145 assert_almost_equal(res, tgt, err_msg=msg)
146
147 #check that shape is preserved
148 for i in range(3):
149 dims = [2]*i
150 x = np.zeros(dims)
151 assert_equal(cheb.chebval(x, [1]).shape, dims)
152 assert_equal(cheb.chebval(x, [1, 0]).shape, dims)
153 assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
154
155 def test_chebval2d(self):
156 x1, x2, x3 = self.x

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
polyvalFunction · 0.90
assert_almost_equalFunction · 0.90
linspaceMethod · 0.80

Tested by

no test coverage detected