From d164f2eea03e637f312db56e144e655e3bdcfd20 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 4 Jun 2022 11:22:43 -0500 Subject: [PATCH 1/5] DEPS: drop np18 support --- ci/deps/actions-38-minimum_versions.yaml | 2 +- doc/source/getting_started/install.rst | 2 +- doc/source/whatsnew/v1.5.0.rst | 2 ++ pandas/compat/__init__.py | 2 -- pandas/compat/numpy/__init__.py | 3 +-- pandas/tests/frame/indexing/test_where.py | 9 --------- pandas/tests/frame/test_constructors.py | 2 -- pandas/tests/series/test_constructors.py | 21 +++------------------ 8 files changed, 8 insertions(+), 35 deletions(-) diff --git a/ci/deps/actions-38-minimum_versions.yaml b/ci/deps/actions-38-minimum_versions.yaml index f68e3e31b5433..3ab27830060b2 100644 --- a/ci/deps/actions-38-minimum_versions.yaml +++ b/ci/deps/actions-38-minimum_versions.yaml @@ -17,7 +17,7 @@ dependencies: # required dependencies - python-dateutil=2.8.1 - - numpy=1.18.5 + - numpy=1.19.5 - pytz=2020.1 # optional dependencies diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index adc8b3d08d441..39c9db2c883b8 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -235,7 +235,7 @@ Dependencies ================================================================ ========================== Package Minimum supported version ================================================================ ========================== -`NumPy `__ 1.18.5 +`NumPy `__ 1.19.5 `python-dateutil `__ 2.8.1 `pytz `__ 2020.1 ================================================================ ========================== diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 6bf6fd65f5633..82e60f80953ae 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -362,6 +362,8 @@ If installed, we now require: +-----------------+-----------------+----------+---------+ | Package | Minimum Version | Required | Changed | +=================+=================+==========+=========+ +| numpy | 1.19.5 | X | X | ++-----------------+-----------------+----------+---------+ | mypy (dev) | 0.960 | | X | +-----------------+-----------------+----------+---------+ | beautifulsoup4 | 4.9.3 | | X | diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index bc8948cc8aee1..bb4787f07b2f0 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -14,7 +14,6 @@ from pandas._typing import F from pandas.compat.numpy import ( is_numpy_dev, - np_version_under1p19, np_version_under1p20, ) from pandas.compat.pyarrow import ( @@ -145,7 +144,6 @@ def get_lzma_file(): __all__ = [ "is_numpy_dev", - "np_version_under1p19", "np_version_under1p20", "pa_version_under1p01", "pa_version_under2p0", diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index 623c5fbecc48c..f9c43592d5f62 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -6,12 +6,11 @@ # numpy versioning _np_version = np.__version__ _nlv = Version(_np_version) -np_version_under1p19 = _nlv < Version("1.19") np_version_under1p20 = _nlv < Version("1.20") np_version_under1p22 = _nlv < Version("1.22") np_version_gte1p22 = _nlv >= Version("1.22") is_numpy_dev = _nlv.dev is not None -_min_numpy_ver = "1.18.5" +_min_numpy_ver = "1.19.5" if is_numpy_dev or not np_version_under1p22: np_percentile_argname = "method" diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index d65a5ebe56ee2..5548232937d77 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -4,8 +4,6 @@ import numpy as np import pytest -from pandas.compat import np_version_under1p19 - from pandas.core.dtypes.common import is_scalar import pandas as pd @@ -918,13 +916,6 @@ def test_where_period_invalid_na(frame_or_series, as_cat, request): r"Cannot setitem on a Categorical with a new category \(NaT\), " "set the categories first" ) - if np_version_under1p19: - mark = pytest.mark.xfail( - reason="When evaluating the f-string to generate the exception " - "message, numpy somehow ends up trying to cast None to int, so " - "ends up raising TypeError but with an unrelated message." - ) - request.node.add_marker(mark) else: msg = "value should be a 'Period'" diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index e62c050fbf812..5360885067c7a 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -18,7 +18,6 @@ import pytest import pytz -from pandas.compat import np_version_under1p19 import pandas.util._test_decorators as td from pandas.core.dtypes.common import is_integer_dtype @@ -308,7 +307,6 @@ def test_constructor_dtype_list_data(self): assert df.loc[1, 0] is None assert df.loc[0, 1] == "2" - @pytest.mark.skipif(np_version_under1p19, reason="NumPy change.") def test_constructor_list_of_2d_raises(self): # https://github.com/pandas-dev/pandas/issues/32289 a = DataFrame() diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index e0b180bf0c6f4..ee54424b38d32 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -13,10 +13,7 @@ iNaT, lib, ) -from pandas.compat.numpy import ( - np_version_under1p19, - np_version_under1p20, -) +from pandas.compat.numpy import np_version_under1p20 import pandas.util._test_decorators as td from pandas.core.dtypes.common import ( @@ -819,17 +816,12 @@ def test_constructor_coerce_float_valid(self, float_numpy_dtype): tm.assert_series_equal(s, expected) def test_constructor_invalid_coerce_ints_with_float_nan( - self, any_int_numpy_dtype, request + self, any_int_numpy_dtype ): # GH 22585 # Updated: make sure we treat this list the same as we would treat the - # equivalent ndarray - if np_version_under1p19 and np.dtype(any_int_numpy_dtype).kind == "u": - mark = pytest.mark.xfail(reason="Produces an extra RuntimeWarning") - request.node.add_marker(mark) - + # equivalent ndarray vals = [1, 2, np.nan] - msg = "In a future version, passing float-dtype values containing NaN" with tm.assert_produces_warning(FutureWarning, match=msg): res = Series(vals, dtype=any_int_numpy_dtype) @@ -1958,13 +1950,6 @@ def test_constructor(rand_series_with_duplicate_datetimeindex): ({1: 1}, np.array([[1]], dtype=np.int64)), ], ) -@pytest.mark.skipif(np_version_under1p19, reason="fails on numpy below 1.19") def test_numpy_array(input_dict, expected): result = np.array([Series(input_dict)]) tm.assert_numpy_array_equal(result, expected) - - -@pytest.mark.xfail(not np_version_under1p19, reason="check failure on numpy below 1.19") -def test_numpy_array_np_v1p19(): - with pytest.raises(KeyError, match="0"): - np.array([Series({1: 1})]) From 16d369de77f93f31c576194c9d2d97b05cee47aa Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 4 Jun 2022 11:25:56 -0500 Subject: [PATCH 2/5] reformat --- pandas/tests/series/test_constructors.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index ee54424b38d32..3dce22a06c1b2 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -815,9 +815,7 @@ def test_constructor_coerce_float_valid(self, float_numpy_dtype): expected = Series([1, 2, 3.5]).astype(float_numpy_dtype) tm.assert_series_equal(s, expected) - def test_constructor_invalid_coerce_ints_with_float_nan( - self, any_int_numpy_dtype - ): + def test_constructor_invalid_coerce_ints_with_float_nan(self, any_int_numpy_dtype): # GH 22585 # Updated: make sure we treat this list the same as we would treat the # equivalent ndarray From 0fc0e14f1626b17d6cd5b24716842d7d0b9095d1 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 4 Jun 2022 11:27:43 -0500 Subject: [PATCH 3/5] update env file --- environment.yml | 2 +- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 4131d0c814b60..1f1583354339c 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: # required - - numpy>=1.18.5 + - numpy>=1.19.5 - python=3.8 - python-dateutil>=2.8.1 - pytz diff --git a/requirements-dev.txt b/requirements-dev.txt index 9f80194775167..7640587b85a1c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ # This file is auto-generated from environment.yml, do not modify. # See that file for comments about the need/usage of each dependency. -numpy>=1.18.5 +numpy>=1.19.5 python-dateutil>=2.8.1 pytz asv From 44454e35cadc5aa7102674abc3e33e12b5339112 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 4 Jun 2022 13:14:21 -0500 Subject: [PATCH 4/5] xfail test for new min version --- pandas/tests/frame/indexing/test_where.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index 5548232937d77..378eeff7eedf5 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -4,6 +4,7 @@ import numpy as np import pytest +from pandas.compat import np_version_under1p20 from pandas.core.dtypes.common import is_scalar import pandas as pd @@ -1004,6 +1005,7 @@ def _check_where_equivalences(df, mask, other, expected): tm.assert_frame_equal(df, expected) +@pytest.mark.xfail(np_version_under1p20, reason="failed on Numpy 1.19.5") def test_where_dt64_2d(): dti = date_range("2016-01-01", periods=6) dta = dti._data.reshape(3, 2) From b6a8f1703c03f582888b04bcfed5c44caaebd5a5 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 4 Jun 2022 13:49:47 -0500 Subject: [PATCH 5/5] fix format --- pandas/tests/frame/indexing/test_where.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index 378eeff7eedf5..9d004613116b8 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -5,6 +5,7 @@ import pytest from pandas.compat import np_version_under1p20 + from pandas.core.dtypes.common import is_scalar import pandas as pd