MCPcopy Create free account
hub / github.com/numpy/numpy / test_legval

Method test_legval

numpy/polynomial/tests/test_legendre.py:123–142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
polyvalFunction · 0.90
assert_almost_equalFunction · 0.90
linspaceMethod · 0.80

Tested by

no test coverage detected