Skip to content

Commit 1bf4cee

Browse files
Daniel SaxtonDaniel Saxton
Daniel Saxton
authored and
Daniel Saxton
committed
Move test_cut for nullable int
1 parent e26a13b commit 1bf4cee

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pandas/tests/arrays/test_integer.py

-13
Original file line numberDiff line numberDiff line change
@@ -1061,19 +1061,6 @@ def test_value_counts_na():
10611061
tm.assert_series_equal(result, expected)
10621062

10631063

1064-
@pytest.mark.parametrize("bins", [3, [0, 5, 15]])
1065-
@pytest.mark.parametrize("right", [True, False])
1066-
@pytest.mark.parametrize("include_lowest", [True, False])
1067-
def test_cut(bins, right, include_lowest):
1068-
a = np.random.randint(0, 10, size=50).astype(object)
1069-
a[::2] = np.nan
1070-
result = pd.cut(
1071-
pd.array(a, dtype="Int64"), bins, right=right, include_lowest=include_lowest
1072-
)
1073-
expected = pd.cut(a, bins, right=right, include_lowest=include_lowest)
1074-
tm.assert_categorical_equal(result, expected)
1075-
1076-
10771064
def test_array_setitem_nullable_boolean_mask():
10781065
# GH 31446
10791066
ser = pd.Series([1, 2], dtype="Int64")

pandas/tests/reshape/test_cut.py

+13
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,16 @@ def test_cut_incorrect_labels(labels):
612612
msg = "Bin labels must either be False, None or passed in as a list-like argument"
613613
with pytest.raises(ValueError, match=msg):
614614
cut(values, 4, labels=labels)
615+
616+
617+
@pytest.mark.parametrize("bins", [3, [0, 5, 15]])
618+
@pytest.mark.parametrize("right", [True, False])
619+
@pytest.mark.parametrize("include_lowest", [True, False])
620+
def test_cut_nullable_integer(bins, right, include_lowest):
621+
a = np.random.randint(0, 10, size=50).astype(object)
622+
a[::2] = np.nan
623+
result = cut(
624+
pd.array(a, dtype="Int64"), bins, right=right, include_lowest=include_lowest
625+
)
626+
expected = cut(a, bins, right=right, include_lowest=include_lowest)
627+
tm.assert_categorical_equal(result, expected)

0 commit comments

Comments
 (0)