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

Function test_truediv

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

Source from the content-addressed store, hash-verified

303
304
305def test_truediv(Poly):
306 # true division is valid only if the denominator is a Number and
307 # not a python bool.
308 p1 = Poly([1,2,3])
309 p2 = p1 * 5
310
311 for stype in np.ScalarType:
312 if not issubclass(stype, Number) or issubclass(stype, bool):
313 continue
314 s = stype(5)
315 assert_poly_almost_equal(op.truediv(p2, s), p1)
316 assert_raises(TypeError, op.truediv, s, p2)
317 for stype in (int, float):
318 s = stype(5)
319 assert_poly_almost_equal(op.truediv(p2, s), p1)
320 assert_raises(TypeError, op.truediv, s, p2)
321 for stype in [complex]:
322 s = stype(5, 0)
323 assert_poly_almost_equal(op.truediv(p2, s), p1)
324 assert_raises(TypeError, op.truediv, s, p2)
325 for s in [tuple(), list(), dict(), bool(), np.array([1])]:
326 assert_raises(TypeError, op.truediv, p2, s)
327 assert_raises(TypeError, op.truediv, s, p2)
328 for ptype in classes:
329 assert_raises(TypeError, op.truediv, p2, ptype(1))
330
331
332def test_mod(Poly):

Callers

nothing calls this directly

Calls 3

assert_raisesFunction · 0.90
PolyFunction · 0.85
assert_poly_almost_equalFunction · 0.85

Tested by

no test coverage detected