MCPcopy Index your code
hub / github.com/numpy/numpy / test_truediv

Function test_truediv

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

Source from the content-addressed store, hash-verified

309
310
311def test_truediv(Poly):
312 # true division is valid only if the denominator is a Number and
313 # not a python bool.
314 p1 = Poly([1, 2, 3])
315 p2 = p1 * 5
316
317 for stype in np.ScalarType:
318 if (
319 not issubclass(stype, Number)
320 or issubclass(stype, bool)
321 or issubclass(stype, np.timedelta64)
322 ):
323 continue
324 s = stype(5)
325 assert_poly_almost_equal(op.truediv(p2, s), p1)
326 assert_raises(TypeError, op.truediv, s, p2)
327 for stype in (int, float):
328 s = stype(5)
329 assert_poly_almost_equal(op.truediv(p2, s), p1)
330 assert_raises(TypeError, op.truediv, s, p2)
331 for stype in [complex]:
332 s = stype(5, 0)
333 assert_poly_almost_equal(op.truediv(p2, s), p1)
334 assert_raises(TypeError, op.truediv, s, p2)
335 for stype in [np.timedelta64]:
336 s = stype(5, 'D')
337 with pytest.warns(
338 DeprecationWarning,
339 match="The 'generic' unit for NumPy timedelta is deprecated",
340 ):
341 assert_poly_almost_equal(op.truediv(p2, s), p1)
342 assert_raises(TypeError, op.truediv, s, p2)
343 for s in [(), [], {}, False, np.array([1])]:
344 assert_raises(TypeError, op.truediv, p2, s)
345 assert_raises(TypeError, op.truediv, s, p2)
346 for ptype in classes:
347 assert_raises(TypeError, op.truediv, p2, ptype(1))
348
349
350def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…