(self)
| 126 | assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a)))))) |
| 127 | |
| 128 | def test_roots(self): |
| 129 | assert_array_equal(np.roots([1, 0, 0]), [0, 0]) |
| 130 | |
| 131 | # Testing for larger root values |
| 132 | for i in np.logspace(10, 25, num=1000, base=10): |
| 133 | tgt = np.array([-1, 1, i]) |
| 134 | res = np.sort(np.roots(poly.polyfromroots(tgt)[::-1])) |
| 135 | # Adapting the expected precision according to the root value, |
| 136 | # to take into account numerical calculation error |
| 137 | assert_almost_equal(res, tgt, 14 - int(np.log10(i))) |
| 138 | |
| 139 | for i in np.logspace(10, 25, num=1000, base=10): |
| 140 | tgt = np.array([-1, 1.01, i]) |
| 141 | res = np.sort(np.roots(poly.polyfromroots(tgt)[::-1])) |
| 142 | # Adapting the expected precision according to the root value, |
| 143 | # to take into account numerical calculation error |
| 144 | assert_almost_equal(res, tgt, 14 - int(np.log10(i))) |
| 145 | |
| 146 | @pytest.mark.parametrize("dtyp", [int, np.float32, np.float64]) |
| 147 | def test_roots_dtype(self, dtyp): |
nothing calls this directly
no test coverage detected