Skip to content

Commit 5694ab6

Browse files
Daniel SaxtonDaniel Saxton
Daniel Saxton
authored and
Daniel Saxton
committed
Update test scripts
1 parent 99e6080 commit 5694ab6

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

pandas/tests/arrays/test_integer.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1074,15 +1074,21 @@ def test_cut(bins, right, include_lowest):
10741074
tm.assert_categorical_equal(result, expected)
10751075

10761076

1077-
@pytest.mark.parametrize("q", [2, 5, 10])
1078-
def test_qcut_nullable_integer(q, any_nullable_int_dtype):
1079-
arr = pd.array(np.arange(100), dtype=any_nullable_int_dtype)
1080-
arr[::2] = pd.NA
1077+
def test_array_setitem_nullable_boolean_mask():
1078+
# GH 31446
1079+
ser = pd.Series([1, 2], dtype="Int64")
1080+
result = ser.where(ser > 1)
1081+
expected = pd.Series([pd.NA, 2], dtype="Int64")
1082+
tm.assert_series_equal(result, expected)
10811083

1082-
result = pd.qcut(arr, q)
1083-
expected = pd.qcut(arr.astype(float), q)
10841084

1085-
tm.assert_categorical_equal(result, expected)
1085+
def test_array_setitem():
1086+
# GH 31446
1087+
arr = pd.Series([1, 2], dtype="Int64").array
1088+
arr[arr > 1] = 1
1089+
1090+
expected = pd.array([1, 1], dtype="Int64")
1091+
tm.assert_extension_array_equal(arr, expected)
10861092

10871093

10881094
# TODO(jreback) - these need testing / are broken

pandas/tests/reshape/test_qcut.py

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
from pandas import (
7+
NA,
78
Categorical,
89
DatetimeIndex,
910
Interval,
@@ -12,6 +13,7 @@
1213
Series,
1314
TimedeltaIndex,
1415
Timestamp,
16+
array,
1517
cut,
1618
date_range,
1719
isna,
@@ -286,3 +288,14 @@ def test_qcut_bool_coercion_to_int(bins, box, compare):
286288
expected = qcut(data_expected, bins, duplicates="drop")
287289
result = qcut(data_result, bins, duplicates="drop")
288290
compare(result, expected)
291+
292+
293+
@pytest.mark.parametrize("q", [2, 5, 10])
294+
def test_qcut_nullable_integer(q, any_nullable_int_dtype):
295+
arr = array(np.arange(100), dtype=any_nullable_int_dtype)
296+
arr[::2] = NA
297+
298+
result = qcut(arr, q)
299+
expected = qcut(arr.astype(float), q)
300+
301+
tm.assert_categorical_equal(result, expected)

0 commit comments

Comments
 (0)