Skip to content

Commit 2d8d313

Browse files
authored
TST: Test Nullable int floordiv by 0 (#48229)
1 parent 6787b8b commit 2d8d313

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

doc/source/whatsnew/v1.5.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,8 @@ Time Zones
10111011
Numeric
10121012
^^^^^^^
10131013
- Bug in operations with array-likes with ``dtype="boolean"`` and :attr:`NA` incorrectly altering the array in-place (:issue:`45421`)
1014+
- Bug in arithmetic operations with nullable types without :attr:`NA` values not matching the same operation with non-nullable types (:issue:`48223`)
1015+
- Bug in ``floordiv`` when dividing by ``IntegerDtype`` ``0`` would return ``0`` instead of ``inf`` (:issue:`48223`)
10141016
- Bug in division, ``pow`` and ``mod`` operations on array-likes with ``dtype="boolean"`` not being like their ``np.bool_`` counterparts (:issue:`46063`)
10151017
- Bug in multiplying a :class:`Series` with ``IntegerDtype`` or ``FloatingDtype`` by an array-like with ``timedelta64[ns]`` dtype incorrectly raising (:issue:`45622`)
10161018
- 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`)

pandas/tests/arrays/integer/test_arithmetic.py

+15
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ def test_floordiv(dtype):
7575
tm.assert_extension_array_equal(result, expected)
7676

7777

78+
def test_floordiv_by_int_zero_no_mask(any_int_ea_dtype):
79+
# GH 48223: Aligns with non-masked floordiv
80+
# but differs from numpy
81+
# https://github.com/pandas-dev/pandas/issues/30188#issuecomment-564452740
82+
ser = pd.Series([0, 1], dtype=any_int_ea_dtype)
83+
result = 1 // ser
84+
expected = pd.Series([np.inf, 1.0], dtype="Float64")
85+
tm.assert_series_equal(result, expected)
86+
87+
ser_non_nullable = ser.astype(ser.dtype.numpy_dtype)
88+
result = 1 // ser_non_nullable
89+
expected = expected.astype(np.float64)
90+
tm.assert_series_equal(result, expected)
91+
92+
7893
def test_mod(dtype):
7994
a = pd.array([1, 2, 3, None, 5], dtype=dtype)
8095
b = pd.array([0, 1, None, 3, 4], dtype=dtype)

0 commit comments

Comments
 (0)