(self)
| 121 | y = polyval(x, [1., 2., 3.]) |
| 122 | |
| 123 | def test_legval(self): |
| 124 | #check empty input |
| 125 | assert_equal(leg.legval([], [1]).size, 0) |
| 126 | |
| 127 | #check normal input) |
| 128 | x = np.linspace(-1, 1) |
| 129 | y = [polyval(x, c) for c in Llist] |
| 130 | for i in range(10): |
| 131 | msg = f"At i={i}" |
| 132 | tgt = y[i] |
| 133 | res = leg.legval(x, [0]*i + [1]) |
| 134 | assert_almost_equal(res, tgt, err_msg=msg) |
| 135 | |
| 136 | #check that shape is preserved |
| 137 | for i in range(3): |
| 138 | dims = [2]*i |
| 139 | x = np.zeros(dims) |
| 140 | assert_equal(leg.legval(x, [1]).shape, dims) |
| 141 | assert_equal(leg.legval(x, [1, 0]).shape, dims) |
| 142 | assert_equal(leg.legval(x, [1, 0, 0]).shape, dims) |
| 143 | |
| 144 | def test_legval2d(self): |
| 145 | x1, x2, x3 = self.x |
nothing calls this directly
no test coverage detected