| 548 | ) |
| 549 | )) |
| 550 | def test_division_int_reduce(self, dtype, ex_val): |
| 551 | fo = np.iinfo(dtype) |
| 552 | a = eval(ex_val) |
| 553 | lst = a.tolist() |
| 554 | c_div = lambda n, d: ( |
| 555 | 0 if d == 0 or (n and n == fo.min and d == -1) else n//d |
| 556 | ) |
| 557 | |
| 558 | with np.errstate(divide='ignore'): |
| 559 | div_a = np.floor_divide.reduce(a) |
| 560 | div_lst = reduce(c_div, lst) |
| 561 | msg = "Reduce floor integer division check" |
| 562 | assert div_a == div_lst, msg |
| 563 | |
| 564 | with np.errstate(divide='raise', over='raise'): |
| 565 | with pytest.raises(FloatingPointError, |
| 566 | match="divide by zero encountered in reduce"): |
| 567 | np.floor_divide.reduce(np.arange(-100, 100).astype(dtype)) |
| 568 | if fo.min: |
| 569 | with pytest.raises(FloatingPointError, |
| 570 | match='overflow encountered in reduce'): |
| 571 | np.floor_divide.reduce( |
| 572 | np.array([fo.min, 1, -1], dtype=dtype) |
| 573 | ) |
| 574 | |
| 575 | @pytest.mark.parametrize( |
| 576 | "dividend,divisor,quotient", |