codekingpro/portable-devtools
114k
1"""Tests for chebyshev module.
2
3"""
4from functools import reduce
5
6import numpy as np
7import numpy.polynomial.chebyshev as cheb
8from numpy.polynomial.polynomial import polyval
9from numpy.testing import assert_, assert_almost_equal, assert_equal, assert_raises
10
11
12def trim(x):
13 return cheb.chebtrim(x, tol=1e-6)
14
15
16T0 = [1]
17T1 = [0, 1]
18T2 = [-1, 0, 2]
19T3 = [0, -3, 0, 4]
20T4 = [1, 0, -8, 0, 8]
21T5 = [0, 5, 0, -20, 0, 16]
22T6 = [-1, 0, 18, 0, -48, 0, 32]
23T7 = [0, -7, 0, 56, 0, -112, 0, 64]
24T8 = [1, 0, -32, 0, 160, 0, -256, 0, 128]
25T9 = [0, 9, 0, -120, 0, 432, 0, -576, 0, 256]
26
27Tlist = [T0, T1, T2, T3, T4, T5, T6, T7, T8, T9]
28
29
30class TestPrivate:
31
32 def test__cseries_to_zseries(self):
33 for i in range(5):
34 inp = np.array([2] + [1] * i, np.double)
35 tgt = np.array([.5] * i + [2] + [.5] * i, np.double)
36 res = cheb._cseries_to_zseries(inp)
37 assert_equal(res, tgt)
38
39 def test__zseries_to_cseries(self):
40 for i in range(5):
41 inp = np.array([.5] * i + [2] + [.5] * i, np.double)
42 tgt = np.array([2] + [1] * i, np.double)
43 res = cheb._zseries_to_cseries(inp)
44 assert_equal(res, tgt)
45
46
47class TestConstants:
48
49 def test_chebdomain(self):
50 assert_equal(cheb.chebdomain, [-1, 1])
51
52 def test_chebzero(self):
53 assert_equal(cheb.chebzero, [0])
54
55 def test_chebone(self):
56 assert_equal(cheb.chebone, [1])
57
58 def test_chebx(self):
59 assert_equal(cheb.chebx, [0, 1])
60
61
62class TestArithmetic:
63
64 def test_chebadd(self):
65 for i in range(5):
66 for j in range(5):
67 msg = f"At i={i}, j={j}"
68 tgt = np.zeros(max(i, j) + 1)
69 tgt[i] += 1
70 tgt[j] += 1
71 res = cheb.chebadd([0] * i + [1], [0] * j + [1])
72 assert_equal(trim(res), trim(tgt), err_msg=msg)
73
74 def test_chebsub(self):
75 for i in range(5):
76 for j in range(5):
77 msg = f"At i={i}, j={j}"
78 tgt = np.zeros(max(i, j) + 1)
79 tgt[i] += 1
80 tgt[j] -= 1
81 res = cheb.chebsub([0] * i + [1], [0] * j + [1])
82 assert_equal(trim(res), trim(tgt), err_msg=msg)
83
84 def test_chebmulx(self):
85 assert_equal(cheb.chebmulx([0]), [0])
86 assert_equal(cheb.chebmulx([1]), [0, 1])
87 for i in range(1, 5):
88 ser = [0] * i + [1]
89 tgt = [0] * (i - 1) + [.5, 0, .5]
90 assert_equal(cheb.chebmulx(ser), tgt)
91
92 def test_chebmul(self):
93 for i in range(5):
94 for j in range(5):
95 msg = f"At i={i}, j={j}"
96 tgt = np.zeros(i + j + 1)
97 tgt[i + j] += .5
98 tgt[abs(i - j)] += .5
99 res = cheb.chebmul([0] * i + [1], [0] * j + [1])
100 assert_equal(trim(res), trim(tgt), err_msg=msg)
101
102 def test_chebdiv(self):
103 for i in range(5):
104 for j in range(5):
105 msg = f"At i={i}, j={j}"
106 ci = [0] * i + [1]
107 cj = [0] * j + [1]
108 tgt = cheb.chebadd(ci, cj)
109 quo, rem = cheb.chebdiv(tgt, ci)
110 res = cheb.chebadd(cheb.chebmul(quo, ci), rem)
111 assert_equal(trim(res), trim(tgt), err_msg=msg)
112
113 def test_chebpow(self):
114 for i in range(5):
115 for j in range(5):
116 msg = f"At i={i}, j={j}"
117 c = np.arange(i + 1)
118 tgt = reduce(cheb.chebmul, [c] * j, np.array([1]))
119 res = cheb.chebpow(c, j)
120 assert_equal(trim(res), trim(tgt), err_msg=msg)
121
122
123class TestEvaluation:
124 # coefficients of 1 + 2*x + 3*x**2
125 c1d = np.array([2.5, 2., 1.5])
126 c2d = np.einsum('i,j->ij', c1d, c1d)
127 c3d = np.einsum('i,j,k->ijk', c1d, c1d, c1d)
128
129 # some random values in [-1, 1)
130 x = np.random.random((3, 5)) * 2 - 1
131 y = polyval(x, [1., 2., 3.])
132
133 def test_chebval(self):
134 # check empty input
135 assert_equal(cheb.chebval([], [1]).size, 0)
136
137 # check normal input)
138 x = np.linspace(-1, 1)
139 y = [polyval(x, c) for c in Tlist]
140 for i in range(10):
141 msg = f"At i={i}"
142 tgt = y[i]
143 res = cheb.chebval(x, [0] * i + [1])
144 assert_almost_equal(res, tgt, err_msg=msg)
145
146 # check that shape is preserved
147 for i in range(3):
148 dims = [2] * i
149 x = np.zeros(dims)
150 assert_equal(cheb.chebval(x, [1]).shape, dims)
151 assert_equal(cheb.chebval(x, [1, 0]).shape, dims)
152 assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims)
153
154 def test_chebval2d(self):
155 x1, x2, x3 = self.x
156 y1, y2, y3 = self.y
157
158 # test exceptions
159 assert_raises(ValueError, cheb.chebval2d, x1, x2[:2], self.c2d)
160
161 # test values
162 tgt = y1 * y2
163 res = cheb.chebval2d(x1, x2, self.c2d)
164 assert_almost_equal(res, tgt)
165
166 # test shape
167 z = np.ones((2, 3))
168 res = cheb.chebval2d(z, z, self.c2d)
169 assert_(res.shape == (2, 3))
170
171 def test_chebval3d(self):
172 x1, x2, x3 = self.x
173 y1, y2, y3 = self.y
174
175 # test exceptions
176 assert_raises(ValueError, cheb.chebval3d, x1, x2, x3[:2], self.c3d)
177
178 # test values
179 tgt = y1 * y2 * y3
180 res = cheb.chebval3d(x1, x2, x3, self.c3d)
181 assert_almost_equal(res, tgt)
182
183 # test shape
184 z = np.ones((2, 3))
185 res = cheb.chebval3d(z, z, z, self.c3d)
186 assert_(res.shape == (2, 3))
187
188 def test_chebgrid2d(self):
189 x1, x2, x3 = self.x
190 y1, y2, y3 = self.y
191
192 # test values
193 tgt = np.einsum('i,j->ij', y1, y2)
194 res = cheb.chebgrid2d(x1, x2, self.c2d)
195 assert_almost_equal(res, tgt)
196
197 # test shape
198 z = np.ones((2, 3))
199 res = cheb.chebgrid2d(z, z, self.c2d)
200 assert_(res.shape == (2, 3) * 2)
201
202 def test_chebgrid3d(self):
203 x1, x2, x3 = self.x
204 y1, y2, y3 = self.y
205
206 # test values
207 tgt = np.einsum('i,j,k->ijk', y1, y2, y3)
208 res = cheb.chebgrid3d(x1, x2, x3, self.c3d)
209 assert_almost_equal(res, tgt)
210
211 # test shape
212 z = np.ones((2, 3))
213 res = cheb.chebgrid3d(z, z, z, self.c3d)
214 assert_(res.shape == (2, 3) * 3)
215
216
217class TestIntegral:
218
219 def test_chebint(self):
220 # check exceptions
221 assert_raises(TypeError, cheb.chebint, [0], .5)
222 assert_raises(ValueError, cheb.chebint, [0], -1)
223 assert_raises(ValueError, cheb.chebint, [0], 1, [0, 0])
224 assert_raises(ValueError, cheb.chebint, [0], lbnd=[0])
225 assert_raises(ValueError, cheb.chebint, [0], scl=[0])
226 assert_raises(TypeError, cheb.chebint, [0], axis=.5)
227
228 # test integration of zero polynomial
229 for i in range(2, 5):
230 k = [0] * (i - 2) + [1]
231 res = cheb.chebint([0], m=i, k=k)
232 assert_almost_equal(res, [0, 1])
233
234 # check single integration with integration constant
235 for i in range(5):
236 scl = i + 1
237 pol = [0] * i + [1]
238 tgt = [i] + [0] * i + [1 / scl]
239 chebpol = cheb.poly2cheb(pol)
240 chebint = cheb.chebint(chebpol, m=1, k=[i])
241 res = cheb.cheb2poly(chebint)
242 assert_almost_equal(trim(res), trim(tgt))
243
244 # check single integration with integration constant and lbnd
245 for i in range(5):
246 scl = i + 1
247 pol = [0] * i + [1]
248 chebpol = cheb.poly2cheb(pol)
249 chebint = cheb.chebint(chebpol, m=1, k=[i], lbnd=-1)
250 assert_almost_equal(cheb.chebval(-1, chebint), i)
251
252 # check single integration with integration constant and scaling
253 for i in range(5):
254 scl = i + 1
255 pol = [0] * i + [1]
256 tgt = [i] + [0] * i + [2 / scl]
257 chebpol = cheb.poly2cheb(pol)
258 chebint = cheb.chebint(chebpol, m=1, k=[i], scl=2)
259 res = cheb.cheb2poly(chebint)
260 assert_almost_equal(trim(res), trim(tgt))
261
262 # check multiple integrations with default k
263 for i in range(5):
264 for j in range(2, 5):
265 pol = [0] * i + [1]
266 tgt = pol[:]
267 for k in range(j):
268 tgt = cheb.chebint(tgt, m=1)
269 res = cheb.chebint(pol, m=j)
270 assert_almost_equal(trim(res), trim(tgt))
271
272 # check multiple integrations with defined k
273 for i in range(5):
274 for j in range(2, 5):
275 pol = [0] * i + [1]
276 tgt = pol[:]
277 for k in range(j):
278 tgt = cheb.chebint(tgt, m=1, k=[k])
279 res = cheb.chebint(pol, m=j, k=list(range(j)))
280 assert_almost_equal(trim(res), trim(tgt))
281
282 # check multiple integrations with lbnd
283 for i in range(5):
284 for j in range(2, 5):
285 pol = [0] * i + [1]
286 tgt = pol[:]
287 for k in range(j):
288 tgt = cheb.chebint(tgt, m=1, k=[k], lbnd=-1)
289 res = cheb.chebint(pol, m=j, k=list(range(j)), lbnd=-1)
290 assert_almost_equal(trim(res), trim(tgt))
291
292 # check multiple integrations with scaling
293 for i in range(5):
294 for j in range(2, 5):
295 pol = [0] * i + [1]
296 tgt = pol[:]
297 for k in range(j):
298 tgt = cheb.chebint(tgt, m=1, k=[k], scl=2)
299 res = cheb.chebint(pol, m=j, k=list(range(j)), scl=2)
300 assert_almost_equal(trim(res), trim(tgt))
301
302 def test_chebint_axis(self):
303 # check that axis keyword works
304 c2d = np.random.random((3, 4))
305
306 tgt = np.vstack([cheb.chebint(c) for c in c2d.T]).T
307 res = cheb.chebint(c2d, axis=0)
308 assert_almost_equal(res, tgt)
309
310 tgt = np.vstack([cheb.chebint(c) for c in c2d])
311 res = cheb.chebint(c2d, axis=1)
312 assert_almost_equal(res, tgt)
313
314 tgt = np.vstack([cheb.chebint(c, k=3) for c in c2d])
315 res = cheb.chebint(c2d, k=3, axis=1)
316 assert_almost_equal(res, tgt)
317
318
319class TestDerivative:
320
321 def test_chebder(self):
322 # check exceptions
323 assert_raises(TypeError, cheb.chebder, [0], .5)
324 assert_raises(ValueError, cheb.chebder, [0], -1)
325
326 # check that zeroth derivative does nothing
327 for i in range(5):
328 tgt = [0] * i + [1]
329 res = cheb.chebder(tgt, m=0)
330 assert_equal(trim(res), trim(tgt))
331
332 # check that derivation is the inverse of integration
333 for i in range(5):
334 for j in range(2, 5):
335 tgt = [0] * i + [1]
336 res = cheb.chebder(cheb.chebint(tgt, m=j), m=j)
337 assert_almost_equal(trim(res), trim(tgt))
338
339 # check derivation with scaling
340 for i in range(5):
341 for j in range(2, 5):
342 tgt = [0] * i + [1]
343 res = cheb.chebder(cheb.chebint(tgt, m=j, scl=2), m=j, scl=.5)
344 assert_almost_equal(trim(res), trim(tgt))
345
346 def test_chebder_axis(self):
347 # check that axis keyword works
348 c2d = np.random.random((3, 4))
349
350 tgt = np.vstack([cheb.chebder(c) for c in c2d.T]).T
351 res = cheb.chebder(c2d, axis=0)
352 assert_almost_equal(res, tgt)
353
354 tgt = np.vstack([cheb.chebder(c) for c in c2d])
355 res = cheb.chebder(c2d, axis=1)
356 assert_almost_equal(res, tgt)
357
358
359class TestVander:
360 # some random values in [-1, 1)
361 x = np.random.random((3, 5)) * 2 - 1
362
363 def test_chebvander(self):
364 # check for 1d x
365 x = np.arange(3)
366 v = cheb.chebvander(x, 3)
367 assert_(v.shape == (3, 4))
368 for i in range(4):
369 coef = [0] * i + [1]
370 assert_almost_equal(v[..., i], cheb.chebval(x, coef))
371
372 # check for 2d x
373 x = np.array([[1, 2], [3, 4], [5, 6]])
374 v = cheb.chebvander(x, 3)
375 assert_(v.shape == (3, 2, 4))
376 for i in range(4):
377 coef = [0] * i + [1]
378 assert_almost_equal(v[..., i], cheb.chebval(x, coef))
379
380 def test_chebvander2d(self):
381 # also tests chebval2d for non-square coefficient array
382 x1, x2, x3 = self.x
383 c = np.random.random((2, 3))
384 van = cheb.chebvander2d(x1, x2, [1, 2])
385 tgt = cheb.chebval2d(x1, x2, c)
386 res = np.dot(van, c.flat)
387 assert_almost_equal(res, tgt)
388
389 # check shape
390 van = cheb.chebvander2d([x1], [x2], [1, 2])
391 assert_(van.shape == (1, 5, 6))
392
393 def test_chebvander3d(self):
394 # also tests chebval3d for non-square coefficient array
395 x1, x2, x3 = self.x
396 c = np.random.random((2, 3, 4))
397 van = cheb.chebvander3d(x1, x2, x3, [1, 2, 3])
398 tgt = cheb.chebval3d(x1, x2, x3, c)
399 res = np.dot(van, c.flat)
400 assert_almost_equal(res, tgt)
401
402 # check shape
403 van = cheb.chebvander3d([x1], [x2], [x3], [1, 2, 3])
404 assert_(van.shape == (1, 5, 24))
405
406
407class TestFitting:
408
409 def test_chebfit(self):
410 def f(x):
411 return x * (x - 1) * (x - 2)
412
413 def f2(x):
414 return x**4 + x**2 + 1
415
416 # Test exceptions
417 assert_raises(ValueError, cheb.chebfit, [1], [1], -1)
418 assert_raises(TypeError, cheb.chebfit, [[1]], [1], 0)
419 assert_raises(TypeError, cheb.chebfit, [], [1], 0)
420 assert_raises(TypeError, cheb.chebfit, [1], [[[1]]], 0)
421 assert_raises(TypeError, cheb.chebfit, [1, 2], [1], 0)
422 assert_raises(TypeError, cheb.chebfit, [1], [1, 2], 0)
423 assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[[1]])
424 assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[1, 1])
425 assert_raises(ValueError, cheb.chebfit, [1], [1], [-1,])
426 assert_raises(ValueError, cheb.chebfit, [1], [1], [2, -1, 6])
427 assert_raises(TypeError, cheb.chebfit, [1], [1], [])
428
429 # Test fit
430 x = np.linspace(0, 2)
431 y = f(x)
432 #
433 coef3 = cheb.chebfit(x, y, 3)
434 assert_equal(len(coef3), 4)
435 assert_almost_equal(cheb.chebval(x, coef3), y)
436 coef3 = cheb.chebfit(x, y, [0, 1, 2, 3])
437 assert_equal(len(coef3), 4)
438 assert_almost_equal(cheb.chebval(x, coef3), y)
439 #
440 coef4 = cheb.chebfit(x, y, 4)
441 assert_equal(len(coef4), 5)
442 assert_almost_equal(cheb.chebval(x, coef4), y)
443 coef4 = cheb.chebfit(x, y, [0, 1, 2, 3, 4])
444 assert_equal(len(coef4), 5)
445 assert_almost_equal(cheb.chebval(x, coef4), y)
446 # check things still work if deg is not in strict increasing
447 coef4 = cheb.chebfit(x, y, [2, 3, 4, 1, 0])
448 assert_equal(len(coef4), 5)
449 assert_almost_equal(cheb.chebval(x, coef4), y)
450 #
451 coef2d = cheb.chebfit(x, np.array([y, y]).T, 3)
452 assert_almost_equal(coef2d, np.array([coef3, coef3]).T)
453 coef2d = cheb.chebfit(x, np.array([y, y]).T, [0, 1, 2, 3])
454 assert_almost_equal(coef2d, np.array([coef3, coef3]).T)
455 # test weighting
456 w = np.zeros_like(x)
457 yw = y.copy()
458 w[1::2] = 1
459 y[0::2] = 0
460 wcoef3 = cheb.chebfit(x, yw, 3, w=w)
461 assert_almost_equal(wcoef3, coef3)
462 wcoef3 = cheb.chebfit(x, yw, [0, 1, 2, 3], w=w)
463 assert_almost_equal(wcoef3, coef3)
464 #
465 wcoef2d = cheb.chebfit(x, np.array([yw, yw]).T, 3, w=w)
466 assert_almost_equal(wcoef2d, np.array([coef3, coef3]).T)
467 wcoef2d = cheb.chebfit(x, np.array([yw, yw]).T, [0, 1, 2, 3], w=w)
468 assert_almost_equal(wcoef2d, np.array([coef3, coef3]).T)
469 # test scaling with complex values x points whose square
470 # is zero when summed.
471 x = [1, 1j, -1, -1j]
472 assert_almost_equal(cheb.chebfit(x, x, 1), [0, 1])
473 assert_almost_equal(cheb.chebfit(x, x, [0, 1]), [0, 1])
474 # test fitting only even polynomials
475 x = np.linspace(-1, 1)
476 y = f2(x)
477 coef1 = cheb.chebfit(x, y, 4)
478 assert_almost_equal(cheb.chebval(x, coef1), y)
479 coef2 = cheb.chebfit(x, y, [0, 2, 4])
480 assert_almost_equal(cheb.chebval(x, coef2), y)
481 assert_almost_equal(coef1, coef2)
482
483
484class TestInterpolate:
485
486 def f(self, x):
487 return x * (x - 1) * (x - 2)
488
489 def test_raises(self):
490 assert_raises(ValueError, cheb.chebinterpolate, self.f, -1)
491 assert_raises(TypeError, cheb.chebinterpolate, self.f, 10.)
492
493 def test_dimensions(self):
494 for deg in range(1, 5):
495 assert_(cheb.chebinterpolate(self.f, deg).shape == (deg + 1,))
496
497 def test_approximation(self):
498
499 def powx(x, p):
500 return x**p
501
502 x = np.linspace(-1, 1, 10)
503 for deg in range(10):
504 for p in range(deg + 1):
505 c = cheb.chebinterpolate(powx, deg, (p,))
506 assert_almost_equal(cheb.chebval(x, c), powx(x, p), decimal=12)
507
508
509class TestCompanion:
510
511 def test_raises(self):
512 assert_raises(ValueError, cheb.chebcompanion, [])
513 assert_raises(ValueError, cheb.chebcompanion, [1])
514
515 def test_dimensions(self):
516 for i in range(1, 5):
517 coef = [0] * i + [1]
518 assert_(cheb.chebcompanion(coef).shape == (i, i))
519
520 def test_linear_root(self):
521 assert_(cheb.chebcompanion([1, 2])[0, 0] == -.5)
522
523
524class TestGauss:
525
526 def test_100(self):
527 x, w = cheb.chebgauss(100)
528
529 # test orthogonality. Note that the results need to be normalized,
530 # otherwise the huge values that can arise from fast growing
531 # functions like Laguerre can be very confusing.
532 v = cheb.chebvander(x, 99)
533 vv = np.dot(v.T * w, v)
534 vd = 1 / np.sqrt(vv.diagonal())
535 vv = vd[:, None] * vv * vd
536 assert_almost_equal(vv, np.eye(100))
537
538 # check that the integral of 1 is correct
539 tgt = np.pi
540 assert_almost_equal(w.sum(), tgt)
541
542
543class TestMisc:
544
545 def test_chebfromroots(self):
546 res = cheb.chebfromroots([])
547 assert_almost_equal(trim(res), [1])
548 for i in range(1, 5):
549 roots = np.cos(np.linspace(-np.pi, 0, 2 * i + 1)[1::2])
550 tgt = [0] * i + [1]
551 res = cheb.chebfromroots(roots) * 2**(i - 1)
552 assert_almost_equal(trim(res), trim(tgt))
553
554 def test_chebroots(self):
555 assert_almost_equal(cheb.chebroots([1]), [])
556 assert_almost_equal(cheb.chebroots([1, 2]), [-.5])
557 for i in range(2, 5):
558 tgt = np.linspace(-1, 1, i)
559 res = cheb.chebroots(cheb.chebfromroots(tgt))
560 assert_almost_equal(trim(res), trim(tgt))
561
562 def test_chebtrim(self):
563 coef = [2, -1, 1, 0]
564
565 # Test exceptions
566 assert_raises(ValueError, cheb.chebtrim, coef, -1)
567
568 # Test results
569 assert_equal(cheb.chebtrim(coef), coef[:-1])
570 assert_equal(cheb.chebtrim(coef, 1), coef[:-3])
571 assert_equal(cheb.chebtrim(coef, 2), [0])
572
573 def test_chebline(self):
574 assert_equal(cheb.chebline(3, 4), [3, 4])
575
576 def test_cheb2poly(self):
577 for i in range(10):
578 assert_almost_equal(cheb.cheb2poly([0] * i + [1]), Tlist[i])
579
580 def test_poly2cheb(self):
581 for i in range(10):
582 assert_almost_equal(cheb.poly2cheb(Tlist[i]), [0] * i + [1])
583
584 def test_weight(self):
585 x = np.linspace(-1, 1, 11)[1:-1]
586 tgt = 1. / (np.sqrt(1 + x) * np.sqrt(1 - x))
587 res = cheb.chebweight(x)
588 assert_almost_equal(res, tgt)
589
590 def test_chebpts1(self):
591 # test exceptions
592 assert_raises(ValueError, cheb.chebpts1, 1.5)
593 assert_raises(ValueError, cheb.chebpts1, 0)
594
595 # test points
596 tgt = [0]
597 assert_almost_equal(cheb.chebpts1(1), tgt)
598 tgt = [-0.70710678118654746, 0.70710678118654746]
599 assert_almost_equal(cheb.chebpts1(2), tgt)
600 tgt = [-0.86602540378443871, 0, 0.86602540378443871]
601 assert_almost_equal(cheb.chebpts1(3), tgt)
602 tgt = [-0.9238795325, -0.3826834323, 0.3826834323, 0.9238795325]
603 assert_almost_equal(cheb.chebpts1(4), tgt)
604
605 def test_chebpts2(self):
606 # test exceptions
607 assert_raises(ValueError, cheb.chebpts2, 1.5)
608 assert_raises(ValueError, cheb.chebpts2, 1)
609
610 # test points
611 tgt = [-1, 1]
612 assert_almost_equal(cheb.chebpts2(2), tgt)
613 tgt = [-1, 0, 1]
614 assert_almost_equal(cheb.chebpts2(3), tgt)
615 tgt = [-1, -0.5, .5, 1]
616 assert_almost_equal(cheb.chebpts2(4), tgt)
617 tgt = [-1.0, -0.707106781187, 0, 0.707106781187, 1.0]
618 assert_almost_equal(cheb.chebpts2(5), tgt)
619 