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

Function test_add

numpy/polynomial/tests/test_classes.py:210–229  ·  view source on GitHub ↗
(Poly)

Source from the content-addressed store, hash-verified

208
209
210def test_add(Poly):
211 # This checks commutation, not numerical correctness
212 c1 = list(random((4,)) + .5)
213 c2 = list(random((3,)) + .5)
214 p1 = Poly(c1)
215 p2 = Poly(c2)
216 p3 = p1 + p2
217 assert_poly_almost_equal(p2 + p1, p3)
218 assert_poly_almost_equal(p1 + c2, p3)
219 assert_poly_almost_equal(c2 + p1, p3)
220 assert_poly_almost_equal(p1 + tuple(c2), p3)
221 assert_poly_almost_equal(tuple(c2) + p1, p3)
222 assert_poly_almost_equal(p1 + np.array(c2), p3)
223 assert_poly_almost_equal(np.array(c2) + p1, p3)
224 assert_raises(TypeError, op.add, p1, Poly([0], domain=Poly.domain + 1))
225 assert_raises(TypeError, op.add, p1, Poly([0], window=Poly.window + 1))
226 if Poly is Polynomial:
227 assert_raises(TypeError, op.add, p1, Chebyshev([0]))
228 else:
229 assert_raises(TypeError, op.add, p1, Polynomial([0]))
230
231
232def test_sub(Poly):

Callers

nothing calls this directly

Calls 5

assert_raisesFunction · 0.90
ChebyshevClass · 0.90
PolynomialClass · 0.90
PolyFunction · 0.85
assert_poly_almost_equalFunction · 0.85

Tested by

no test coverage detected