(Poly)
| 348 | |
| 349 | |
| 350 | def test_mod(Poly): |
| 351 | # This checks commutation, not numerical correctness |
| 352 | c1 = list(random((4,)) + .5) |
| 353 | c2 = list(random((3,)) + .5) |
| 354 | c3 = list(random((2,)) + .5) |
| 355 | p1 = Poly(c1) |
| 356 | p2 = Poly(c2) |
| 357 | p3 = Poly(c3) |
| 358 | p4 = p1 * p2 + p3 |
| 359 | c4 = list(p4.coef) |
| 360 | assert_poly_almost_equal(p4 % p2, p3) |
| 361 | assert_poly_almost_equal(p4 % c2, p3) |
| 362 | assert_poly_almost_equal(c4 % p2, p3) |
| 363 | assert_poly_almost_equal(p4 % tuple(c2), p3) |
| 364 | assert_poly_almost_equal(tuple(c4) % p2, p3) |
| 365 | assert_poly_almost_equal(p4 % np.array(c2), p3) |
| 366 | assert_poly_almost_equal(np.array(c4) % p2, p3) |
| 367 | assert_poly_almost_equal(2 % p2, Poly([2])) |
| 368 | assert_poly_almost_equal(p2 % 2, Poly([0])) |
| 369 | assert_raises(TypeError, op.mod, p1, Poly([0], domain=Poly.domain + 1)) |
| 370 | assert_raises(TypeError, op.mod, p1, Poly([0], window=Poly.window + 1)) |
| 371 | if Poly is Polynomial: |
| 372 | assert_raises(TypeError, op.mod, p1, Chebyshev([0])) |
| 373 | else: |
| 374 | assert_raises(TypeError, op.mod, p1, Polynomial([0])) |
| 375 | |
| 376 | |
| 377 | def test_divmod(Poly): |
nothing calls this directly
no test coverage detected
searching dependent graphs…