Skip to content

Commit ea7d18c

Browse files
Fix ceil, floor and round pytests (#13218)
A fix for pandas-dev/pandas#52761 has been merged by @mroeschke , this PR xfails the pytests conditionally for `2.0.0` and passes for rest of the versions. This PR fixes 27 pytests: ``` = 404 failed, 88221 passed, 2044 skipped, 959 xfailed, 165 xpassed in 442.21s (0:07:22) = ``` On `pandas_2.0_feature_branch`: ``` = 431 failed, 88221 passed, 2044 skipped, 932 xfailed, 165 xpassed in 456.25s (0:07:36) = ```
1 parent e4500a6 commit ea7d18c

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

python/cudf/cudf/core/_compat.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
PANDAS_LT_140 = PANDAS_VERSION < version.parse("1.4.0")
1010
PANDAS_GE_150 = PANDAS_VERSION >= version.parse("1.5.0")
1111
PANDAS_LT_153 = PANDAS_VERSION < version.parse("1.5.3")
12+
PANDAS_EQ_200 = PANDAS_VERSION == version.parse("2.0.0")
1213
PANDAS_GE_200 = PANDAS_VERSION >= version.parse("2.0.0")

python/cudf/cudf/tests/test_datetime.py

+49-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import warnings
1414
import cudf.testing.dataset_generator as dataset_generator
1515
from cudf import DataFrame, Series
16-
from cudf.core._compat import PANDAS_GE_150, PANDAS_LT_140
16+
from cudf.core._compat import PANDAS_GE_150, PANDAS_LT_140, PANDAS_EQ_200
1717
from cudf.core.index import DatetimeIndex
1818
from cudf.testing._utils import (
1919
DATETIME_TYPES,
@@ -1906,8 +1906,22 @@ def test_error_values():
19061906
@pytest.mark.parametrize(
19071907
"resolution", ["D", "H", "T", "min", "S", "L", "ms", "U", "us", "N"]
19081908
)
1909-
def test_ceil(data, time_type, resolution):
1910-
1909+
def test_ceil(request, data, time_type, resolution):
1910+
alias_map = {"L": "ms", "U": "us", "N": "ns"}
1911+
request.applymarker(
1912+
pytest.mark.xfail(
1913+
condition=(
1914+
PANDAS_EQ_200
1915+
and resolution in {"L", "ms", "U", "us", "N"}
1916+
and np.dtype(
1917+
f"datetime64[{alias_map.get(resolution, resolution)}]"
1918+
)
1919+
> np.dtype(time_type)
1920+
),
1921+
reason="https://github.com/pandas-dev/pandas/issues/52761",
1922+
strict=True,
1923+
)
1924+
)
19111925
gs = cudf.Series(data, dtype=time_type)
19121926
ps = gs.to_pandas()
19131927

@@ -1937,7 +1951,22 @@ def test_ceil(data, time_type, resolution):
19371951
@pytest.mark.parametrize(
19381952
"resolution", ["D", "H", "T", "min", "S", "L", "ms", "U", "us", "N"]
19391953
)
1940-
def test_floor(data, time_type, resolution):
1954+
def test_floor(request, data, time_type, resolution):
1955+
alias_map = {"L": "ms", "U": "us", "N": "ns"}
1956+
request.applymarker(
1957+
pytest.mark.xfail(
1958+
condition=(
1959+
PANDAS_EQ_200
1960+
and resolution in {"L", "ms", "U", "us", "N"}
1961+
and np.dtype(
1962+
f"datetime64[{alias_map.get(resolution, resolution)}]"
1963+
)
1964+
> np.dtype(time_type)
1965+
),
1966+
reason="https://github.com/pandas-dev/pandas/issues/52761",
1967+
strict=True,
1968+
)
1969+
)
19411970

19421971
gs = cudf.Series(data, dtype=time_type)
19431972
ps = gs.to_pandas()
@@ -1968,7 +1997,22 @@ def test_floor(data, time_type, resolution):
19681997
@pytest.mark.parametrize(
19691998
"resolution", ["D", "H", "T", "min", "S", "L", "ms", "U", "us", "N"]
19701999
)
1971-
def test_round(data, time_type, resolution):
2000+
def test_round(request, data, time_type, resolution):
2001+
alias_map = {"L": "ms", "U": "us", "N": "ns"}
2002+
request.applymarker(
2003+
pytest.mark.xfail(
2004+
condition=(
2005+
PANDAS_EQ_200
2006+
and resolution in {"L", "ms", "U", "us", "N"}
2007+
and np.dtype(
2008+
f"datetime64[{alias_map.get(resolution, resolution)}]"
2009+
)
2010+
> np.dtype(time_type)
2011+
),
2012+
reason="https://github.com/pandas-dev/pandas/issues/52761",
2013+
strict=True,
2014+
)
2015+
)
19722016

19732017
gs = cudf.Series(data, dtype=time_type)
19742018
ps = gs.to_pandas()

0 commit comments

Comments
 (0)