Skip to content

Commit a7aa063

Browse files
CI: silence numpy-dev failures (pandas-dev#32025)
1 parent 12a7d65 commit a7aa063

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

pandas/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
_np_version_under1p16,
2626
_np_version_under1p17,
2727
_np_version_under1p18,
28+
_is_numpy_dev,
2829
)
2930

3031
try:

pandas/tests/api/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class TestPDApi(Base):
198198
"_np_version_under1p16",
199199
"_np_version_under1p17",
200200
"_np_version_under1p18",
201+
"_is_numpy_dev",
201202
"_testing",
202203
"_tslib",
203204
"_typing",

pandas/tests/frame/test_cumulative.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"""
88

99
import numpy as np
10+
import pytest
1011

11-
from pandas import DataFrame, Series
12+
from pandas import DataFrame, Series, _is_numpy_dev
1213
import pandas._testing as tm
1314

1415

@@ -73,6 +74,9 @@ def test_cumprod(self, datetime_frame):
7374
df.cumprod(0)
7475
df.cumprod(1)
7576

77+
@pytest.mark.xfail(
78+
_is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992"
79+
)
7680
def test_cummin(self, datetime_frame):
7781
datetime_frame.loc[5:10, 0] = np.nan
7882
datetime_frame.loc[10:15, 1] = np.nan
@@ -96,6 +100,9 @@ def test_cummin(self, datetime_frame):
96100
cummin_xs = datetime_frame.cummin(axis=1)
97101
assert np.shape(cummin_xs) == np.shape(datetime_frame)
98102

103+
@pytest.mark.xfail(
104+
_is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992"
105+
)
99106
def test_cummax(self, datetime_frame):
100107
datetime_frame.loc[5:10, 0] = np.nan
101108
datetime_frame.loc[10:15, 1] = np.nan

pandas/tests/groupby/test_function.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
NaT,
1818
Series,
1919
Timestamp,
20+
_is_numpy_dev,
2021
date_range,
2122
isna,
2223
)
@@ -685,6 +686,9 @@ def test_numpy_compat(func):
685686
getattr(g, func)(foo=1)
686687

687688

689+
@pytest.mark.xfail(
690+
_is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992"
691+
)
688692
def test_cummin_cummax():
689693
# GH 15048
690694
num_types = [np.int32, np.int64, np.float32, np.float64]

pandas/tests/groupby/test_transform.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
MultiIndex,
1616
Series,
1717
Timestamp,
18+
_is_numpy_dev,
1819
concat,
1920
date_range,
2021
)
@@ -317,6 +318,34 @@ def test_dispatch_transform(tsframe):
317318
tm.assert_frame_equal(filled, expected)
318319

319320

321+
def test_transform_transformation_func(transformation_func):
322+
# GH 30918
323+
df = DataFrame(
324+
{
325+
"A": ["foo", "foo", "foo", "foo", "bar", "bar", "baz"],
326+
"B": [1, 2, np.nan, 3, 3, np.nan, 4],
327+
}
328+
)
329+
330+
if transformation_func in ["pad", "backfill", "tshift", "corrwith", "cumcount"]:
331+
# These transformation functions are not yet covered in this test
332+
pytest.xfail("See GH 31269 and GH 31270")
333+
elif _is_numpy_dev and transformation_func in ["cummin"]:
334+
pytest.xfail("https://github.com/pandas-dev/pandas/issues/31992")
335+
elif transformation_func == "fillna":
336+
test_op = lambda x: x.transform("fillna", value=0)
337+
mock_op = lambda x: x.fillna(value=0)
338+
else:
339+
test_op = lambda x: x.transform(transformation_func)
340+
mock_op = lambda x: getattr(x, transformation_func)()
341+
342+
result = test_op(df.groupby("A"))
343+
groups = [df[["B"]].iloc[:4], df[["B"]].iloc[4:6], df[["B"]].iloc[6:]]
344+
expected = concat([mock_op(g) for g in groups])
345+
346+
tm.assert_frame_equal(result, expected)
347+
348+
320349
def test_transform_select_columns(df):
321350
f = lambda x: x.mean()
322351
result = df.groupby("A")[["C", "D"]].transform(f)

pandas/tests/scalar/timedelta/test_arithmetic.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
import pandas as pd
11-
from pandas import NaT, Timedelta, Timestamp, offsets
11+
from pandas import NaT, Timedelta, Timestamp, _is_numpy_dev, offsets
1212
import pandas._testing as tm
1313
from pandas.core import ops
1414

@@ -377,7 +377,20 @@ def test_td_div_numeric_scalar(self):
377377
assert isinstance(result, Timedelta)
378378
assert result == Timedelta(days=2)
379379

380-
@pytest.mark.parametrize("nan", [np.nan, np.float64("NaN"), float("nan")])
380+
@pytest.mark.parametrize(
381+
"nan",
382+
[
383+
np.nan,
384+
pytest.param(
385+
np.float64("NaN"),
386+
marks=pytest.mark.xfail(
387+
_is_numpy_dev,
388+
reason="https://github.com/pandas-dev/pandas/issues/31992",
389+
),
390+
),
391+
float("nan"),
392+
],
393+
)
381394
def test_td_div_nan(self, nan):
382395
# np.float64('NaN') has a 'dtype' attr, avoid treating as array
383396
td = Timedelta(10, unit="d")

pandas/tests/series/test_cumulative.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
import pandas as pd
14+
from pandas import _is_numpy_dev
1415
import pandas._testing as tm
1516

1617

@@ -37,6 +38,9 @@ def test_cumsum(self, datetime_series):
3738
def test_cumprod(self, datetime_series):
3839
_check_accum_op("cumprod", datetime_series)
3940

41+
@pytest.mark.xfail(
42+
_is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992"
43+
)
4044
def test_cummin(self, datetime_series):
4145
tm.assert_numpy_array_equal(
4246
datetime_series.cummin().values,
@@ -49,6 +53,9 @@ def test_cummin(self, datetime_series):
4953

5054
tm.assert_series_equal(result, expected)
5155

56+
@pytest.mark.xfail(
57+
_is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992"
58+
)
5259
def test_cummax(self, datetime_series):
5360
tm.assert_numpy_array_equal(
5461
datetime_series.cummax().values,

0 commit comments

Comments
 (0)