(Poly)
| 375 | |
| 376 | |
| 377 | def test_divmod(Poly): |
| 378 | # This checks commutation, not numerical correctness |
| 379 | c1 = list(random((4,)) + .5) |
| 380 | c2 = list(random((3,)) + .5) |
| 381 | c3 = list(random((2,)) + .5) |
| 382 | p1 = Poly(c1) |
| 383 | p2 = Poly(c2) |
| 384 | p3 = Poly(c3) |
| 385 | p4 = p1 * p2 + p3 |
| 386 | c4 = list(p4.coef) |
| 387 | quo, rem = divmod(p4, p2) |
| 388 | assert_poly_almost_equal(quo, p1) |
| 389 | assert_poly_almost_equal(rem, p3) |
| 390 | quo, rem = divmod(p4, c2) |
| 391 | assert_poly_almost_equal(quo, p1) |
| 392 | assert_poly_almost_equal(rem, p3) |
| 393 | quo, rem = divmod(c4, p2) |
| 394 | assert_poly_almost_equal(quo, p1) |
| 395 | assert_poly_almost_equal(rem, p3) |
| 396 | quo, rem = divmod(p4, tuple(c2)) |
| 397 | assert_poly_almost_equal(quo, p1) |
| 398 | assert_poly_almost_equal(rem, p3) |
| 399 | quo, rem = divmod(tuple(c4), p2) |
| 400 | assert_poly_almost_equal(quo, p1) |
| 401 | assert_poly_almost_equal(rem, p3) |
| 402 | quo, rem = divmod(p4, np.array(c2)) |
| 403 | assert_poly_almost_equal(quo, p1) |
| 404 | assert_poly_almost_equal(rem, p3) |
| 405 | quo, rem = divmod(np.array(c4), p2) |
| 406 | assert_poly_almost_equal(quo, p1) |
| 407 | assert_poly_almost_equal(rem, p3) |
| 408 | quo, rem = divmod(p2, 2) |
| 409 | assert_poly_almost_equal(quo, 0.5 * p2) |
| 410 | assert_poly_almost_equal(rem, Poly([0])) |
| 411 | quo, rem = divmod(2, p2) |
| 412 | assert_poly_almost_equal(quo, Poly([0])) |
| 413 | assert_poly_almost_equal(rem, Poly([2])) |
| 414 | assert_raises(TypeError, divmod, p1, Poly([0], domain=Poly.domain + 1)) |
| 415 | assert_raises(TypeError, divmod, p1, Poly([0], window=Poly.window + 1)) |
| 416 | if Poly is Polynomial: |
| 417 | assert_raises(TypeError, divmod, p1, Chebyshev([0])) |
| 418 | else: |
| 419 | assert_raises(TypeError, divmod, p1, Polynomial([0])) |
| 420 | |
| 421 | |
| 422 | def test_roots(Poly): |
nothing calls this directly
no test coverage detected
searching dependent graphs…