Skip to content

Commit 233152d

Browse files
authored
DEPS: drop np 1.20 (#52661)
* DEPS: drop no 1.20 * update min version in doc * remove more compat * remove more compat, fix doc and ci * remove xfail in arrow test * fix pylint
1 parent e44daed commit 233152d

File tree

12 files changed

+16
-62
lines changed

12 files changed

+16
-62
lines changed

.github/workflows/sdist.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ jobs:
8181
run: |
8282
case "${{matrix.python-version}}" in
8383
3.8)
84-
pip install numpy==1.20.3 ;;
84+
pip install numpy==1.21.6 ;;
8585
3.9)
86-
pip install numpy==1.20.3 ;;
86+
pip install numpy==1.21.6 ;;
8787
3.10)
88-
pip install numpy==1.21.2 ;;
88+
pip install numpy==1.21.6 ;;
8989
3.11)
9090
pip install numpy==1.23.2 ;;
9191
esac

ci/deps/actions-38-minimum_versions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919

2020
# required dependencies
2121
- python-dateutil=2.8.2
22-
- numpy=1.20.3
22+
- numpy=1.21.6
2323
- pytz=2020.1
2424

2525
# optional dependencies

doc/source/getting_started/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pandas requires the following dependencies.
260260
================================================================ ==========================
261261
Package Minimum supported version
262262
================================================================ ==========================
263-
`NumPy <https://numpy.org>`__ 1.20.3
263+
`NumPy <https://numpy.org>`__ 1.21.6
264264
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
265265
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
266266
================================================================ ==========================

doc/source/whatsnew/v2.1.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ If installed, we now require:
131131
+-----------------+-----------------+----------+---------+
132132
| Package | Minimum Version | Required | Changed |
133133
+=================+=================+==========+=========+
134+
| numpy | 1.21.6 | X | X |
135+
+-----------------+-----------------+----------+---------+
134136
| mypy (dev) | 1.2 | | X |
135137
+-----------------+-----------------+----------+---------+
136138
| beautifulsoup4 | 4.11.1 | | X |

