From 94bf7f946d0032807949ffa0d50405b52c729e34 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 20 May 2021 15:33:34 -0700 Subject: [PATCH 01/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 2643dc5ec656e..4d51651ee1a31 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -45,7 +45,6 @@ jobs: - name: Test with pytest run: | coverage run -m pytest -m 'not slow and not network and not clipboard' pandas - continue-on-error: true - name: Publish test results uses: actions/upload-artifact@master From b7966cb1db2ed20f80fb8470521487fcf3bf8865 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 20 May 2021 19:54:17 -0700 Subject: [PATCH 02/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 4d51651ee1a31..2f7887720bcb8 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -30,6 +30,7 @@ jobs: pip install git+https://github.com/numpy/numpy.git pip install git+https://github.com/pytest-dev/pytest.git pip install git+https://github.com/nedbat/coveragepy.git + pip install git+https://github.com/cython/cython.git pip install cython python-dateutil pytz hypothesis pytest-xdist pip list From c1500c9e290bf9787e3fa644b141de01269d33d4 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 20 May 2021 20:14:58 -0700 Subject: [PATCH 03/43] Revert changes --- .github/workflows/python-dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 2f7887720bcb8..4d51651ee1a31 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -30,7 +30,6 @@ jobs: pip install git+https://github.com/numpy/numpy.git pip install git+https://github.com/pytest-dev/pytest.git pip install git+https://github.com/nedbat/coveragepy.git - pip install git+https://github.com/cython/cython.git pip install cython python-dateutil pytz hypothesis pytest-xdist pip list From 9bbebf794bb8bc3bdfbad1004a00fdd9b1c68c7a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 21 May 2021 19:56:58 -0700 Subject: [PATCH 04/43] Update test_algos.py --- pandas/tests/test_algos.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 4df95d895e475..83840068c7f85 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -9,7 +9,10 @@ algos as libalgos, hashtable as ht, ) -from pandas.compat import np_array_datetime64_compat +from pandas.compat import ( + np_array_datetime64_compat, + PY310, +) import pandas.util._test_decorators as td from pandas.core.dtypes.common import ( @@ -783,6 +786,7 @@ def test_different_nans(self): expected = np.array([np.nan]) tm.assert_numpy_array_equal(result, expected) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_first_nan_kept(self): # GH 22295 # create different nans from bit-patterns: @@ -988,6 +992,7 @@ def __hash__(self): # different objects -> False tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10) def test_different_nans(self): # GH 22160 # all nans are handled as equivalent @@ -1030,6 +1035,7 @@ def test_empty(self, empty): result = algos.isin(vals, empty) tm.assert_numpy_array_equal(expected, result) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10) def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From e09628caf42fc639e526dae60c0dbe5d8836542a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 21 May 2021 20:01:20 -0700 Subject: [PATCH 05/43] Update test_dtype.py --- pandas/tests/arrays/sparse/test_dtype.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/arrays/sparse/test_dtype.py b/pandas/tests/arrays/sparse/test_dtype.py index 58fedbd3e4231..7b9e5957a2320 100644 --- a/pandas/tests/arrays/sparse/test_dtype.py +++ b/pandas/tests/arrays/sparse/test_dtype.py @@ -128,7 +128,10 @@ def test_construct_from_string(string, expected): [ (SparseDtype(float, 0.0), SparseDtype(np.dtype("float"), 0.0), True), (SparseDtype(int, 0), SparseDtype(int, 0), True), - (SparseDtype(float, float("nan")), SparseDtype(float, np.nan), True), + pytest.param(SparseDtype(float, float("nan")), + SparseDtype(float, np.nan), + True, + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10")) (SparseDtype(float, 0), SparseDtype(float, np.nan), False), (SparseDtype(int, 0.0), SparseDtype(float, 0.0), False), ], From 321a5d0452dc632b0418b79740ac0d837e8d4a43 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 21 May 2021 20:04:01 -0700 Subject: [PATCH 06/43] Typo --- pandas/tests/arrays/sparse/test_dtype.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/arrays/sparse/test_dtype.py b/pandas/tests/arrays/sparse/test_dtype.py index 7b9e5957a2320..9f9744c8db5b9 100644 --- a/pandas/tests/arrays/sparse/test_dtype.py +++ b/pandas/tests/arrays/sparse/test_dtype.py @@ -4,6 +4,7 @@ import pytest import pandas as pd +from pandas.compat import PY310 from pandas.core.arrays.sparse import SparseDtype From c599e0c5aa25ea3a172bfd27021e2fb8a5557ea1 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 22 May 2021 22:05:47 +0000 Subject: [PATCH 07/43] update tests --- pandas/tests/arrays/sparse/test_dtype.py | 13 +++++---- pandas/tests/frame/methods/test_to_records.py | 28 ++++++++++++------- pandas/tests/test_algos.py | 6 ++-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/pandas/tests/arrays/sparse/test_dtype.py b/pandas/tests/arrays/sparse/test_dtype.py index 9f9744c8db5b9..f9b7251e8a693 100644 --- a/pandas/tests/arrays/sparse/test_dtype.py +++ b/pandas/tests/arrays/sparse/test_dtype.py @@ -3,8 +3,9 @@ import numpy as np import pytest -import pandas as pd from pandas.compat import PY310 + +import pandas as pd from pandas.core.arrays.sparse import SparseDtype @@ -129,10 +130,12 @@ def test_construct_from_string(string, expected): [ (SparseDtype(float, 0.0), SparseDtype(np.dtype("float"), 0.0), True), (SparseDtype(int, 0), SparseDtype(int, 0), True), - pytest.param(SparseDtype(float, float("nan")), - SparseDtype(float, np.nan), - True, - marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10")) + pytest.param( + SparseDtype(float, float("nan")), + SparseDtype(float, np.nan), + True, + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10"), + ), (SparseDtype(float, 0), SparseDtype(float, np.nan), False), (SparseDtype(int, 0.0), SparseDtype(float, 0.0), False), ], diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index 2c96cf291c154..c3897eddb4e51 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -3,6 +3,8 @@ import numpy as np import pytest +from pandas.compat import PY310 + from pandas import ( CategoricalDtype, DataFrame, @@ -172,19 +174,25 @@ def test_to_records_with_categorical(self): ), # Pass in a type instance. ( - {"column_dtypes": str}, - np.rec.array( - [("0", "1", "0.2", "a"), ("1", "2", "1.5", "bc")], - dtype=[("index", " False tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_different_nans(self): # GH 22160 # all nans are handled as equivalent @@ -1035,7 +1035,7 @@ def test_empty(self, empty): result = algos.isin(vals, empty) tm.assert_numpy_array_equal(expected, result) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From 0faac5676d454c68b0fe04f333eb3ce2ac6d462b Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 22 May 2021 22:20:44 +0000 Subject: [PATCH 08/43] Xfail more --- pandas/tests/frame/methods/test_reindex.py | 3 +++ pandas/tests/indexes/test_base.py | 2 ++ pandas/tests/io/json/test_ujson.py | 15 ++++++++++++++- pandas/tests/reshape/test_get_dummies.py | 3 +++ pandas/tests/series/methods/test_reindex.py | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pandas/tests/frame/methods/test_reindex.py b/pandas/tests/frame/methods/test_reindex.py index 8a3ac265db154..8f3f8cc7f6028 100644 --- a/pandas/tests/frame/methods/test_reindex.py +++ b/pandas/tests/frame/methods/test_reindex.py @@ -8,6 +8,8 @@ import numpy as np import pytest +from pandas.compat import PY310 + import pandas as pd from pandas import ( Categorical, @@ -458,6 +460,7 @@ def test_reindex(self, float_frame): tm.assert_frame_equal(result, float_frame) assert result is not float_frame + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_reindex_nan(self): df = DataFrame( [[1, 2], [3, 5], [7, 11], [9, 23]], diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 47657fff56ceb..beed97e75471a 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -12,6 +12,7 @@ from pandas.compat import ( IS64, + PY310, np_datetime64_compat, ) from pandas.util._test_decorators import async_mark @@ -992,6 +993,7 @@ def test_isin(self, values, index, expected): result = index.isin(values) tm.assert_numpy_array_equal(result, expected) + @pytest.mark.xfail(PY310, "Failing on Python 3.10") def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2): # Test cartesian product of null fixtures and ensure that we don't # mangle the various types (save a corner case with PyPy) diff --git a/pandas/tests/io/json/test_ujson.py b/pandas/tests/io/json/test_ujson.py index 805f6b8dbe461..d7559f5775964 100644 --- a/pandas/tests/io/json/test_ujson.py +++ b/pandas/tests/io/json/test_ujson.py @@ -16,6 +16,7 @@ import pandas._libs.json as ujson from pandas.compat import ( IS64, + PY310, is_platform_windows, ) @@ -248,7 +249,19 @@ def test_double_precision(self): assert rounded_input == json.loads(output) assert rounded_input == ujson.decode(output) - @pytest.mark.parametrize("invalid_val", [20, -1, "9", None]) + @pytest.mark.parametrize( + "invalid_val", + [ + 20, + -1, + pytest.param( + "9", marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + ), + pytest.param( + None, marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + ), + ], + ) def test_invalid_double_precision(self, invalid_val): double_input = 30.12345678901234567890 expected_exception = ValueError if isinstance(invalid_val, int) else TypeError diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index 8af49ac20987a..393c55eb0ef09 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -3,6 +3,8 @@ import numpy as np import pytest +from pandas.compat import PY310 + from pandas.core.dtypes.common import is_integer_dtype import pandas as pd @@ -427,6 +429,7 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected): result = get_dummies(**get_dummies_kwargs) tm.assert_frame_equal(result, expected) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_get_dummies_basic_drop_first(self, sparse): # GH12402 Add a new parameter `drop_first` to avoid collinearity # Basic case diff --git a/pandas/tests/series/methods/test_reindex.py b/pandas/tests/series/methods/test_reindex.py index 36d3971d10a3d..b7e9f8880b6d8 100644 --- a/pandas/tests/series/methods/test_reindex.py +++ b/pandas/tests/series/methods/test_reindex.py @@ -1,6 +1,8 @@ import numpy as np import pytest +from pandas.compat import PY310 + from pandas import ( Categorical, Index, @@ -54,6 +56,7 @@ def test_reindex(datetime_series, string_series): assert not (result is datetime_series) +@pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_reindex_nan(): ts = Series([2, 3, 5, 7], index=[1, 4, np.nan, 8]) From 07517c5857d8a769f120de6faff62fdbc1166e51 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 22 May 2021 15:21:57 -0700 Subject: [PATCH 09/43] Update test_to_records.py --- pandas/tests/frame/methods/test_to_records.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index c3897eddb4e51..b5aa69e0b92ec 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -191,7 +191,7 @@ def test_to_records_with_categorical(self): [("0", "1", "0.2", "a"), ("1", "2", "1.5", "bc")], dtype=[("index", " Date: Sun, 23 May 2021 10:42:25 -0700 Subject: [PATCH 10/43] Typo --- pandas/tests/indexes/test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index beed97e75471a..ab1a7b4288158 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -993,7 +993,7 @@ def test_isin(self, values, index, expected): result = index.isin(values) tm.assert_numpy_array_equal(result, expected) - @pytest.mark.xfail(PY310, "Failing on Python 3.10") + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2): # Test cartesian product of null fixtures and ensure that we don't # mangle the various types (save a corner case with PyPy) From 7d6dd36e9597217a53c4d061e5bb2dc15599593c Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Tue, 25 May 2021 15:09:10 -0700 Subject: [PATCH 11/43] Update test_sparse.py --- pandas/tests/extension/test_sparse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index f0d3fb7ff9e1b..64275bd80c70b 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -173,6 +173,9 @@ def test_merge(self, data, na_value): @pytest.mark.xfail(reason="SparseArray does not support setitem") def test_transpose(self, data): super().test_transpose(data) + + # Inherited tests that fail on Python 3.10 + test_stack = pytest.mark.xfail(test_stack) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): From 55844b0650d1fe83901bf72155d1098826ce930b Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Tue, 25 May 2021 15:10:06 -0700 Subject: [PATCH 12/43] Formatting --- pandas/tests/extension/test_sparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 64275bd80c70b..138a6e0203c71 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -173,7 +173,7 @@ def test_merge(self, data, na_value): @pytest.mark.xfail(reason="SparseArray does not support setitem") def test_transpose(self, data): super().test_transpose(data) - + # Inherited tests that fail on Python 3.10 test_stack = pytest.mark.xfail(test_stack) From cc2eaf826b0c2413ad97bcd5712995d2d4d1a579 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Tue, 25 May 2021 15:20:09 -0700 Subject: [PATCH 13/43] Properly xfail sparse tests --- pandas/tests/extension/test_sparse.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 138a6e0203c71..46fd468419129 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -16,6 +16,7 @@ import numpy as np import pytest +from pandas.compat import PY310 from pandas.errors import PerformanceWarning from pandas.core.dtypes.common import is_object_dtype @@ -174,8 +175,19 @@ def test_merge(self, data, na_value): def test_transpose(self, data): super().test_transpose(data) - # Inherited tests that fail on Python 3.10 - test_stack = pytest.mark.xfail(test_stack) + # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + @pytest.mark.parametrize( + "columns", + [ + ["A", "B"], + pd.MultiIndex.from_tuples( + [("A", "a"), ("A", "b")], names=["outer", "inner"] + ), + ], + ) + def test_stack(self, data, columns): + super().test_stack(data, columns) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): From 915862ad81813720551a7496282fb7ba0e7aaf78 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Wed, 26 May 2021 15:44:02 -0700 Subject: [PATCH 14/43] Xfail less --- .github/workflows/python-dev.yml | 2 +- pandas/tests/indexes/test_base.py | 5 +++-- pandas/tests/reshape/test_get_dummies.py | 5 +++-- pandas/tests/test_algos.py | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 4d51651ee1a31..67de721217c13 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -44,7 +44,7 @@ jobs: - name: Test with pytest run: | - coverage run -m pytest -m 'not slow and not network and not clipboard' pandas + coverage run -m pytest -m 'not slow and not network and not clipboard' -n auto pandas - name: Publish test results uses: actions/upload-artifact@master diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index ab1a7b4288158..758539f30e10c 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -993,8 +993,7 @@ def test_isin(self, values, index, expected): result = index.isin(values) tm.assert_numpy_array_equal(result, expected) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2): + def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): # Test cartesian product of null fixtures and ensure that we don't # mangle the various types (save a corner case with PyPy) @@ -1005,6 +1004,8 @@ def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2): and math.isnan(nulls_fixture) and math.isnan(nulls_fixture2) ): + if PY310: + request.applymarker(pytest.mark.xfail(reason="Failing on Python 3.10")) tm.assert_numpy_array_equal( Index(["a", nulls_fixture]).isin([nulls_fixture2]), np.array([False, True]), diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index 393c55eb0ef09..6f65fd08c25ce 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -429,8 +429,7 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected): result = get_dummies(**get_dummies_kwargs) tm.assert_frame_equal(result, expected) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - def test_get_dummies_basic_drop_first(self, sparse): + def test_get_dummies_basic_drop_first(self, request, sparse): # GH12402 Add a new parameter `drop_first` to avoid collinearity # Basic case s_list = list("abc") @@ -441,6 +440,8 @@ def test_get_dummies_basic_drop_first(self, sparse): result = get_dummies(s_list, drop_first=True, sparse=sparse) if sparse: + if PY310: + request.applymarker(pytest.mark.xfail(reason="Failing on Python 3.10")) expected = expected.apply(SparseArray, fill_value=0) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index a2719fa8b349a..cf17065c03441 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -992,7 +992,7 @@ def __hash__(self): # different objects -> False tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_different_nans(self): # GH 22160 # all nans are handled as equivalent @@ -1035,7 +1035,7 @@ def test_empty(self, empty): result = algos.isin(vals, empty) tm.assert_numpy_array_equal(expected, result) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From 773fa84c293b7ded9b40bf75399ceaf98a8eec9e Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Wed, 26 May 2021 16:49:01 -0700 Subject: [PATCH 15/43] Maybe fix? --- pandas/tests/extension/test_sparse.py | 25 ++++++++++++------------ pandas/tests/indexes/test_base.py | 8 +++++++- pandas/tests/reshape/test_get_dummies.py | 3 ++- pandas/tests/test_algos.py | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 46fd468419129..4bf9dedcc67df 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -16,7 +16,6 @@ import numpy as np import pytest -from pandas.compat import PY310 from pandas.errors import PerformanceWarning from pandas.core.dtypes.common import is_object_dtype @@ -176,18 +175,18 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - @pytest.mark.parametrize( - "columns", - [ - ["A", "B"], - pd.MultiIndex.from_tuples( - [("A", "a"), ("A", "b")], names=["outer", "inner"] - ), - ], - ) - def test_stack(self, data, columns): - super().test_stack(data, columns) + # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + # @pytest.mark.parametrize( + # "columns", + # [ + # ["A", "B"], + # pd.MultiIndex.from_tuples( + # [("A", "a"), ("A", "b")], names=["outer", "inner"] + # ), + # ], + # ) + # def test_stack(self, data, columns): + # super().test_stack(data, columns) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 758539f30e10c..b16b07624a86a 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1005,7 +1005,13 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): and math.isnan(nulls_fixture2) ): if PY310: - request.applymarker(pytest.mark.xfail(reason="Failing on Python 3.10")) + if nulls_fixture == float("nan") and nulls_fixture2 in [ + np.nan, + float("nan"), + ]: + request.applymarker( + pytest.mark.xfail(reason="Failing on Python 3.10") + ) tm.assert_numpy_array_equal( Index(["a", nulls_fixture]).isin([nulls_fixture2]), np.array([False, True]), diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index 6f65fd08c25ce..fb547d91a6b0a 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -440,9 +440,10 @@ def test_get_dummies_basic_drop_first(self, request, sparse): result = get_dummies(s_list, drop_first=True, sparse=sparse) if sparse: + expected = expected.apply(SparseArray, fill_value=0) + else: if PY310: request.applymarker(pytest.mark.xfail(reason="Failing on Python 3.10")) - expected = expected.apply(SparseArray, fill_value=0) tm.assert_frame_equal(result, expected) result = get_dummies(s_series, drop_first=True, sparse=sparse) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index cf17065c03441..cd11be2e5066d 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -1035,7 +1035,7 @@ def test_empty(self, empty): result = algos.isin(vals, empty) tm.assert_numpy_array_equal(expected, result) - # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From 39d39497e2c701e5b62fc344abc8ed1f225f8d1c Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 27 May 2021 10:20:28 -0700 Subject: [PATCH 16/43] Handle Flaky Tests --- pandas/tests/test_algos.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index cd11be2e5066d..4dcfd83843bf9 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -785,8 +785,9 @@ def test_different_nans(self): result = pd.unique(a) expected = np.array([np.nan]) tm.assert_numpy_array_equal(result, expected) - - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + + # Flaky on Python 3.10 -> Don't make strict + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_first_nan_kept(self): # GH 22295 # create different nans from bit-patterns: @@ -991,8 +992,9 @@ def __hash__(self): tm.assert_numpy_array_equal(algos.isin([a], [a]), np.array([True])) # different objects -> False tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) - - # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + + # Flaky on Python 3.10 -> Don't make strict + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_different_nans(self): # GH 22160 # all nans are handled as equivalent @@ -1035,7 +1037,8 @@ def test_empty(self, empty): result = algos.isin(vals, empty) tm.assert_numpy_array_equal(expected, result) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + # Flaky on Python 3.10 -> Don't make strict + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From 795320b112806feef6a4a1826fe4b13e264ea16c Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Mon, 31 May 2021 21:03:57 -0700 Subject: [PATCH 17/43] fix a little more --- pandas/tests/extension/test_sparse.py | 4 ++++ pandas/tests/frame/methods/test_to_records.py | 6 +----- pandas/tests/indexes/test_base.py | 14 ++++++++++---- pandas/tests/reshape/test_get_dummies.py | 5 ++++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 4bf9dedcc67df..8b0b2bee0582b 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -16,6 +16,7 @@ import numpy as np import pytest +from pandas.compat import PY310 from pandas.errors import PerformanceWarning from pandas.core.dtypes.common import is_object_dtype @@ -187,6 +188,9 @@ def test_transpose(self, data): # ) # def test_stack(self, data, columns): # super().test_stack(data, columns) + test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( + base.BaseReshapingTests.test_stack + ) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index 3f9b0e94f54ad..ba8fe25401e8c 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -3,11 +3,7 @@ import numpy as np import pytest - -from pandas.compat import ( - is_numpy_dev, - PY310, -) +from pandas.compat import is_numpy_dev from pandas import ( CategoricalDtype, diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 0a8f06c512421..85ebec878ac9b 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1005,10 +1005,16 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): and math.isnan(nulls_fixture2) ): if PY310: - if nulls_fixture == float("nan") and nulls_fixture2 in [ - np.nan, - float("nan"), - ]: + if ( + nulls_fixture == float("nan") + and nulls_fixture2 + in [ + np.nan, + float("nan"), + ] + or nulls_fixture is np.nan + and nulls_fixture2 is np.nan + ): request.applymarker( pytest.mark.xfail(reason="Failing on Python 3.10") ) diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index fb547d91a6b0a..0259d479eaf49 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -429,6 +429,8 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected): result = get_dummies(**get_dummies_kwargs) tm.assert_frame_equal(result, expected) + # This is flaky on Python 3.10 + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_get_dummies_basic_drop_first(self, request, sparse): # GH12402 Add a new parameter `drop_first` to avoid collinearity # Basic case @@ -443,7 +445,7 @@ def test_get_dummies_basic_drop_first(self, request, sparse): expected = expected.apply(SparseArray, fill_value=0) else: if PY310: - request.applymarker(pytest.mark.xfail(reason="Failing on Python 3.10")) + request.applymarker() tm.assert_frame_equal(result, expected) result = get_dummies(s_series, drop_first=True, sparse=sparse) @@ -471,6 +473,7 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse): result = get_dummies(s_series_index, drop_first=True, sparse=sparse) tm.assert_frame_equal(result, expected) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") def test_get_dummies_basic_drop_first_NA(self, sparse): # Test NA handling together with drop_first s_NA = ["a", "b", np.nan] From e4583556dd435e3266901e5cfb7b123a70e8dc56 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Wed, 2 Jun 2021 07:46:24 -0700 Subject: [PATCH 18/43] fix more --- pandas/tests/arrays/string_/test_string.py | 5 +---- pandas/tests/extension/test_sparse.py | 4 +++- pandas/tests/reshape/test_get_dummies.py | 9 +++++---- pandas/tests/test_algos.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pandas/tests/arrays/string_/test_string.py b/pandas/tests/arrays/string_/test_string.py index c9533e239abe0..f4d41d8c9ae59 100644 --- a/pandas/tests/arrays/string_/test_string.py +++ b/pandas/tests/arrays/string_/test_string.py @@ -2,9 +2,6 @@ This module tests the functionality of StringArray and ArrowStringArray. Tests for the str accessors are in pandas/tests/strings/test_string_array.py """ - -import re - import numpy as np import pytest @@ -334,7 +331,7 @@ def test_astype_int(dtype): tm.assert_numpy_array_equal(result, expected) arr = pd.array(["1", pd.NA, "3"], dtype=dtype) - msg = re.escape("int() argument must be a string, a bytes-like object or a number") + msg = r"int\(\) argument must be a string, a bytes-like object or a( real)? number" with pytest.raises(TypeError, match=msg): arr.astype("int64") diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 8b0b2bee0582b..f4e7000b3d4d2 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -13,6 +13,8 @@ be added to the array-specific tests in `pandas/tests/arrays/`. """ +from copy import deepcopy + import numpy as np import pytest @@ -189,7 +191,7 @@ def test_transpose(self, data): # def test_stack(self, data, columns): # super().test_stack(data, columns) test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( - base.BaseReshapingTests.test_stack + deepcopy(base.BaseReshapingTests.test_stack) ) diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index 0259d479eaf49..0994de3107171 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -443,9 +443,6 @@ def test_get_dummies_basic_drop_first(self, request, sparse): result = get_dummies(s_list, drop_first=True, sparse=sparse) if sparse: expected = expected.apply(SparseArray, fill_value=0) - else: - if PY310: - request.applymarker() tm.assert_frame_equal(result, expected) result = get_dummies(s_series, drop_first=True, sparse=sparse) @@ -474,13 +471,17 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse): tm.assert_frame_equal(result, expected) @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - def test_get_dummies_basic_drop_first_NA(self, sparse): + def test_get_dummies_basic_drop_first_NA(self, request, sparse): # Test NA handling together with drop_first s_NA = ["a", "b", np.nan] res = get_dummies(s_NA, drop_first=True, sparse=sparse) exp = DataFrame({"b": [0, 1, 0]}, dtype=np.uint8) if sparse: exp = exp.apply(SparseArray, fill_value=0) + else: + request.applymarker( + pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + ) tm.assert_frame_equal(res, exp) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 4dcfd83843bf9..63e2c857851ec 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -785,7 +785,7 @@ def test_different_nans(self): result = pd.unique(a) expected = np.array([np.nan]) tm.assert_numpy_array_equal(result, expected) - + # Flaky on Python 3.10 -> Don't make strict @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_first_nan_kept(self): @@ -992,7 +992,7 @@ def __hash__(self): tm.assert_numpy_array_equal(algos.isin([a], [a]), np.array([True])) # different objects -> False tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) - + # Flaky on Python 3.10 -> Don't make strict @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) def test_different_nans(self): From 65058989fdd8e41522713e3377e81c90725aa8c1 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 3 Jun 2021 15:26:14 -0700 Subject: [PATCH 19/43] maybe fix? --- pandas/tests/extension/test_sparse.py | 31 ++++++++++++++------------- pandas/tests/indexes/test_base.py | 17 ++++++++------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index f4e7000b3d4d2..a5a026053af38 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -13,7 +13,7 @@ be added to the array-specific tests in `pandas/tests/arrays/`. """ -from copy import deepcopy +# from copy import deepcopy import numpy as np import pytest @@ -178,21 +178,22 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - # @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - # @pytest.mark.parametrize( - # "columns", - # [ - # ["A", "B"], - # pd.MultiIndex.from_tuples( - # [("A", "a"), ("A", "b")], names=["outer", "inner"] - # ), - # ], - # ) - # def test_stack(self, data, columns): - # super().test_stack(data, columns) - test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( - deepcopy(base.BaseReshapingTests.test_stack) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + @pytest.mark.parametrize( + "columns", + [ + ["A", "B"], + pd.MultiIndex.from_tuples( + [("A", "a"), ("A", "b")], names=["outer", "inner"] + ), + ], ) + def test_stack(self, data, columns): + super().test_stack(data, columns) + + # test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( + # deepcopy(base.BaseReshapingTests.test_stack) + # ) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 85ebec878ac9b..0714e5f772ac5 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1006,14 +1006,15 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): ): if PY310: if ( - nulls_fixture == float("nan") - and nulls_fixture2 - in [ - np.nan, - float("nan"), - ] - or nulls_fixture is np.nan - and nulls_fixture2 is np.nan + # Failing cases are + # np.nan, float('nan') + # float('nan'), np.nan + # float('nan'), float('nan') + # Since only float('nan'), np.nan is float + # Use not np.nan to identify float('nan') + nulls_fixture is np.nan + and nulls_fixture2 is not np.nan + or nulls_fixture is not np.nan ): request.applymarker( pytest.mark.xfail(reason="Failing on Python 3.10") From b365d76253515cf066b6b184e3883e2f9f609ce5 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 3 Jun 2021 19:57:06 -0700 Subject: [PATCH 20/43] Maybe fix? --- pandas/tests/extension/test_sparse.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index a5a026053af38..3b32be8a8b7c8 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -178,7 +178,6 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") @pytest.mark.parametrize( "columns", [ @@ -189,7 +188,21 @@ def test_transpose(self, data): ], ) def test_stack(self, data, columns): - super().test_stack(data, columns) + df = pd.DataFrame({"A": data[:5], "B": data[:5]}) + df.columns = columns + result = df.stack() + expected = df.astype(object).stack() + # we need a second astype(object), in case the constructor inferred + # object -> specialized, as is done for period. + expected = expected.astype(object) + + if isinstance(expected, pd.Series): + assert result.dtype == df.iloc[:, 0].dtype + else: + assert all(result.dtypes == df.iloc[:, 0].dtype) + + result = result.astype(object) + self.assert_equal(result, expected) # test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( # deepcopy(base.BaseReshapingTests.test_stack) From 6fc1de26792209b8a13cdcef2180307b6bdbf0f1 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 4 Jun 2021 08:32:16 -0700 Subject: [PATCH 21/43] Update test_sparse.py --- pandas/tests/extension/test_sparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 3b32be8a8b7c8..80c0913f4d20d 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -13,7 +13,6 @@ be added to the array-specific tests in `pandas/tests/arrays/`. """ -# from copy import deepcopy import numpy as np import pytest @@ -178,6 +177,7 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") @pytest.mark.parametrize( "columns", [ From dc5c1e07392e973bf8b79d76d01131529c9d0084 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:01:00 -0700 Subject: [PATCH 22/43] Update test_base.py --- pandas/tests/indexes/test_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 0714e5f772ac5..9492f105b5bed 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1017,7 +1017,8 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): or nulls_fixture is not np.nan ): request.applymarker( - pytest.mark.xfail(reason="Failing on Python 3.10") + # This test is flaky :( + pytest.mark.xfail(reason="Failing on Python 3.10", strict=False) ) tm.assert_numpy_array_equal( Index(["a", nulls_fixture]).isin([nulls_fixture2]), From b640084417754e16510f8c963b672ed4fde4c788 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Sun, 6 Jun 2021 10:51:01 -0700 Subject: [PATCH 23/43] Xfail all --- pandas/tests/apply/test_series_apply.py | 7 ++++++- pandas/tests/extension/test_sparse.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 34d00e653b52d..9d4fa6b835736 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -7,6 +7,8 @@ import numpy as np import pytest +from pandas.compat import PY310 + from pandas.core.dtypes.common import is_number import pandas as pd @@ -808,7 +810,10 @@ def f(x): @pytest.mark.parametrize( "vals,mapping,exp", [ - (list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"]), + pytest.param( + (list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"]), + marks=pytest.marks.xfail(PY310, reason="Failing on Python 3.10"), + ), (list("abc"), {"a": "a letter"}, ["a letter"] + [np.nan] * 3), (list(range(3)), {0: 42}, [42] + [np.nan] * 3), ], diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 80c0913f4d20d..b0968c03847d9 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -177,7 +177,7 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) @pytest.mark.parametrize( "columns", [ From c9267a5eb3839512d9f60feda373935104a1336f Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 6 Jun 2021 13:17:10 -0700 Subject: [PATCH 24/43] Fix typo --- pandas/tests/apply/test_series_apply.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 9d4fa6b835736..f93c6dd7038a8 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -812,7 +812,7 @@ def f(x): [ pytest.param( (list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"]), - marks=pytest.marks.xfail(PY310, reason="Failing on Python 3.10"), + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10"), ), (list("abc"), {"a": "a letter"}, ["a letter"] + [np.nan] * 3), (list(range(3)), {0: 42}, [42] + [np.nan] * 3), From 81f78525e04829c3c955bf1fc7d46fbb297b6328 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 6 Jun 2021 14:29:54 -0700 Subject: [PATCH 25/43] Typo --- pandas/tests/apply/test_series_apply.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index f93c6dd7038a8..297b7d1ad4796 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -811,7 +811,9 @@ def f(x): "vals,mapping,exp", [ pytest.param( - (list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"]), + list("abc"), + {np.nan: "not NaN"}, + [np.nan] * 3 + ["not NaN"], marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10"), ), (list("abc"), {"a": "a letter"}, ["a letter"] + [np.nan] * 3), From 628fdd95c3fa74b9175a3dc58c762b862c7dd481 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 10 Jun 2021 20:01:56 -0700 Subject: [PATCH 26/43] Add issue reference --- pandas/tests/apply/test_series_apply.py | 2 +- pandas/tests/arrays/sparse/test_dtype.py | 2 +- pandas/tests/extension/test_sparse.py | 29 ++++++--------------- pandas/tests/frame/methods/test_reindex.py | 2 +- pandas/tests/indexes/test_base.py | 4 ++- pandas/tests/io/json/test_ujson.py | 6 +++-- pandas/tests/reshape/test_get_dummies.py | 12 +++------ pandas/tests/series/methods/test_reindex.py | 2 +- pandas/tests/test_algos.py | 6 ++--- 9 files changed, 26 insertions(+), 39 deletions(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 297b7d1ad4796..cef7570da16c5 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -814,7 +814,7 @@ def f(x): list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"], - marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10"), + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), ), (list("abc"), {"a": "a letter"}, ["a letter"] + [np.nan] * 3), (list(range(3)), {0: 42}, [42] + [np.nan] * 3), diff --git a/pandas/tests/arrays/sparse/test_dtype.py b/pandas/tests/arrays/sparse/test_dtype.py index f9b7251e8a693..ef73f179f4101 100644 --- a/pandas/tests/arrays/sparse/test_dtype.py +++ b/pandas/tests/arrays/sparse/test_dtype.py @@ -134,7 +134,7 @@ def test_construct_from_string(string, expected): SparseDtype(float, float("nan")), SparseDtype(float, np.nan), True, - marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10"), + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), ), (SparseDtype(float, 0), SparseDtype(float, np.nan), False), (SparseDtype(int, 0.0), SparseDtype(float, 0.0), False), diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index b0968c03847d9..1f3f97bb78872 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -177,7 +177,6 @@ def test_transpose(self, data): super().test_transpose(data) # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) @pytest.mark.parametrize( "columns", [ @@ -187,26 +186,14 @@ def test_transpose(self, data): ), ], ) - def test_stack(self, data, columns): - df = pd.DataFrame({"A": data[:5], "B": data[:5]}) - df.columns = columns - result = df.stack() - expected = df.astype(object).stack() - # we need a second astype(object), in case the constructor inferred - # object -> specialized, as is done for period. - expected = expected.astype(object) - - if isinstance(expected, pd.Series): - assert result.dtype == df.iloc[:, 0].dtype - else: - assert all(result.dtypes == df.iloc[:, 0].dtype) - - result = result.astype(object) - self.assert_equal(result, expected) - - # test_stack = pytest.mark.xfail(PY310, reason="Failing on Python 3.10")( - # deepcopy(base.BaseReshapingTests.test_stack) - # ) + def test_stack(self, request, data, columns): + if data.fill_value is np.nan: + request.applymarker( + pytest.mark.xfail( + PY310, reason="Failing on Python 3.10 GH41940", strict=False + ) + ) + super().test_stack(data, columns) class TestGetitem(BaseSparseTests, base.BaseGetitemTests): diff --git a/pandas/tests/frame/methods/test_reindex.py b/pandas/tests/frame/methods/test_reindex.py index a92b4b2e8729a..069f61b25971b 100644 --- a/pandas/tests/frame/methods/test_reindex.py +++ b/pandas/tests/frame/methods/test_reindex.py @@ -478,7 +478,7 @@ def test_reindex(self, float_frame): tm.assert_frame_equal(result, float_frame) assert result is not float_frame - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940") def test_reindex_nan(self): df = DataFrame( [[1, 2], [3, 5], [7, 11], [9, 23]], diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 95910938a1705..af781f0b58f85 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -1018,7 +1018,9 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2): ): request.applymarker( # This test is flaky :( - pytest.mark.xfail(reason="Failing on Python 3.10", strict=False) + pytest.mark.xfail( + reason="Failing on Python 3.10 GH41940", strict=False + ) ) tm.assert_numpy_array_equal( Index(["a", nulls_fixture]).isin([nulls_fixture2]), diff --git a/pandas/tests/io/json/test_ujson.py b/pandas/tests/io/json/test_ujson.py index d7559f5775964..57a6b214cec84 100644 --- a/pandas/tests/io/json/test_ujson.py +++ b/pandas/tests/io/json/test_ujson.py @@ -255,10 +255,12 @@ def test_double_precision(self): 20, -1, pytest.param( - "9", marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + "9", + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), ), pytest.param( - None, marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10") + None, + marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), ), ], ) diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index af926cdc73441..b8100d220dca2 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -431,8 +431,8 @@ def test_dataframe_dummies_unicode(self, get_dummies_kwargs, expected): tm.assert_frame_equal(result, expected) # This is flaky on Python 3.10 - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) - def test_get_dummies_basic_drop_first(self, request, sparse): + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False) + def test_get_dummies_basic_drop_first(self, sparse): # GH12402 Add a new parameter `drop_first` to avoid collinearity # Basic case s_list = list("abc") @@ -471,18 +471,14 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse): result = get_dummies(s_series_index, drop_first=True, sparse=sparse) tm.assert_frame_equal(result, expected) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - def test_get_dummies_basic_drop_first_NA(self, request, sparse): + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) + def test_get_dummies_basic_drop_first_NA(self, sparse): # Test NA handling together with drop_first s_NA = ["a", "b", np.nan] res = get_dummies(s_NA, drop_first=True, sparse=sparse) exp = DataFrame({"b": [0, 1, 0]}, dtype=np.uint8) if sparse: exp = exp.apply(SparseArray, fill_value=0) - else: - request.applymarker( - pytest.mark.xfail(PY310, reason="Failing on Python 3.10") - ) tm.assert_frame_equal(res, exp) diff --git a/pandas/tests/series/methods/test_reindex.py b/pandas/tests/series/methods/test_reindex.py index b7e9f8880b6d8..4f782d2a3feea 100644 --- a/pandas/tests/series/methods/test_reindex.py +++ b/pandas/tests/series/methods/test_reindex.py @@ -56,7 +56,7 @@ def test_reindex(datetime_series, string_series): assert not (result is datetime_series) -@pytest.mark.xfail(PY310, reason="Failing on Python 3.10") +@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940") def test_reindex_nan(): ts = Series([2, 3, 5, 7], index=[1, 4, np.nan, 8]) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 63e2c857851ec..490052c793fdc 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -787,7 +787,7 @@ def test_different_nans(self): tm.assert_numpy_array_equal(result, expected) # Flaky on Python 3.10 -> Don't make strict - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False) def test_first_nan_kept(self): # GH 22295 # create different nans from bit-patterns: @@ -994,7 +994,7 @@ def __hash__(self): tm.assert_numpy_array_equal(algos.isin([a], [b]), np.array([False])) # Flaky on Python 3.10 -> Don't make strict - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False) def test_different_nans(self): # GH 22160 # all nans are handled as equivalent @@ -1038,7 +1038,7 @@ def test_empty(self, empty): tm.assert_numpy_array_equal(expected, result) # Flaky on Python 3.10 -> Don't make strict - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False) def test_different_nan_objects(self): # GH 22119 comps = np.array(["nan", np.nan * 1j, float("nan")], dtype=object) From 3a7314b0d5cd84911114933bad8e17cb776ddfba Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 11 Jun 2021 10:18:40 -0700 Subject: [PATCH 27/43] Update test_get_dummies.py --- pandas/tests/reshape/test_get_dummies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/reshape/test_get_dummies.py b/pandas/tests/reshape/test_get_dummies.py index b8100d220dca2..d33721c796efa 100644 --- a/pandas/tests/reshape/test_get_dummies.py +++ b/pandas/tests/reshape/test_get_dummies.py @@ -471,7 +471,7 @@ def test_get_dummies_basic_drop_first_one_level(self, sparse): result = get_dummies(s_series_index, drop_first=True, sparse=sparse) tm.assert_frame_equal(result, expected) - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10", strict=False) + @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940", strict=False) def test_get_dummies_basic_drop_first_NA(self, sparse): # Test NA handling together with drop_first s_NA = ["a", "b", np.nan] From e76902f2464bec301db99a31cef6ab1e47a3c4c1 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Wed, 16 Jun 2021 06:59:51 -0700 Subject: [PATCH 28/43] try using run_tests --- .github/workflows/python-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 0d120ffe5bf90..667a684f1f4d7 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -50,7 +50,7 @@ jobs: - name: Test with pytest run: | - coverage run -m pytest -m 'not slow and not network and not clipboard' -n auto pandas + ci/run_tests.sh - name: Publish test results uses: actions/upload-artifact@master From 6b7ab013a726451189fa857cb81046a8352895da Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 16 Jun 2021 08:29:38 -0700 Subject: [PATCH 29/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 667a684f1f4d7..635bd9a1cac50 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -10,6 +10,10 @@ on: paths-ignore: - "doc/**" +env: + PYTEST_WORKERS: "auto" + PANDAS_CI: 1 + jobs: build: runs-on: ubuntu-latest From 91796544909bf72e13d2c6457ed80425eebe6630 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 16 Jun 2021 09:31:43 -0700 Subject: [PATCH 30/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 635bd9a1cac50..4a358c8815863 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -13,6 +13,7 @@ on: env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 + PATTERN: "not slow and not network and not clipboard" jobs: build: From e5271fe35e526cae4475cb8448b9195233b925f0 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Fri, 18 Jun 2021 16:51:58 -0700 Subject: [PATCH 31/43] debug --- pandas/tests/series/methods/test_nlargest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 3af06145b9fcd..bad39deaf4617 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -168,6 +168,7 @@ def test_nlargest_n(self, n): def test_nlargest_boundary_integer(self, nselect_method, any_int_dtype): # GH#21426 + print(np.core.numeric.dtype) dtype_info = np.iinfo(any_int_dtype) min_val, max_val = dtype_info.min, dtype_info.max vals = [min_val, min_val + 1, max_val - 1, max_val] From 2d050b6f9897161006f1b6e2c6a89ff1ce683bde Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 20 Jun 2021 09:23:42 -0700 Subject: [PATCH 32/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 4a358c8815863..e11808e586fe4 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,6 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" + TEST_ARGS: "-s" jobs: build: From c765f4aa0f0aa119ff1139339eb161f4f3d58ded Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 20 Jun 2021 10:28:39 -0700 Subject: [PATCH 33/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index e11808e586fe4..8c3194df4d84d 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - TEST_ARGS: "-s" + TEST_ARGS: "-rx" jobs: build: From 955494e3a8836d7afcd2b0b3265ba31be928cc15 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 24 Jun 2021 16:23:47 -0700 Subject: [PATCH 34/43] Un-xfail some tests --- pandas/tests/extension/test_sparse.py | 20 -------------------- pandas/tests/frame/methods/test_reindex.py | 3 --- pandas/tests/series/methods/test_reindex.py | 3 --- 3 files changed, 26 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 1f3f97bb78872..9c21f717573c1 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -17,7 +17,6 @@ import numpy as np import pytest -from pandas.compat import PY310 from pandas.errors import PerformanceWarning from pandas.core.dtypes.common import is_object_dtype @@ -176,25 +175,6 @@ def test_merge(self, data, na_value): def test_transpose(self, data): super().test_transpose(data) - # Inherited tests that fail on Python 3.10 (TODO: remove test once passed) - @pytest.mark.parametrize( - "columns", - [ - ["A", "B"], - pd.MultiIndex.from_tuples( - [("A", "a"), ("A", "b")], names=["outer", "inner"] - ), - ], - ) - def test_stack(self, request, data, columns): - if data.fill_value is np.nan: - request.applymarker( - pytest.mark.xfail( - PY310, reason="Failing on Python 3.10 GH41940", strict=False - ) - ) - super().test_stack(data, columns) - class TestGetitem(BaseSparseTests, base.BaseGetitemTests): def test_get(self, data): diff --git a/pandas/tests/frame/methods/test_reindex.py b/pandas/tests/frame/methods/test_reindex.py index 437ff2b70699f..d0765084adfa9 100644 --- a/pandas/tests/frame/methods/test_reindex.py +++ b/pandas/tests/frame/methods/test_reindex.py @@ -8,8 +8,6 @@ import numpy as np import pytest -from pandas.compat import PY310 - import pandas as pd from pandas import ( Categorical, @@ -478,7 +476,6 @@ def test_reindex(self, float_frame): tm.assert_frame_equal(result, float_frame) assert result is not float_frame - @pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940") def test_reindex_nan(self): df = DataFrame( [[1, 2], [3, 5], [7, 11], [9, 23]], diff --git a/pandas/tests/series/methods/test_reindex.py b/pandas/tests/series/methods/test_reindex.py index 4f782d2a3feea..36d3971d10a3d 100644 --- a/pandas/tests/series/methods/test_reindex.py +++ b/pandas/tests/series/methods/test_reindex.py @@ -1,8 +1,6 @@ import numpy as np import pytest -from pandas.compat import PY310 - from pandas import ( Categorical, Index, @@ -56,7 +54,6 @@ def test_reindex(datetime_series, string_series): assert not (result is datetime_series) -@pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940") def test_reindex_nan(): ts = Series([2, 3, 5, 7], index=[1, 4, np.nan, 8]) From 50536febd4ccb0fe256376b4f50f0b2d5954c6be Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 24 Jun 2021 16:25:08 -0700 Subject: [PATCH 35/43] More debugging --- .github/workflows/python-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 8c3194df4d84d..9da22a55821fc 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - TEST_ARGS: "-rx" + TEST_ARGS: "-v" jobs: build: From 10259f07d2028509aa37add691b85d54c55fd141 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 24 Jun 2021 17:42:00 -0700 Subject: [PATCH 36/43] debug more --- .github/workflows/python-dev.yml | 2 +- pandas/tests/series/methods/test_nlargest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 9da22a55821fc..295aac44346f2 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - TEST_ARGS: "-v" + TEST_ARGS: "--capture=no" jobs: build: diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index bad39deaf4617..db2edd6398211 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -168,7 +168,7 @@ def test_nlargest_n(self, n): def test_nlargest_boundary_integer(self, nselect_method, any_int_dtype): # GH#21426 - print(np.core.numeric.dtype) + print("np.core.numeric.dtype is", np.core.numeric.dtype) dtype_info = np.iinfo(any_int_dtype) min_val, max_val = dtype_info.min, dtype_info.max vals = [min_val, min_val + 1, max_val - 1, max_val] From 3e13b163a664d77d9fed6f79dacd9243ec58e189 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Sat, 26 Jun 2021 14:04:08 -0700 Subject: [PATCH 37/43] Un xfail some tests --- pandas/tests/apply/test_series_apply.py | 31 ++------------------ pandas/tests/arrays/sparse/test_dtype.py | 9 +----- pandas/tests/series/methods/test_nlargest.py | 1 - 3 files changed, 4 insertions(+), 37 deletions(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index cef7570da16c5..bfa88f54e4f10 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -7,8 +7,6 @@ import numpy as np import pytest -from pandas.compat import PY310 - from pandas.core.dtypes.common import is_number import pandas as pd @@ -117,20 +115,6 @@ def func(x): ser.apply(func) -def test_series_map_stringdtype(any_string_dtype): - # map test on StringDType, GH#40823 - ser1 = Series( - data=["cat", "dog", "rabbit"], - index=["id1", "id2", "id3"], - dtype=any_string_dtype, - ) - ser2 = Series(data=["id3", "id2", "id1", "id7000"], dtype=any_string_dtype) - result = ser2.map(ser1) - expected = Series(data=["rabbit", "dog", "cat", pd.NA], dtype=any_string_dtype) - - tm.assert_series_equal(result, expected) - - def test_apply_box(): # ufunc will not be boxed. Same test cases as the test_map_box vals = [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")] @@ -278,9 +262,7 @@ def test_transform_partial_failure(op, request): # GH 35964 if op in ("ffill", "bfill", "pad", "backfill", "shift"): request.node.add_marker( - pytest.mark.xfail( - raises=AssertionError, reason=f"{op} is successful on any dtype" - ) + pytest.mark.xfail(reason=f"{op} is successful on any dtype") ) if op in ("rank", "fillna"): pytest.skip(f"{op} doesn't raise TypeError on object") @@ -810,12 +792,7 @@ def f(x): @pytest.mark.parametrize( "vals,mapping,exp", [ - pytest.param( - list("abc"), - {np.nan: "not NaN"}, - [np.nan] * 3 + ["not NaN"], - marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), - ), + (list("abc"), {np.nan: "not NaN"}, [np.nan] * 3 + ["not NaN"]), (list("abc"), {"a": "a letter"}, ["a letter"] + [np.nan] * 3), (list(range(3)), {0: 42}, [42] + [np.nan] * 3), ], @@ -880,9 +857,7 @@ def test_apply_to_timedelta(): list_of_strings = ["00:00:01", np.nan, pd.NaT, pd.NaT] a = pd.to_timedelta(list_of_strings) # noqa - with tm.assert_produces_warning(FutureWarning, match="Inferring timedelta64"): - ser = Series(list_of_strings) - b = ser.apply(pd.to_timedelta) # noqa + b = Series(list_of_strings).apply(pd.to_timedelta) # noqa # Can't compare until apply on a Series gives the correct dtype # assert_series_equal(a, b) diff --git a/pandas/tests/arrays/sparse/test_dtype.py b/pandas/tests/arrays/sparse/test_dtype.py index ef73f179f4101..58fedbd3e4231 100644 --- a/pandas/tests/arrays/sparse/test_dtype.py +++ b/pandas/tests/arrays/sparse/test_dtype.py @@ -3,8 +3,6 @@ import numpy as np import pytest -from pandas.compat import PY310 - import pandas as pd from pandas.core.arrays.sparse import SparseDtype @@ -130,12 +128,7 @@ def test_construct_from_string(string, expected): [ (SparseDtype(float, 0.0), SparseDtype(np.dtype("float"), 0.0), True), (SparseDtype(int, 0), SparseDtype(int, 0), True), - pytest.param( - SparseDtype(float, float("nan")), - SparseDtype(float, np.nan), - True, - marks=pytest.mark.xfail(PY310, reason="Failing on Python 3.10 GH41940"), - ), + (SparseDtype(float, float("nan")), SparseDtype(float, np.nan), True), (SparseDtype(float, 0), SparseDtype(float, np.nan), False), (SparseDtype(int, 0.0), SparseDtype(float, 0.0), False), ], diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index db2edd6398211..3af06145b9fcd 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -168,7 +168,6 @@ def test_nlargest_n(self, n): def test_nlargest_boundary_integer(self, nselect_method, any_int_dtype): # GH#21426 - print("np.core.numeric.dtype is", np.core.numeric.dtype) dtype_info = np.iinfo(any_int_dtype) min_val, max_val = dtype_info.min, dtype_info.max vals = [min_val, min_val + 1, max_val - 1, max_val] From f84a97683f348daf2e42a5f923700350d1f65828 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Sat, 26 Jun 2021 14:06:13 -0700 Subject: [PATCH 38/43] Remove accidental changes --- pandas/tests/apply/test_series_apply.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index bfa88f54e4f10..34d00e653b52d 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -115,6 +115,20 @@ def func(x): ser.apply(func) +def test_series_map_stringdtype(any_string_dtype): + # map test on StringDType, GH#40823 + ser1 = Series( + data=["cat", "dog", "rabbit"], + index=["id1", "id2", "id3"], + dtype=any_string_dtype, + ) + ser2 = Series(data=["id3", "id2", "id1", "id7000"], dtype=any_string_dtype) + result = ser2.map(ser1) + expected = Series(data=["rabbit", "dog", "cat", pd.NA], dtype=any_string_dtype) + + tm.assert_series_equal(result, expected) + + def test_apply_box(): # ufunc will not be boxed. Same test cases as the test_map_box vals = [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")] @@ -262,7 +276,9 @@ def test_transform_partial_failure(op, request): # GH 35964 if op in ("ffill", "bfill", "pad", "backfill", "shift"): request.node.add_marker( - pytest.mark.xfail(reason=f"{op} is successful on any dtype") + pytest.mark.xfail( + raises=AssertionError, reason=f"{op} is successful on any dtype" + ) ) if op in ("rank", "fillna"): pytest.skip(f"{op} doesn't raise TypeError on object") @@ -857,7 +873,9 @@ def test_apply_to_timedelta(): list_of_strings = ["00:00:01", np.nan, pd.NaT, pd.NaT] a = pd.to_timedelta(list_of_strings) # noqa - b = Series(list_of_strings).apply(pd.to_timedelta) # noqa + with tm.assert_produces_warning(FutureWarning, match="Inferring timedelta64"): + ser = Series(list_of_strings) + b = ser.apply(pd.to_timedelta) # noqa # Can't compare until apply on a Series gives the correct dtype # assert_series_equal(a, b) From a87edcd226da64bacce1d146864d905e8fe43a0d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 27 Jun 2021 09:35:53 -0700 Subject: [PATCH 39/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 295aac44346f2..4a358c8815863 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,6 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - TEST_ARGS: "--capture=no" jobs: build: From 03eb6e7f73f13780e574a66e19fac1c2a4631fd5 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 27 Jun 2021 10:51:01 -0700 Subject: [PATCH 40/43] Fix coverage --- .github/workflows/python-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 4a358c8815863..a99e98a71d703 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,6 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" + COVERAGE: true jobs: build: From d28e3281e442ac33570a4450f4e6302568f47e1a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 27 Jun 2021 11:15:16 -0700 Subject: [PATCH 41/43] Actually fix coverage --- .github/workflows/python-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index a99e98a71d703..9941cfcc98e1b 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -42,7 +42,7 @@ jobs: pip install git+https://github.com/numpy/numpy.git pip install git+https://github.com/pytest-dev/pytest.git pip install git+https://github.com/nedbat/coveragepy.git - pip install cython python-dateutil pytz hypothesis pytest-xdist + pip install cython python-dateutil pytz hypothesis pytest-xdist pytest-cov pip list - name: Build Pandas From 64ed1f09063daf0a6c46c8e10c7fff33749d6e7e Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 27 Jun 2021 14:15:45 -0700 Subject: [PATCH 42/43] Disable coverage for now --- .github/workflows/python-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 9941cfcc98e1b..25e4653a013fd 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - COVERAGE: true + COVERAGE: false jobs: build: From 1094138d3f04b561e59823326cdddd38862083da Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 28 Jun 2021 08:35:23 -0700 Subject: [PATCH 43/43] Update python-dev.yml --- .github/workflows/python-dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-dev.yml b/.github/workflows/python-dev.yml index 25e4653a013fd..57e0144c967ea 100644 --- a/.github/workflows/python-dev.yml +++ b/.github/workflows/python-dev.yml @@ -14,7 +14,7 @@ env: PYTEST_WORKERS: "auto" PANDAS_CI: 1 PATTERN: "not slow and not network and not clipboard" - COVERAGE: false + COVERAGE: true jobs: build: @@ -57,6 +57,8 @@ jobs: - name: Test with pytest run: | ci/run_tests.sh + # GH 41935 + continue-on-error: true - name: Publish test results uses: actions/upload-artifact@master