Skip to content

Commit 4840f66

Browse files
committed
Added message to mask deprec test
1 parent 383202b commit 4840f66

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

pandas/tests/frame/indexing/test_mask.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,19 @@ def test_mask_dtype_bool_conversion(self):
9292

9393
def test_mask_pos_args_deprecation(self):
9494
# https://github.com/pandas-dev/pandas/issues/41485
95-
df = DataFrame(np.random.randn(5, 5))
96-
cond = df > 0
97-
other = DataFrame(np.random.randn(5, 3))
95+
df = DataFrame({"a": range(5)})
96+
97+
expected = DataFrame({"a": [-1, 1, -1, 3, -1]})
98+
cond = df % 2 == 0
99+
100+
msg = (
101+
r"In a future version of pandas all arguments of NDFrame.mask except for "
102+
r"the arguments 'cond' and 'other' will be keyword-only"
103+
)
98104

99-
with tm.assert_produces_warning(FutureWarning):
100-
result = df.mask(cond, other, False)
105+
with tm.assert_produces_warning(FutureWarning, match=msg):
106+
result = df.mask(cond, -1, False)
101107

102-
expected = df.mask(cond, other=other, inplace=False)
103108
tm.assert_frame_equal(result, expected)
104109

105110

pandas/tests/series/indexing/test_mask.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ def test_mask_stringdtype():
9090

9191
def test_mask_pos_args_deprecation():
9292
# https://github.com/pandas-dev/pandas/issues/41485
93-
s = Series(np.random.randn(6))
94-
cond = s > 0
93+
s = Series(range(5))
94+
expected = Series([-1, 1, -1, 3, -1])
95+
cond = s % 2 == 0
96+
97+
msg = (
98+
r"In a future version of pandas all arguments of NDFrame.mask except for "
99+
r"the arguments 'cond' and 'other' will be keyword-only"
100+
)
95101

96-
with tm.assert_produces_warning(FutureWarning):
97-
result = s.mask(cond, np.nan, False)
102+
with tm.assert_produces_warning(FutureWarning, match=msg):
103+
result = s.mask(cond, -1, False)
98104

99-
expected = s.mask(cond, other=np.nan, inplace=False)
100105
tm.assert_series_equal(result, expected)

path_to_file.xlsx

-5.45 KB
Binary file not shown.

0 commit comments

Comments
 (0)