Skip to content

Commit 39b59c0

Browse files
lithomas1JulianWgs
authored andcommitted
CI: Xfails on Python 3.10 (pandas-dev#41595)
1 parent f54eaa7 commit 39b59c0

File tree

7 files changed

+62
-9
lines changed

7 files changed

+62
-9
lines changed

.github/workflows/python-dev.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ on:
1010
paths-ignore:
1111
- "doc/**"
1212

13+
env:
14+
PYTEST_WORKERS: "auto"
15+
PANDAS_CI: 1
16+
PATTERN: "not slow and not network and not clipboard"
17+
COVERAGE: true
18+
1319
jobs:
1420
build:
1521
runs-on: ubuntu-latest
@@ -36,7 +42,7 @@ jobs:
3642
pip install git+https://github.com/numpy/numpy.git
3743
pip install git+https://github.com/pytest-dev/pytest.git
3844
pip install git+https://github.com/nedbat/coveragepy.git
39-
pip install cython python-dateutil pytz hypothesis pytest-xdist
45+
pip install cython python-dateutil pytz hypothesis pytest-xdist pytest-cov
4046
pip list
4147
4248
- name: Build Pandas
@@ -50,7 +56,8 @@ jobs:
5056
5157
- name: Test with pytest
5258
run: |
53-
coverage run -m pytest -m 'not slow and not network and not clipboard' pandas
59+
ci/run_tests.sh
60+
# GH 41935
5461
continue-on-error: true
5562

5663
- name: Publish test results

pandas/tests/arrays/string_/test_string.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
This module tests the functionality of StringArray and ArrowStringArray.
33
Tests for the str accessors are in pandas/tests/strings/test_string_array.py
44
"""
5-
6-
import re
7-
85
import numpy as np
96
import pytest
107

@@ -314,7 +311,7 @@ def test_astype_int(dtype):
314311
tm.assert_numpy_array_equal(result, expected)
315312

316313
arr = pd.array(["1", pd.NA, "3"], dtype=dtype)
317-
msg = re.escape("int() argument must be a string, a bytes-like object or a number")
314+
msg = r"int\(\) argument must be a string, a bytes-like object or a( real)? number"
318315
with pytest.raises(TypeError, match=msg):
319316
arr.astype("int64")
320317

pandas/tests/extension/test_sparse.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
be added to the array-specific tests in `pandas/tests/arrays/`.
1414
1515
"""
16+
1617
import numpy as np
1718
import pytest
1819

pandas/tests/indexes/test_base.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from pandas.compat import (
1414
IS64,
15+
PY310,
1516
np_datetime64_compat,
1617
)
1718
from pandas.util._test_decorators import async_mark
@@ -992,7 +993,7 @@ def test_isin(self, values, index, expected):
992993
result = index.isin(values)
993994
tm.assert_numpy_array_equal(result, expected)
994995

995-
def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
996+
def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
996997
# Test cartesian product of null fixtures and ensure that we don't
997998
# mangle the various types (save a corner case with PyPy)
998999

@@ -1003,6 +1004,24 @@ def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
10031004
and math.isnan(nulls_fixture)
10041005
and math.isnan(nulls_fixture2)
10051006
):
1007+
if PY310:
1008+
if (
1009+
# Failing cases are
1010+
# np.nan, float('nan')
1011+
# float('nan'), np.nan
1012+
# float('nan'), float('nan')
1013+
# Since only float('nan'), np.nan is float
1014+
# Use not np.nan to identify float('nan')
1015+
nulls_fixture is np.nan
1016+
and nulls_fixture2 is not np.nan
1017+
or nulls_fixture is not np.nan
1018+
):
1019+
request.applymarker(
1020+
# This test is flaky :(
1021+
pytest.mark.xfail(
1022+
reason="Failing on Python 3.10 GH41940", strict=False
1023+
)
1024+
)
10061025
tm.assert_numpy_array_equal(
10071026
Index(["a", nulls_fixture]).isin([nulls_fixture2]),
10081027
np.array([False, True]),

pandas/tests/io/json/test_ujson.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pandas._libs.json as ujson
1717
from pandas.compat import (
1818
IS64,
19+
PY310,
1920
is_platform_windows,
2021
)
2122

@@ -248,7 +249,21 @@ def test_double_precision(self):
248249
assert rounded_input == json.loads(output)
249250
assert rounded_input == ujson.decode(output)
250251

251-
@pytest.mark.parametrize("invalid_val", [20, -1, "9", None])
252+
@pytest.mark.parametrize(
253+
"invalid_val",
254+
[
255+
20,
256+
-1,
257+
pytest.param(
258+
"9",
259+
marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"),
260+
),
261+
pytest.param(
262+
None,
263+
marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"),
264+
),
265+
],
266+
)
252267
def test_invalid_double_precision(self, invalid_val):
253268
double_input = 30.12345678901234567890
254269
expected_exception = ValueError if isinstance(invalid_val, int) else TypeError

pandas/tests/reshape/test_get_dummies.py

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import numpy as np
44
import pytest
55

6+
from pandas.compat import PY310
7+
68
from pandas.core.dtypes.common import is_integer_dtype
79

810
import pandas as pd
@@ -428,6 +430,8 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected):
428430
result = get_dummies(**get_dummies_kwargs)
429431
tm.assert_frame_equal(result, expected)
430432

433+
# This is flaky on Python 3.10
434+
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
431435
def test_get_dummies_basic_drop_first(self, sparse):
432436
# GH12402 Add a new parameter `drop_first` to avoid collinearity
433437
# Basic case
@@ -467,6 +471,7 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse):
467471
result = get_dummies(s_series_index, drop_first=True, sparse=sparse)
468472
tm.assert_frame_equal(result, expected)
469473

474+
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
470475
def test_get_dummies_basic_drop_first_NA(self, sparse):
471476
# Test NA handling together with drop_first
472477
s_NA = ["a", "b", np.nan]

pandas/tests/test_algos.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
algos as libalgos,
1010
hashtable as ht,
1111
)
12-
from pandas.compat import np_array_datetime64_compat
12+
from pandas.compat import (
13+
PY310,
14+
np_array_datetime64_compat,
15+
)
1316
import pandas.util._test_decorators as td
1417

1518
from pandas.core.dtypes.common import (
@@ -783,6 +786,8 @@ def test_different_nans(self):
783786
expected = np.array([np.nan])
784787
tm.assert_numpy_array_equal(result, expected)
785788

789+
# Flaky on Python 3.10 -> Don't make strict
790+
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
786791
def test_first_nan_kept(self):
787792
# GH 22295
788793
# create different nans from bit-patterns:
@@ -988,6 +993,8 @@ def __hash__(self):
988993
# different objects -> False
989994
tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False]))
990995

996+
# Flaky on Python 3.10 -> Don't make strict
997+
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
991998
def test_different_nans(self):
992999
# GH 22160
9931000
# all nans are handled as equivalent
@@ -1030,6 +1037,8 @@ def test_empty(self, empty):
10301037
result = algos.isin(vals, empty)
10311038
tm.assert_numpy_array_equal(expected, result)
10321039

1040+
# Flaky on Python 3.10 -> Don't make strict
1041+
@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False)
10331042
def test_different_nan_objects(self):
10341043
# GH 22119
10351044
comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object)

0 commit comments

Comments
 (0)