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

Method test_poly1d_math

numpy/lib/tests/test_polynomial.py:51–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

49 assert_equal(q(5), 86.0)
50
51 def test_poly1d_math(self):
52 # here we use some simple coeffs to make calculations easier
53 p = np.poly1d([1., 2, 4])
54 q = np.poly1d([4., 2, 1])
55 assert_equal(p / q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75])))
56 assert_equal(p.integ(), np.poly1d([1 / 3, 1., 4., 0.]))
57 assert_equal(p.integ(1), np.poly1d([1 / 3, 1., 4., 0.]))
58
59 p = np.poly1d([1., 2, 3])
60 q = np.poly1d([3., 2, 1])
61 assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.]))
62 assert_equal(p + q, np.poly1d([4., 4., 4.]))
63 assert_equal(p - q, np.poly1d([-2., 0., 2.]))
64 assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214.,
65 312., 324., 216., 81.]))
66 assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.]))
67 assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.]))
68 assert_equal(p.deriv(), np.poly1d([2., 2.]))
69 assert_equal(p.deriv(2), np.poly1d([2.]))
70 assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])),
71 (np.poly1d([1., -1.]), np.poly1d([0.])))
72
73 @pytest.mark.parametrize("type_code", TYPE_CODES)
74 def test_poly1d_misc(self, type_code: str) -> None:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
integMethod · 0.45
derivMethod · 0.45

Tested by

no test coverage detected