Skip to content

Commit 76263da

Browse files
committed
wip
1 parent bb597c3 commit 76263da

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

pandas/tests/frame/indexing/test_where.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ def test_where_axis_with_upcast(self):
520520
result = df.where(mask, ser, axis="columns")
521521
tm.assert_frame_equal(result, expected)
522522

523+
result = df.copy()
523524
with pytest.raises(TypeError, match="Invalid value"):
524525
result.where(mask, ser, axis="columns", inplace=True)
525526

@@ -573,15 +574,10 @@ def test_where_axis_multiple_dtypes(self):
573574
result = df.where(mask, d1, axis="index")
574575
tm.assert_frame_equal(result, expected)
575576
result = df.copy()
576-
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
577-
return_value = result.where(mask, d1, inplace=True)
578-
assert return_value is None
579-
tm.assert_frame_equal(result, expected)
580-
result = df.copy()
581-
with tm.assert_produces_warning(FutureWarning, match="incompatible dtype"):
577+
with pytest.raises(TypeError, match="Invalid value"):
578+
result.where(mask, d1, inplace=True)
579+
with pytest.raises(TypeError, match="Invalid value"):
582580
return_value = result.where(mask, d1, inplace=True, axis="index")
583-
assert return_value is None
584-
tm.assert_frame_equal(result, expected)
585581

586582
d2 = df.copy().drop(1, axis=1)
587583
expected = df.copy()
@@ -728,11 +724,8 @@ def test_where_interval_fullop_downcast(self, frame_or_series):
728724
res = obj.where(~obj.notna(), other)
729725
tm.assert_equal(res, other)
730726

731-
with tm.assert_produces_warning(
732-
FutureWarning, match="Setting an item of incompatible dtype"
733-
):
727+
with pytest.raises(TypeError, match="Invalid value"):
734728
obj.mask(obj.notna(), other, inplace=True)
735-
tm.assert_equal(obj, other.astype(object))
736729

737730
@pytest.mark.parametrize(
738731
"dtype",
@@ -762,14 +755,10 @@ def test_where_datetimelike_noop(self, dtype):
762755

763756
res4 = df.mask(mask2, "foo")
764757
tm.assert_frame_equal(res4, df)
765-
expected = DataFrame(4, index=df.index, columns=df.columns)
766758

767759
# unlike where, Block.putmask does not downcast
768-
with tm.assert_produces_warning(
769-
FutureWarning, match="Setting an item of incompatible dtype"
770-
):
760+
with pytest.raises(TypeError, match="Invalid value"):
771761
df.mask(~mask2, 4, inplace=True)
772-
tm.assert_frame_equal(df, expected.astype(object))
773762

774763

775764
def test_where_int_downcasting_deprecated():
@@ -923,11 +912,8 @@ def test_where_period_invalid_na(frame_or_series, as_cat, request):
923912
result = obj.mask(mask, tdnat)
924913
tm.assert_equal(result, expected)
925914

926-
with tm.assert_produces_warning(
927-
FutureWarning, match="Setting an item of incompatible dtype"
928-
):
915+
with pytest.raises(TypeError, match="Invalid value"):
929916
obj.mask(mask, tdnat, inplace=True)
930-
tm.assert_equal(obj, expected)
931917

932918

933919
def test_where_nullable_invalid_na(frame_or_series, any_numeric_ea_dtype):
@@ -1009,9 +995,7 @@ def test_where_dt64_2d():
1009995
"B": dta[:, 1],
1010996
}
1011997
)
1012-
with tm.assert_produces_warning(
1013-
FutureWarning, match="Setting an item of incompatible dtype"
1014-
):
998+
with pytest.raises(TypeError, match="Invalid value"):
1015999
_check_where_equivalences(df, mask, other, expected)
10161000

10171001
# setting nothing in either column

0 commit comments

Comments
 (0)