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

Function test_mod

numpy/polynomial/tests/test_classes.py:332–356  ·  view source on GitHub ↗
(Poly)

Source from the content-addressed store, hash-verified

330
331
332def test_mod(Poly):
333 # This checks commutation, not numerical correctness
334 c1 = list(random((4,)) + .5)
335 c2 = list(random((3,)) + .5)
336 c3 = list(random((2,)) + .5)
337 p1 = Poly(c1)
338 p2 = Poly(c2)
339 p3 = Poly(c3)
340 p4 = p1 * p2 + p3
341 c4 = list(p4.coef)
342 assert_poly_almost_equal(p4 % p2, p3)
343 assert_poly_almost_equal(p4 % c2, p3)
344 assert_poly_almost_equal(c4 % p2, p3)
345 assert_poly_almost_equal(p4 % tuple(c2), p3)
346 assert_poly_almost_equal(tuple(c4) % p2, p3)
347 assert_poly_almost_equal(p4 % np.array(c2), p3)
348 assert_poly_almost_equal(np.array(c4) % p2, p3)
349 assert_poly_almost_equal(2 % p2, Poly([2]))
350 assert_poly_almost_equal(p2 % 2, Poly([0]))
351 assert_raises(TypeError, op.mod, p1, Poly([0], domain=Poly.domain + 1))
352 assert_raises(TypeError, op.mod, p1, Poly([0], window=Poly.window + 1))
353 if Poly is Polynomial:
354 assert_raises(TypeError, op.mod, p1, Chebyshev([0]))
355 else:
356 assert_raises(TypeError, op.mod, p1, Polynomial([0]))
357
358
359def test_divmod(Poly):

Callers

nothing calls this directly

Calls 5

assert_raisesFunction · 0.90
ChebyshevClass · 0.90
PolynomialClass · 0.90
PolyFunction · 0.85
assert_poly_almost_equalFunction · 0.85

Tested by

no test coverage detected