From b58c1da2a9684f7a9a697ae6a52c3c51f9ee68dd Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 26 Jan 2023 19:25:11 -0500 Subject: [PATCH 01/17] CI: Add complete build with 1.24 numpy --- .github/workflows/ubuntu.yml | 5 ++ ci/deps/actions-310_new_numpy_no_numba.yaml | 56 +++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 ci/deps/actions-310_new_numpy_no_numba.yaml diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 6726139ed5fa4..5c975e041734a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -78,6 +78,11 @@ jobs: pattern: "not slow and not network and not single_cpu" test_args: "-W error::DeprecationWarning -W error::FutureWarning" error_on_warnings: "0" + - name: "New Numpy (1.24)" + env_file: actions-310_new_numpy_no_numba.yaml + pattern: "not slow and not network and not single_cpu" + test_args: "-W error::DeprecationWarning -W error::FutureWarning" + error_on_warnings: "0" exclude: - env_file: actions-38.yaml pyarrow_version: "7" diff --git a/ci/deps/actions-310_new_numpy_no_numba.yaml b/ci/deps/actions-310_new_numpy_no_numba.yaml new file mode 100644 index 0000000000000..32aea82c055bf --- /dev/null +++ b/ci/deps/actions-310_new_numpy_no_numba.yaml @@ -0,0 +1,56 @@ +name: pandas-dev +channels: + - conda-forge +dependencies: + - python=3.10 + + # build dependencies + - versioneer[toml] + - cython>=0.29.32 + + # test dependencies + - pytest>=7.0.0 + - pytest-cov + - pytest-xdist>=2.2.0 + - psutil + - pytest-asyncio>=0.17 + - boto3 + + # required dependencies + - python-dateutil + - numpy>=1.24 + - pytz + + # optional dependencies + - beautifulsoup4 + - blosc + - bottleneck + - brotlipy + - fastparquet + - fsspec + - html5lib + - hypothesis + - gcsfs + - jinja2 + - lxml + - matplotlib>=3.6.1 + - numexpr + - openpyxl + - odfpy + - pandas-gbq + - psycopg2 + - pymysql + - pytables + - pyarrow + - pyreadstat + - python-snappy + - pyxlsb + - s3fs>=2021.08.0 + - scipy + - sqlalchemy<1.4.46 + - tabulate + - tzdata>=2022a + - xarray + - xlrd + - xlsxwriter + - zstandard From 993dec471b1b0d38026659cff9ae0c5aef619530 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 26 Jan 2023 21:46:23 -0500 Subject: [PATCH 02/17] Change --- .github/workflows/ubuntu.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5c975e041734a..245711ebed4c3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -81,7 +81,6 @@ jobs: - name: "New Numpy (1.24)" env_file: actions-310_new_numpy_no_numba.yaml pattern: "not slow and not network and not single_cpu" - test_args: "-W error::DeprecationWarning -W error::FutureWarning" error_on_warnings: "0" exclude: - env_file: actions-38.yaml From 27ceb6e634c331671723dce59f12e19a2b6e931e Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 16:44:32 -0500 Subject: [PATCH 03/17] Revert "Change" This reverts commit 993dec471b1b0d38026659cff9ae0c5aef619530. --- .github/workflows/ubuntu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 245711ebed4c3..5c975e041734a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -81,6 +81,7 @@ jobs: - name: "New Numpy (1.24)" env_file: actions-310_new_numpy_no_numba.yaml pattern: "not slow and not network and not single_cpu" + test_args: "-W error::DeprecationWarning -W error::FutureWarning" error_on_warnings: "0" exclude: - env_file: actions-38.yaml From 05f9c44ba7f9a0bf45706169661aac6e4087c42a Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 16:44:32 -0500 Subject: [PATCH 04/17] Revert "CI: Add complete build with 1.24 numpy" This reverts commit b58c1da2a9684f7a9a697ae6a52c3c51f9ee68dd. --- .github/workflows/ubuntu.yml | 5 -- ci/deps/actions-310_new_numpy_no_numba.yaml | 56 --------------------- 2 files changed, 61 deletions(-) delete mode 100644 ci/deps/actions-310_new_numpy_no_numba.yaml diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5c975e041734a..6726139ed5fa4 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -78,11 +78,6 @@ jobs: pattern: "not slow and not network and not single_cpu" test_args: "-W error::DeprecationWarning -W error::FutureWarning" error_on_warnings: "0" - - name: "New Numpy (1.24)" - env_file: actions-310_new_numpy_no_numba.yaml - pattern: "not slow and not network and not single_cpu" - test_args: "-W error::DeprecationWarning -W error::FutureWarning" - error_on_warnings: "0" exclude: - env_file: actions-38.yaml pyarrow_version: "7" diff --git a/ci/deps/actions-310_new_numpy_no_numba.yaml b/ci/deps/actions-310_new_numpy_no_numba.yaml deleted file mode 100644 index 32aea82c055bf..0000000000000 --- a/ci/deps/actions-310_new_numpy_no_numba.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: pandas-dev -channels: - - conda-forge -dependencies: - - python=3.10 - - # build dependencies - - versioneer[toml] - - cython>=0.29.32 - - # test dependencies - - pytest>=7.0.0 - - pytest-cov - - pytest-xdist>=2.2.0 - - psutil - - pytest-asyncio>=0.17 - - boto3 - - # required dependencies - - python-dateutil - - numpy>=1.24 - - pytz - - # optional dependencies - - beautifulsoup4 - - blosc - - bottleneck - - brotlipy - - fastparquet - - fsspec - - html5lib - - hypothesis - - gcsfs - - jinja2 - - lxml - - matplotlib>=3.6.1 - - numexpr - - openpyxl - - odfpy - - pandas-gbq - - psycopg2 - - pymysql - - pytables - - pyarrow - - pyreadstat - - python-snappy - - pyxlsb - - s3fs>=2021.08.0 - - scipy - - sqlalchemy<1.4.46 - - tabulate - - tzdata>=2022a - - xarray - - xlrd - - xlsxwriter - - zstandard From b01472478fbd1377e5c4ed2f11e05cde6bdefb22 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 16:44:52 -0500 Subject: [PATCH 05/17] Change 3.11 build --- ci/deps/actions-311.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/deps/actions-311.yaml b/ci/deps/actions-311.yaml index 8e15c7b4740c5..30050835008de 100644 --- a/ci/deps/actions-311.yaml +++ b/ci/deps/actions-311.yaml @@ -18,7 +18,7 @@ dependencies: # required dependencies - python-dateutil - - numpy<1.24.0 + - numpy>=1.24.0 - pytz # optional dependencies From 860cc0c209d09adeeb1b822fa3eb7a0ddf6930ca Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 19:10:08 -0500 Subject: [PATCH 06/17] Fix some tests --- pandas/compat/numpy/__init__.py | 1 + pandas/core/arrays/timedeltas.py | 8 +++++++- pandas/tests/arrays/floating/test_comparison.py | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index 60ec74553a207..6f31358dabe86 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -9,6 +9,7 @@ np_version_under1p21 = _nlv < Version("1.21") np_version_under1p22 = _nlv < Version("1.22") np_version_gte1p22 = _nlv >= Version("1.22") +np_version_gte1p24 = _nlv >= Version("1.24") is_numpy_dev = _nlv.dev is not None _min_numpy_ver = "1.20.3" diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 1e7d5f0436e7e..edd28991d4d4a 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -7,6 +7,7 @@ Iterator, cast, ) +import warnings import numpy as np @@ -918,7 +919,12 @@ def sequence_to_td64ns( mask = np.isnan(data) # The next few lines are effectively a vectorized 'cast_from_unit' m, p = precision_from_unit(unit or "ns") - base = data.astype(np.int64) + with warnings.catch_warnings(): + # Suppress RuntimeWarning about All-NaN slice + warnings.filterwarnings( + "ignore", "invalid value encountered in cast", RuntimeWarning + ) + base = data.astype(np.int64) frac = data - base if p: frac = np.round(frac, p) diff --git a/pandas/tests/arrays/floating/test_comparison.py b/pandas/tests/arrays/floating/test_comparison.py index a429649f1ce1d..42cce6790b253 100644 --- a/pandas/tests/arrays/floating/test_comparison.py +++ b/pandas/tests/arrays/floating/test_comparison.py @@ -1,6 +1,8 @@ import numpy as np import pytest +from pandas.compat.numpy import np_version_gte1p24 + import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray @@ -19,7 +21,11 @@ def test_compare_with_integerarray(self, comparison_op): op = comparison_op a = pd.array([0, 1, None] * 3, dtype="Int64") b = pd.array([0] * 3 + [1] * 3 + [None] * 3, dtype="Float64") - other = b.astype("Int64") + if np_version_gte1p24: + with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): + other = b.astype("Int64") + else: + other = b.astype("Int64") expected = op(a, other) result = op(a, b) tm.assert_extension_array_equal(result, expected) From 98d7ff97e07b3f2c47587d39128ea60a95fd9bf7 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 22:05:55 -0500 Subject: [PATCH 07/17] Fix --- pandas/core/arrays/timedeltas.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index edd28991d4d4a..a2b9b32ac6cfa 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -928,7 +928,11 @@ def sequence_to_td64ns( frac = data - base if p: frac = np.round(frac, p) - data = (base * m + (frac * m).astype(np.int64)).view("timedelta64[ns]") + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "invalid value encountered in cast", RuntimeWarning + ) + data = (base * m + (frac * m).astype(np.int64)).view("timedelta64[ns]") data[mask] = iNaT copy = False From d32a255baed47363631395cd4f035e7b56ec7665 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 27 Jan 2023 22:08:17 -0500 Subject: [PATCH 08/17] Fix --- pandas/core/dtypes/cast.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 3be89f6da2bd8..9dd5c50a65f5e 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -398,7 +398,11 @@ def trans(x): and not is_bool_dtype(result.dtype) and not is_string_dtype(result.dtype) ): - new_result = result.astype(dtype) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "overflow encountered in cast", RuntimeWarning + ) + new_result = result.astype(dtype) # Adjust tolerances based on floating point size size_tols = {4: 5e-4, 8: 5e-8, 16: 5e-16} From 4cc5f43cdddd270c2676e175d38dbece71bbbb58 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Thu, 2 Feb 2023 23:14:01 +0100 Subject: [PATCH 09/17] Fix some warnings --- pandas/core/arrays/masked.py | 13 ++++++++++--- pandas/core/dtypes/astype.py | 5 ++++- pandas/core/dtypes/cast.py | 4 +++- pandas/core/indexes/base.py | 12 +++++++++--- pandas/tests/io/parser/test_c_parser_only.py | 17 ++++++++++------- pandas/tests/series/test_constructors.py | 4 ++-- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index d45fe05d52937..7bf64b21697da 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -428,10 +428,14 @@ def to_numpy( "for this dtype." ) # don't pass copy to astype -> always need a copy since we are mutating - data = self._data.astype(dtype) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + data = self._data.astype(dtype) data[self._mask] = na_value else: - data = self._data.astype(dtype, copy=copy) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + data = self._data.astype(dtype, copy=copy) return data @doc(ExtensionArray.tolist) @@ -464,7 +468,10 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: # if we are astyping to another nullable masked dtype, we can fastpath if isinstance(dtype, BaseMaskedDtype): # TODO deal with NaNs for FloatingArray case - data = self._data.astype(dtype.numpy_dtype, copy=copy) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + # TODO: Is rounding what we want long term? + data = self._data.astype(dtype.numpy_dtype, copy=copy) # mask is copied depending on whether the data was copied, and # not directly depending on the `copy` keyword mask = self._mask if data is self._data else self._mask.copy() diff --git a/pandas/core/dtypes/astype.py b/pandas/core/dtypes/astype.py index e5b0b5658534f..59828ea9bb823 100644 --- a/pandas/core/dtypes/astype.py +++ b/pandas/core/dtypes/astype.py @@ -9,6 +9,7 @@ TYPE_CHECKING, overload, ) +import warnings import numpy as np @@ -153,7 +154,9 @@ def _astype_float_to_int_nansafe( # GH#45151 if not (values >= 0).all(): raise ValueError(f"Cannot losslessly cast from {values.dtype} to {dtype}") - return values.astype(dtype, copy=copy) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + return values.astype(dtype, copy=copy) def astype_array(values: ArrayLike, dtype: DtypeObj, copy: bool = False) -> ArrayLike: diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 9dd5c50a65f5e..3e61e94494b9b 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1610,7 +1610,9 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n ) casted = np.array(arr, dtype=dtype, copy=False) else: - casted = arr.astype(dtype, copy=False) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + casted = arr.astype(dtype, copy=False) except OverflowError as err: raise OverflowError( "The elements provided in the data cannot all be " diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index dbd70b8f4db62..a18f3892f094a 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3851,9 +3851,15 @@ def _get_fill_indexer( # but that doesn't appear to be enforced # error: "IndexEngine" has no attribute "get_indexer_with_fill" engine = self._engine - return engine.get_indexer_with_fill( # type: ignore[union-attr] - target=target._values, values=self._values, method=method, limit=limit - ) + with warnings.catch_warnings(): + # TODO: We need to fix this. Casting to int64 in cython + warnings.filterwarnings("ignore") + return engine.get_indexer_with_fill( # type: ignore[union-attr] + target=target._values, + values=self._values, + method=method, + limit=limit, + ) if self.is_monotonic_increasing and target.is_monotonic_increasing: target_values = target._get_engine_target() diff --git a/pandas/tests/io/parser/test_c_parser_only.py b/pandas/tests/io/parser/test_c_parser_only.py index d5a7610ecb8a9..4c6bc3583676a 100644 --- a/pandas/tests/io/parser/test_c_parser_only.py +++ b/pandas/tests/io/parser/test_c_parser_only.py @@ -21,6 +21,7 @@ IS64, is_ci_environment, ) +from pandas.compat.numpy import np_version_gte1p24 from pandas.errors import ParserError import pandas.util._test_decorators as td @@ -114,14 +115,16 @@ def test_dtype_and_names_error(c_parser_only): 3.0 3 """ # fallback casting, but not castable + warning = RuntimeWarning if np_version_gte1p24 else None with pytest.raises(ValueError, match="cannot safely convert"): - parser.read_csv( - StringIO(data), - sep=r"\s+", - header=None, - names=["a", "b"], - dtype={"a": np.int32}, - ) + with tm.assert_produces_warning(warning, check_stacklevel=False): + parser.read_csv( + StringIO(data), + sep=r"\s+", + header=None, + names=["a", "b"], + dtype={"a": np.int32}, + ) @pytest.mark.parametrize( diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 7f65bce873126..99f7f06b2fc89 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -798,7 +798,7 @@ def test_constructor_floating_data_int_dtype(self, frame_or_series): # Long-standing behavior (for Series, new in 2.0 for DataFrame) # has been to ignore the dtype on these; # not clear if this is what we want long-term - expected = frame_or_series(arr) + # expected = frame_or_series(arr) # GH#49599 as of 2.0 we raise instead of silently retaining float dtype msg = "Trying to coerce float values to integer" @@ -810,7 +810,7 @@ def test_constructor_floating_data_int_dtype(self, frame_or_series): # pre-2.0, when we had NaNs, we silently ignored the integer dtype arr[0] = np.nan - expected = frame_or_series(arr) + # expected = frame_or_series(arr) msg = r"Cannot convert non-finite values \(NA or inf\) to integer" with pytest.raises(IntCastingNaNError, match=msg): From b8e24b66e78b69c7191a28dc0816c07fc66b7c55 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 3 Feb 2023 21:02:55 +0100 Subject: [PATCH 10/17] Fix tests --- pandas/core/dtypes/cast.py | 4 +++- pandas/tests/arrays/floating/test_comparison.py | 8 +------- pandas/tests/plotting/frame/test_frame_subplots.py | 4 ++++ pandas/tests/plotting/test_series.py | 3 +++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 3e61e94494b9b..ddce29588ef8b 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1827,7 +1827,9 @@ def np_can_hold_element(dtype: np.dtype, element: Any) -> Any: # see test_where_complex GH#6345 return dtype.type(element) - casted = dtype.type(element) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + casted = dtype.type(element) if casted == element: return casted # otherwise e.g. overflow see test_32878_complex_itemsize diff --git a/pandas/tests/arrays/floating/test_comparison.py b/pandas/tests/arrays/floating/test_comparison.py index 42cce6790b253..a429649f1ce1d 100644 --- a/pandas/tests/arrays/floating/test_comparison.py +++ b/pandas/tests/arrays/floating/test_comparison.py @@ -1,8 +1,6 @@ import numpy as np import pytest -from pandas.compat.numpy import np_version_gte1p24 - import pandas as pd import pandas._testing as tm from pandas.core.arrays import FloatingArray @@ -21,11 +19,7 @@ def test_compare_with_integerarray(self, comparison_op): op = comparison_op a = pd.array([0, 1, None] * 3, dtype="Int64") b = pd.array([0] * 3 + [1] * 3 + [None] * 3, dtype="Float64") - if np_version_gte1p24: - with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): - other = b.astype("Int64") - else: - other = b.astype("Int64") + other = b.astype("Int64") expected = op(a, other) result = op(a, b) tm.assert_extension_array_equal(result, expected) diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 47d91c7975a28..3768f8858006d 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -6,6 +6,8 @@ import numpy as np import pytest +from pandas.compat import is_platform_linux +from pandas.compat.numpy import np_version_gte1p24 import pandas.util._test_decorators as td import pandas as pd @@ -370,6 +372,7 @@ def test_subplots_dup_columns(self): assert len(ax.lines) == 0 assert len(ax.right_ax.lines) == 5 + @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) def test_bar_log_no_subplots(self): # GH3254, GH3298 matplotlib/matplotlib#1882, #1892 # regressions in 1.2.1 @@ -380,6 +383,7 @@ def test_bar_log_no_subplots(self): ax = df.plot.bar(grid=True, log=True) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) + @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) def test_bar_log_subplots(self): expected = np.array([0.1, 1.0, 10.0, 100.0, 1000.0, 1e4]) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 3a9aa91002730..10523aa26ae3b 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -5,6 +5,8 @@ import numpy as np import pytest +from pandas.compat import is_platform_linux +from pandas.compat.numpy import np_version_gte1p24 import pandas.util._test_decorators as td import pandas as pd @@ -238,6 +240,7 @@ def test_line_use_index_false(self): label2 = ax2.get_xlabel() assert label2 == "" + @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) def test_bar_log(self): expected = np.array([1e-1, 1e0, 1e1, 1e2, 1e3, 1e4]) From b757913d072bb2314b1d9424ab009b6613e939ce Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 3 Feb 2023 22:17:33 +0100 Subject: [PATCH 11/17] Add reason --- pandas/tests/plotting/frame/test_frame_subplots.py | 8 ++++++-- pandas/tests/plotting/test_series.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 3768f8858006d..42285d7b61d40 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -372,7 +372,9 @@ def test_subplots_dup_columns(self): assert len(ax.lines) == 0 assert len(ax.right_ax.lines) == 5 - @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) + @pytest.mark.xfail( + np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" + ) def test_bar_log_no_subplots(self): # GH3254, GH3298 matplotlib/matplotlib#1882, #1892 # regressions in 1.2.1 @@ -383,7 +385,9 @@ def test_bar_log_no_subplots(self): ax = df.plot.bar(grid=True, log=True) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) - @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) + @pytest.mark.xfail( + np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" + ) def test_bar_log_subplots(self): expected = np.array([0.1, 1.0, 10.0, 100.0, 1000.0, 1e4]) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 10523aa26ae3b..ae0de8f97d029 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -240,7 +240,9 @@ def test_line_use_index_false(self): label2 = ax2.get_xlabel() assert label2 == "" - @pytest.mark.xfail(np_version_gte1p24 and is_platform_linux()) + @pytest.mark.xfail( + np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" + ) def test_bar_log(self): expected = np.array([1e-1, 1e0, 1e1, 1e2, 1e3, 1e4]) From 45504422e94d5e768f47ffa7b501d391ba4beb66 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Sun, 5 Feb 2023 00:42:31 +0100 Subject: [PATCH 12/17] Fix windows ci --- pandas/tests/extension/test_period.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index b51846e34fd88..366a4f074adaf 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -17,10 +17,12 @@ import pytest from pandas._libs import iNaT +from pandas.compat import is_platform_windows from pandas.core.dtypes.dtypes import PeriodDtype import pandas as pd +import pandas._testing as tm from pandas.core.arrays import PeriodArray from pandas.tests.extension import base @@ -94,6 +96,14 @@ def test_combine_add(self, data_repeated): # Period + Period is not defined. pass + @pytest.mark.parametrize("periods", [1, -2]) + def test_diff(self, data, periods): + if is_platform_windows(): + with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): + super().test_diff(data, periods) + else: + super().test_diff(data, periods) + class TestInterface(BasePeriodTests, base.BaseInterfaceTests): From 9558d567f6781b359c4bd400868120b3cdca5d5f Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Sun, 5 Feb 2023 23:20:58 +0100 Subject: [PATCH 13/17] Fix --- pandas/tests/extension/test_period.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index 366a4f074adaf..923dc24240f61 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -18,6 +18,7 @@ from pandas._libs import iNaT from pandas.compat import is_platform_windows +from pandas.compat.numpy import np_version_gte1p24 from pandas.core.dtypes.dtypes import PeriodDtype @@ -98,7 +99,7 @@ def test_combine_add(self, data_repeated): @pytest.mark.parametrize("periods", [1, -2]) def test_diff(self, data, periods): - if is_platform_windows(): + if is_platform_windows() and np_version_gte1p24: with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False): super().test_diff(data, periods) else: From 8bbb6fca17934f59d42085ac55516ddf5d5fed3c Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Mon, 6 Feb 2023 20:56:53 +0100 Subject: [PATCH 14/17] Update ci/deps/actions-311.yaml Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- ci/deps/actions-311.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/deps/actions-311.yaml b/ci/deps/actions-311.yaml index 3921444bbd3c8..fd12df0afda65 100644 --- a/ci/deps/actions-311.yaml +++ b/ci/deps/actions-311.yaml @@ -18,7 +18,7 @@ dependencies: # required dependencies - python-dateutil - - numpy>=1.24.0 + - numpy - pytz # optional dependencies From bc256fc2d0d4fcc2c11ed72373e608411288e95b Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Wed, 8 Feb 2023 19:45:51 +0100 Subject: [PATCH 15/17] Add warning category --- pandas/core/arrays/masked.py | 6 +++--- pandas/core/dtypes/astype.py | 2 +- pandas/core/dtypes/cast.py | 4 ++-- pandas/core/indexes/base.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index e38886ebfa16b..e9ffb9af98323 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -429,12 +429,12 @@ def to_numpy( ) # don't pass copy to astype -> always need a copy since we are mutating with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) data = self._data.astype(dtype) data[self._mask] = na_value else: with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) data = self._data.astype(dtype, copy=copy) return data @@ -469,7 +469,7 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: if isinstance(dtype, BaseMaskedDtype): # TODO deal with NaNs for FloatingArray case with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) # TODO: Is rounding what we want long term? data = self._data.astype(dtype.numpy_dtype, copy=copy) # mask is copied depending on whether the data was copied, and diff --git a/pandas/core/dtypes/astype.py b/pandas/core/dtypes/astype.py index 59828ea9bb823..681151f8c7b5f 100644 --- a/pandas/core/dtypes/astype.py +++ b/pandas/core/dtypes/astype.py @@ -155,7 +155,7 @@ def _astype_float_to_int_nansafe( if not (values >= 0).all(): raise ValueError(f"Cannot losslessly cast from {values.dtype} to {dtype}") with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) return values.astype(dtype, copy=copy) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index ddce29588ef8b..659da41acb1c4 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1611,7 +1611,7 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n casted = np.array(arr, dtype=dtype, copy=False) else: with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) casted = arr.astype(dtype, copy=False) except OverflowError as err: raise OverflowError( @@ -1624,7 +1624,7 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n return casted with warnings.catch_warnings(): - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) if np.array_equal(arr, casted): return casted diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index b19e329c2cfc9..e427442a1f6fb 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3874,7 +3874,7 @@ def _get_fill_indexer( engine = self._engine with warnings.catch_warnings(): # TODO: We need to fix this. Casting to int64 in cython - warnings.filterwarnings("ignore") + warnings.filterwarnings("ignore", category=RuntimeWarning) return engine.get_indexer_with_fill( # type: ignore[union-attr] target=target._values, values=self._values, From 3e3aaf07b4ebab262594ee7f6b6d4d0a873e0a09 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Thu, 9 Feb 2023 01:20:46 +0100 Subject: [PATCH 16/17] Update test_frame_subplots.py --- pandas/tests/plotting/frame/test_frame_subplots.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 42285d7b61d40..47d91c7975a28 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -6,8 +6,6 @@ import numpy as np import pytest -from pandas.compat import is_platform_linux -from pandas.compat.numpy import np_version_gte1p24 import pandas.util._test_decorators as td import pandas as pd @@ -372,9 +370,6 @@ def test_subplots_dup_columns(self): assert len(ax.lines) == 0 assert len(ax.right_ax.lines) == 5 - @pytest.mark.xfail( - np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" - ) def test_bar_log_no_subplots(self): # GH3254, GH3298 matplotlib/matplotlib#1882, #1892 # regressions in 1.2.1 @@ -385,9 +380,6 @@ def test_bar_log_no_subplots(self): ax = df.plot.bar(grid=True, log=True) tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) - @pytest.mark.xfail( - np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" - ) def test_bar_log_subplots(self): expected = np.array([0.1, 1.0, 10.0, 100.0, 1000.0, 1e4]) From b3b107fc5cd4da014f50ea1036f86b62b8e846a3 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Thu, 9 Feb 2023 01:21:06 +0100 Subject: [PATCH 17/17] Update test_series.py --- pandas/tests/plotting/test_series.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index ae0de8f97d029..3a9aa91002730 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -5,8 +5,6 @@ import numpy as np import pytest -from pandas.compat import is_platform_linux -from pandas.compat.numpy import np_version_gte1p24 import pandas.util._test_decorators as td import pandas as pd @@ -240,9 +238,6 @@ def test_line_use_index_false(self): label2 = ax2.get_xlabel() assert label2 == "" - @pytest.mark.xfail( - np_version_gte1p24 and is_platform_linux(), reason="Weird rounding problems" - ) def test_bar_log(self): expected = np.array([1e-1, 1e0, 1e1, 1e2, 1e3, 1e4])