(self)
| 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: |
nothing calls this directly
no test coverage detected