pandas/compat/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
PYPY,
2323
)
2424
import pandas.compat.compressors
25-
from pandas.compat.numpy import (
26-
is_numpy_dev,
27-
np_version_under1p21,
28-
)
25+
from pandas.compat.numpy import is_numpy_dev
2926
from pandas.compat.pyarrow import (
3027
pa_version_under7p0,
3128
pa_version_under8p0,
@@ -159,7 +156,6 @@ def get_lzma_file() -> type[pandas.compat.compressors.LZMAFile]:
159156

160157
__all__ = [
161158
"is_numpy_dev",
162-
"np_version_under1p21",
163159
"pa_version_under7p0",
164160
"pa_version_under8p0",
165161
"pa_version_under9p0",

pandas/compat/numpy/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66
# numpy versioning
77
_np_version = np.__version__
88
_nlv = Version(_np_version)
9-
np_version_under1p21 = _nlv < Version("1.21")
109
np_version_under1p22 = _nlv < Version("1.22")
11-
np_version_gte1p22 = _nlv >= Version("1.22")
1210
np_version_gte1p24 = _nlv >= Version("1.24")
1311
is_numpy_dev = _nlv.dev is not None
14-
_min_numpy_ver = "1.20.3"
12+
_min_numpy_ver = "1.21.6"
1513

16-
if is_numpy_dev or not np_version_under1p22:
17-
np_percentile_argname = "method"
18-
else:
19-
np_percentile_argname = "interpolation"
14+
np_percentile_argname = "interpolation" if np_version_under1p22 else "method"
2015

2116

2217
if _nlv < Version(_min_numpy_ver):

pandas/core/array_algos/putmask.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import numpy as np
1212

1313
from pandas._libs import lib
14-
from pandas.compat import np_version_under1p21
1514

1615
from pandas.core.dtypes.cast import infer_dtype_from
1716
from pandas.core.dtypes.common import is_list_like
@@ -73,9 +72,6 @@ def putmask_without_repeat(
7372
mask : np.ndarray[bool]
7473
new : Any
7574
"""
76-
if np_version_under1p21:
77-
new = setitem_datetimelike_compat(values, mask.sum(), new)
78-
7975
if getattr(new, "ndim", 0) >= 1:
8076
new = new.astype(values.dtype, copy=False)
8177

pandas/tests/extension/base/casting.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat import np_version_under1p21
54
import pandas.util._test_decorators as td
65

76
import pandas as pd
@@ -31,11 +30,9 @@ def test_astype_object_frame(self, all_data):
3130
assert isinstance(result._mgr.arrays[0], np.ndarray)
3231
assert result._mgr.arrays[0].dtype == np.dtype(object)
3332

34-
# earlier numpy raises TypeError on e.g. np.dtype(np.int64) == "Int64"
35-
if not np_version_under1p21:
36-
# check that we can compare the dtypes
37-
comp = result.dtypes == df.dtypes
38-
assert not comp.any()
33+
# check that we can compare the dtypes
34+
comp = result.dtypes == df.dtypes
35+
assert not comp.any()
3936

4037
def test_tolist(self, data):
4138
result = pd.Series(data).tolist()

pandas/tests/extension/base/dtype.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@ def test_check_dtype(self, data):
6262
{"A": pd.Series(data, dtype=dtype), "B": data, "C": "foo", "D": 1}
6363
)
6464
result = df.dtypes == str(dtype)
65-
66-
try:
67-
new_numpy_behavior = np.dtype("int64") != "Int64"
68-
except TypeError:
69-
# numpy<=1.20.3 this comparison could raise or in some cases
70-
# come back True
71-
new_numpy_behavior = True
72-
assert new_numpy_behavior
65+
assert np.dtype("int64") != "Int64"
7366

7467
expected = pd.Series([True, True, False, False], index=list("ABCD"))
7568

pandas/tests/extension/test_arrow.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,6 @@ def test_in_numeric_groupby(self, data_for_grouping):
600600

601601

602602
class TestBaseDtype(base.BaseDtypeTests):
603-
def test_check_dtype(self, data, request):
604-
pa_dtype = data.dtype.pyarrow_dtype
605-
if pa.types.is_decimal(pa_dtype) and pa_version_under8p0:
606-
request.node.add_marker(
607-
pytest.mark.xfail(
608-
raises=ValueError,
609-
reason="decimal string repr affects numpy comparison",
610-
)
611-
)
612-
super().test_check_dtype(data)
613-
614603
def test_construct_from_string_own_name(self, dtype, request):
615604
pa_dtype = dtype.pyarrow_dtype
616605
if pa.types.is_decimal(pa_dtype):

pandas/tests/frame/methods/test_quantile.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat.numpy import (
5-
np_percentile_argname,
6-
np_version_under1p21,
7-
)
4+
from pandas.compat.numpy import np_percentile_argname
85

96
import pandas as pd
107
from pandas import (
@@ -848,11 +845,6 @@ def test_quantile_ea(self, request, obj, index):
848845
qs = [0.5, 0, 1]
849846
result = self.compute_quantile(obj, qs)
850847

851-
if np_version_under1p21 and index.dtype == "timedelta64[ns]":
852-
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
853-
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
854-
request.node.add_marker(mark)
855-
856848
exp_dtype = index.dtype
857849
if index.dtype == "Int64":
858850
# match non-nullable casting behavior
@@ -914,11 +906,6 @@ def test_quantile_ea_scalar(self, request, obj, index):
914906
qs = 0.5
915907
result = self.compute_quantile(obj, qs)
916908

917-
if np_version_under1p21 and index.dtype == "timedelta64[ns]":
918-
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
919-
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
920-
request.node.add_marker(mark)
921-
922909
exp_dtype = index.dtype
923910
if index.dtype == "Int64":
924911
exp_dtype = "Float64"

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ authors = [
2323
license = {file = 'LICENSE'}
2424
requires-python = '>=3.8'
2525
dependencies = [
26-
"numpy>=1.20.3; python_version<'3.10'",
27-
"numpy>=1.21.0; python_version>='3.10'",
26+
"numpy>=1.21.6; python_version<'3.11'",
2827
"numpy>=1.23.2; python_version>='3.11'",
2928
"python-dateutil>=2.8.2",
3029
"pytz>=2020.1",

0 commit comments

Comments
 (0)