(self)
| 218 | class TestIntegral: |
| 219 | |
| 220 | def test_chebint(self): |
| 221 | # check exceptions |
| 222 | assert_raises(TypeError, cheb.chebint, [0], .5) |
| 223 | assert_raises(ValueError, cheb.chebint, [0], -1) |
| 224 | assert_raises(ValueError, cheb.chebint, [0], 1, [0, 0]) |
| 225 | assert_raises(ValueError, cheb.chebint, [0], lbnd=[0]) |
| 226 | assert_raises(ValueError, cheb.chebint, [0], scl=[0]) |
| 227 | assert_raises(TypeError, cheb.chebint, [0], axis=.5) |
| 228 | |
| 229 | # test integration of zero polynomial |
| 230 | for i in range(2, 5): |
| 231 | k = [0]*(i - 2) + [1] |
| 232 | res = cheb.chebint([0], m=i, k=k) |
| 233 | assert_almost_equal(res, [0, 1]) |
| 234 | |
| 235 | # check single integration with integration constant |
| 236 | for i in range(5): |
| 237 | scl = i + 1 |
| 238 | pol = [0]*i + [1] |
| 239 | tgt = [i] + [0]*i + [1/scl] |
| 240 | chebpol = cheb.poly2cheb(pol) |
| 241 | chebint = cheb.chebint(chebpol, m=1, k=[i]) |
| 242 | res = cheb.cheb2poly(chebint) |
| 243 | assert_almost_equal(trim(res), trim(tgt)) |
| 244 | |
| 245 | # check single integration with integration constant and lbnd |
| 246 | for i in range(5): |
| 247 | scl = i + 1 |
| 248 | pol = [0]*i + [1] |
| 249 | chebpol = cheb.poly2cheb(pol) |
| 250 | chebint = cheb.chebint(chebpol, m=1, k=[i], lbnd=-1) |
| 251 | assert_almost_equal(cheb.chebval(-1, chebint), i) |
| 252 | |
| 253 | # check single integration with integration constant and scaling |
| 254 | for i in range(5): |
| 255 | scl = i + 1 |
| 256 | pol = [0]*i + [1] |
| 257 | tgt = [i] + [0]*i + [2/scl] |
| 258 | chebpol = cheb.poly2cheb(pol) |
| 259 | chebint = cheb.chebint(chebpol, m=1, k=[i], scl=2) |
| 260 | res = cheb.cheb2poly(chebint) |
| 261 | assert_almost_equal(trim(res), trim(tgt)) |
| 262 | |
| 263 | # check multiple integrations with default k |
| 264 | for i in range(5): |
| 265 | for j in range(2, 5): |
| 266 | pol = [0]*i + [1] |
| 267 | tgt = pol[:] |
| 268 | for k in range(j): |
| 269 | tgt = cheb.chebint(tgt, m=1) |
| 270 | res = cheb.chebint(pol, m=j) |
| 271 | assert_almost_equal(trim(res), trim(tgt)) |
| 272 | |
| 273 | # check multiple integrations with defined k |
| 274 | for i in range(5): |
| 275 | for j in range(2, 5): |
| 276 | pol = [0]*i + [1] |
| 277 | tgt = pol[:] |
nothing calls this directly
no test coverage detected