Skip to content

Commit 0ccc42a

Browse files
jbrockmendelYYYasin19
authored andcommitted
TST: catch some test warnings (pandas-dev#48031)
1 parent db4b26f commit 0ccc42a

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

pandas/tests/apply/test_frame_apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ def test_apply_on_empty_dataframe():
15831583
# GH 39111
15841584
df = DataFrame({"a": [1, 2], "b": [3, 0]})
15851585
result = df.head(0).apply(lambda x: max(x["a"], x["b"]), axis=1)
1586-
expected = Series([])
1586+
expected = Series([], dtype=np.float64)
15871587
tm.assert_series_equal(result, expected)
15881588

15891589

pandas/tests/series/methods/test_fillna.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,16 @@ def test_fillna_consistency(self):
152152
tm.assert_series_equal(result, expected)
153153

154154
# where (we ignore the errors=)
155-
result = ser.where(
156-
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
157-
)
155+
with tm.assert_produces_warning(FutureWarning, match="the 'errors' keyword"):
156+
result = ser.where(
157+
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
158+
)
158159
tm.assert_series_equal(result, expected)
159160

160-
result = ser.where(
161-
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
162-
)
161+
with tm.assert_produces_warning(FutureWarning, match="the 'errors' keyword"):
162+
result = ser.where(
163+
[True, False], Timestamp("20130101", tz="US/Eastern"), errors="ignore"
164+
)
163165
tm.assert_series_equal(result, expected)
164166

165167
# with a non-datetime

pandas/tests/series/test_ufunc.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -434,19 +434,22 @@ def __repr__(self) -> str:
434434

435435
def test_outer():
436436
# https://github.com/pandas-dev/pandas/issues/27186
437-
s = pd.Series([1, 2, 3])
438-
o = np.array([1, 2, 3])
437+
ser = pd.Series([1, 2, 3])
438+
obj = np.array([1, 2, 3])
439439

440440
with pytest.raises(NotImplementedError, match=tm.EMPTY_STRING_PATTERN):
441-
np.subtract.outer(s, o)
441+
np.subtract.outer(ser, obj)
442442

443443

444444
def test_np_matmul():
445445
# GH26650
446446
df1 = pd.DataFrame(data=[[-1, 1, 10]])
447447
df2 = pd.DataFrame(data=[-1, 1, 10])
448448
expected_result = pd.DataFrame(data=[102])
449+
450+
with tm.assert_produces_warning(FutureWarning, match="on non-aligned"):
451+
result = np.matmul(df1, df2)
449452
tm.assert_frame_equal(
450453
expected_result,
451-
np.matmul(df1, df2),
454+
result,
452455
)

pandas/tests/util/test_assert_series_equal.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ def test_series_equal_index_mismatch(check_index):
184184

185185

186186
def test_series_invalid_param_combination():
187+
left = Series(dtype=object)
188+
right = Series(dtype=object)
187189
with pytest.raises(
188190
ValueError, match="check_like must be False if check_index is False"
189191
):
190-
tm.assert_series_equal(Series(), Series(), check_index=False, check_like=True)
192+
tm.assert_series_equal(left, right, check_index=False, check_like=True)
191193

192194

193195
def test_series_equal_length_mismatch(rtol):

pandas/tests/window/moments/test_moments_consistency_ewm.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,10 @@ def test_ewm_consistency_series_cov_corr(
220220

221221
# check that corr(x, y) == cov(x, y) / (std(x) *
222222
# std(y))
223-
corr_x_y = series_data.ewm(
224-
com=com, min_periods=min_periods, adjust=adjust, ignore_na=ignore_na
225-
).corr(series_data, bias=bias)
223+
with tm.assert_produces_warning(FutureWarning, match="Passing additional kwargs"):
224+
corr_x_y = series_data.ewm(
225+
com=com, min_periods=min_periods, adjust=adjust, ignore_na=ignore_na
226+
).corr(series_data, bias=bias)
226227
std_x = series_data.ewm(
227228
com=com, min_periods=min_periods, adjust=adjust, ignore_na=ignore_na
228229
).std(bias=bias)

0 commit comments

Comments
 (0)