(Poly)
| 309 | |
| 310 | |
| 311 | def 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 | |
| 350 | def test_mod(Poly): |
nothing calls this directly
no test coverage detected
searching dependent graphs…