MCPcopy Index your code
hub / github.com/numpy/numpy / test_mod

Function test_mod

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

Source from the content-addressed store, hash-verified

348
349
350def 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
377def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…