Skip to content

Commit

Permalink
TST: Test Nullable int floordiv by 0 (pandas-dev#48229)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored and noatamir committed Nov 9, 2022
1 parent 24c83dc commit e0c2406
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,8 @@ Time Zones
Numeric
^^^^^^^
- Bug in operations with array-likes with ``dtype="boolean"`` and :attr:`NA` incorrectly altering the array in-place (:issue:`45421`)
- Bug in arithmetic operations with nullable types without :attr:`NA` values not matching the same operation with non-nullable types (:issue:`48223`)
- Bug in ``floordiv`` when dividing by ``IntegerDtype`` ``0`` would return ``0`` instead of ``inf`` (:issue:`48223`)
- Bug in division, ``pow`` and ``mod`` operations on array-likes with ``dtype="boolean"`` not being like their ``np.bool_`` counterparts (:issue:`46063`)
- Bug in multiplying a :class:`Series` with ``IntegerDtype`` or ``FloatingDtype`` by an array-like with ``timedelta64[ns]`` dtype incorrectly raising (:issue:`45622`)
- Bug in :meth:`mean` where the optional dependency ``bottleneck`` causes precision loss linear in the length of the array. ``bottleneck`` has been disabled for :meth:`mean` improving the loss to log-linear but may result in a performance decrease. (:issue:`42878`)
Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/arrays/integer/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ def test_floordiv(dtype):
tm.assert_extension_array_equal(result, expected)


def test_floordiv_by_int_zero_no_mask(any_int_ea_dtype):
# GH 48223: Aligns with non-masked floordiv
# but differs from numpy
# https://github.com/pandas-dev/pandas/issues/30188#issuecomment-564452740
ser = pd.Series([0, 1], dtype=any_int_ea_dtype)
result = 1 // ser
expected = pd.Series([np.inf, 1.0], dtype="Float64")
tm.assert_series_equal(result, expected)

ser_non_nullable = ser.astype(ser.dtype.numpy_dtype)
result = 1 // ser_non_nullable
expected = expected.astype(np.float64)
tm.assert_series_equal(result, expected)


def test_mod(dtype):
a = pd.array([1, 2, 3, None, 5], dtype=dtype)
b = pd.array([0, 1, None, 3, 4], dtype=dtype)
Expand Down

0 comments on commit e0c2406

Please sign in to comment.