Skip to content

Commit 61464f8

Browse files
authored
DEPS: drop np19 support (#47796)
1 parent 91d4cc5 commit 61464f8

File tree

17 files changed

+39
-83
lines changed

17 files changed

+39
-83
lines changed

.github/workflows/sdist.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ jobs:
7979
run: |
8080
case "${{matrix.python-version}}" in
8181
3.8)
82-
pip install numpy==1.19.5 ;;
82+
pip install numpy==1.20.3 ;;
8383
3.9)
84-
pip install numpy==1.19.5 ;;
84+
pip install numpy==1.20.3 ;;
8585
3.10)
8686
pip install numpy==1.21.2 ;;
8787
esac

ci/deps/actions-38-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717

1818
# required dependencies
1919
- python-dateutil=2.8.1
20-
- numpy=1.19.5
20+
- numpy=1.20.3
2121
- pytz=2020.1
2222

2323
# optional dependencies

doc/source/getting_started/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Dependencies
235235
================================================================ ==========================
236236
Package Minimum supported version
237237
================================================================ ==========================
238-
`NumPy <https://numpy.org>`__ 1.19.5
238+
`NumPy <https://numpy.org>`__ 1.20.3
239239
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.1
240240
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
241241
================================================================ ==========================

doc/source/whatsnew/v1.5.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ If installed, we now require:
416416
+-----------------+-----------------+----------+---------+
417417
| Package | Minimum Version | Required | Changed |
418418
+=================+=================+==========+=========+
419-
| numpy | 1.19.5 | X | X |
419+
| numpy | 1.20.3 | X | X |
420420
+-----------------+-----------------+----------+---------+
421421
| mypy (dev) | 0.971 | | X |
422422
+-----------------+-----------------+----------+---------+

pandas/compat/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pandas._typing import F
1818
from pandas.compat.numpy import (
1919
is_numpy_dev,
20-
np_version_under1p20,
20+
np_version_under1p21,
2121
)
2222
from pandas.compat.pyarrow import (
2323
pa_version_under1p01,
@@ -152,7 +152,7 @@ def get_lzma_file() -> type[lzma.LZMAFile]:
152152

153153
__all__ = [
154154
"is_numpy_dev",
155-
"np_version_under1p20",
155+
"np_version_under1p21",
156156
"pa_version_under1p01",
157157
"pa_version_under2p0",
158158
"pa_version_under3p0",

pandas/compat/numpy/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
# numpy versioning
77
_np_version = np.__version__
88
_nlv = Version(_np_version)
9-
np_version_under1p20 = _nlv < Version("1.20")
9+
np_version_under1p21 = _nlv < Version("1.21")
1010
np_version_under1p22 = _nlv < Version("1.22")
1111
np_version_gte1p22 = _nlv >= Version("1.22")
1212
is_numpy_dev = _nlv.dev is not None
13-
_min_numpy_ver = "1.19.5"
14-
is_numpy_min = _nlv == Version(_min_numpy_ver)
13+
_min_numpy_ver = "1.20.3"
1514

1615
if is_numpy_dev or not np_version_under1p22:
1716
np_percentile_argname = "method"

pandas/core/array_algos/putmask.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ArrayLike,
1313
npt,
1414
)
15-
from pandas.compat import np_version_under1p20
15+
from pandas.compat import np_version_under1p21
1616

1717
from pandas.core.dtypes.cast import infer_dtype_from
1818
from pandas.core.dtypes.common import is_list_like
@@ -66,7 +66,7 @@ def putmask_without_repeat(
6666
mask : np.ndarray[bool]
6767
new : Any
6868
"""
69-
if np_version_under1p20:
69+
if np_version_under1p21:
7070
new = setitem_datetimelike_compat(values, mask.sum(), new)
7171

7272
if getattr(new, "ndim", 0) >= 1:
@@ -78,7 +78,6 @@ def putmask_without_repeat(
7878
shape = np.shape(new)
7979
# np.shape compat for if setitem_datetimelike_compat
8080
# changed arraylike to list e.g. test_where_dt64_2d
81-
8281
if nlocs == shape[-1]:
8382
# GH#30567
8483
# If length of ``new`` is less than the length of ``values``,

pandas/tests/arrays/floating/test_construction.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat import np_version_under1p20
5-
64
import pandas as pd
75
import pandas._testing as tm
86
from pandas.core.arrays import FloatingArray
@@ -54,11 +52,6 @@ def test_floating_array_disallows_float16():
5452

5553
def test_floating_array_disallows_Float16_dtype(request):
5654
# GH#44715
57-
if np_version_under1p20:
58-
# https://github.com/numpy/numpy/issues/20512
59-
mark = pytest.mark.xfail(reason="numpy does not raise on np.dtype('Float16')")
60-
request.node.add_marker(mark)
61-
6255
with pytest.raises(TypeError, match="data type 'Float16' not understood"):
6356
pd.array([1.0, 2.0], dtype="Float16")
6457

pandas/tests/arrays/sparse/test_arithmetics.py

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

6-
from pandas.compat import np_version_under1p20
7-
86
import pandas as pd
97
import pandas._testing as tm
10-
from pandas.core import ops
118
from pandas.core.arrays.sparse import (
129
SparseArray,
1310
SparseDtype,
@@ -121,19 +118,7 @@ def test_float_scalar(
121118
self, kind, mix, all_arithmetic_functions, fill_value, scalar, request
122119
):
123120
op = all_arithmetic_functions
124-
125-
if np_version_under1p20:
126-
if op in [operator.floordiv, ops.rfloordiv]:
127-
if op is operator.floordiv and scalar != 0:
128-
pass
129-
elif op is ops.rfloordiv and scalar == 0:
130-
pass
131-
else:
132-
mark = pytest.mark.xfail(raises=AssertionError, reason="GH#38172")
133-
request.node.add_marker(mark)
134-
135121
values = np.array([np.nan, 1, 2, 0, np.nan, 0, 1, 2, 1, np.nan])
136-
137122
a = SparseArray(values, kind=kind, fill_value=fill_value)
138123
self._check_numeric_ops(a, scalar, values, scalar, mix, op)
139124

@@ -171,14 +156,6 @@ def test_float_same_index_with_nans(
171156
):
172157
# when sp_index are the same
173158
op = all_arithmetic_functions
174-
175-
if (
176-
np_version_under1p20
177-
and op is ops.rfloordiv
178-
and not (mix and kind == "block")
179-
):
180-
mark = pytest.mark.xfail(raises=AssertionError, reason="GH#38172")
181-
request.node.add_marker(mark)
182159
values = np.array([np.nan, 1, 2, 0, np.nan, 0, 1, 2, 1, np.nan])
183160
rvalues = np.array([np.nan, 2, 3, 4, np.nan, 0, 1, 3, 2, np.nan])
184161

@@ -353,13 +330,7 @@ def test_bool_array_logical(self, kind, fill_value):
353330

354331
def test_mixed_array_float_int(self, kind, mix, all_arithmetic_functions, request):
355332
op = all_arithmetic_functions
356-
357-
if np_version_under1p20 and op in [operator.floordiv, ops.rfloordiv] and mix:
358-
mark = pytest.mark.xfail(raises=AssertionError, reason="GH#38172")
359-
request.node.add_marker(mark)
360-
361333
rdtype = "int64"
362-
363334
values = np.array([np.nan, 1, 2, 0, np.nan, 0, 1, 2, 1, np.nan])
364335
rvalues = np.array([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=rdtype)
365336

pandas/tests/extension/base/casting.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat import np_version_under1p20
4+
from pandas.compat import np_version_under1p21
55
import pandas.util._test_decorators as td
66

77
import pandas as pd
@@ -32,8 +32,7 @@ def test_astype_object_frame(self, all_data):
3232
assert result._mgr.arrays[0].dtype == np.dtype(object)
3333

3434
# earlier numpy raises TypeError on e.g. np.dtype(np.int64) == "Int64"
35-
# instead of returning False
36-
if not np_version_under1p20:
35+
if not np_version_under1p21:
3736
# check that we can compare the dtypes
3837
comp = result.dtypes == df.dtypes
3938
assert not comp.any()

pandas/tests/extension/test_sparse.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import numpy as np
1818
import pytest
1919

20-
from pandas.compat import np_version_under1p20
2120
from pandas.errors import PerformanceWarning
2221

2322
from pandas.core.dtypes.common import is_object_dtype
@@ -415,12 +414,9 @@ def test_astype_object_frame(self, all_data):
415414
result = df.astype(object)
416415
assert is_object_dtype(result._mgr.arrays[0].dtype)
417416

418-
# earlier numpy raises TypeError on e.g. np.dtype(np.int64) == "Int64"
419-
# instead of returning False
420-
if not np_version_under1p20:
421-
# check that we can compare the dtypes
422-
comp = result.dtypes == df.dtypes
423-
assert not comp.any()
417+
# check that we can compare the dtypes
418+
comp = result.dtypes == df.dtypes
419+
assert not comp.any()
424420

425421
def test_astype_str(self, data):
426422
with tm.assert_produces_warning(FutureWarning, match="astype from Sparse"):

pandas/tests/frame/indexing/test_where.py

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

7-
from pandas.compat import np_version_under1p20
8-
97
from pandas.core.dtypes.common import is_scalar
108

119
import pandas as pd
@@ -1006,7 +1004,6 @@ def _check_where_equivalences(df, mask, other, expected):
10061004
tm.assert_frame_equal(df, expected)
10071005

10081006

1009-
@pytest.mark.xfail(np_version_under1p20, reason="failed on Numpy 1.19.5")
10101007
def test_where_dt64_2d():
10111008
dti = date_range("2016-01-01", periods=6)
10121009
dta = dti._data.reshape(3, 2)

pandas/tests/frame/methods/test_quantile.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import numpy as np
22
import pytest
33

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

69
import pandas as pd
710
from pandas import (
@@ -655,7 +658,7 @@ def compute_quantile(self, obj, qs):
655658
result = obj.quantile(qs, numeric_only=False)
656659
return result
657660

658-
def test_quantile_ea(self, obj, index):
661+
def test_quantile_ea(self, request, obj, index):
659662

660663
# result should be invariant to shuffling
661664
indexer = np.arange(len(index), dtype=np.intp)
@@ -665,6 +668,11 @@ def test_quantile_ea(self, obj, index):
665668
qs = [0.5, 0, 1]
666669
result = self.compute_quantile(obj, qs)
667670

671+
if np_version_under1p21 and index.dtype == "timedelta64[ns]":
672+
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
673+
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
674+
request.node.add_marker(mark)
675+
668676
exp_dtype = index.dtype
669677
if index.dtype == "Int64":
670678
# match non-nullable casting behavior
@@ -700,7 +708,7 @@ def test_quantile_ea_with_na(self, obj, index):
700708

701709
# TODO(GH#39763): filtering can be removed after GH#39763 is fixed
702710
@pytest.mark.filterwarnings("ignore:Using .astype to convert:FutureWarning")
703-
def test_quantile_ea_all_na(self, obj, index):
711+
def test_quantile_ea_all_na(self, request, obj, index):
704712
obj.iloc[:] = index._na_value
705713

706714
# TODO(ArrayManager): this casting should be unnecessary after GH#39763 is fixed
@@ -715,14 +723,19 @@ def test_quantile_ea_all_na(self, obj, index):
715723
qs = [0.5, 0, 1]
716724
result = self.compute_quantile(obj, qs)
717725

726+
if np_version_under1p21 and index.dtype == "timedelta64[ns]":
727+
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
728+
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
729+
request.node.add_marker(mark)
730+
718731
expected = index.take([-1, -1, -1], allow_fill=True, fill_value=index._na_value)
719732
expected = Series(expected, index=qs, name="A")
720733
if expected.dtype == "Int64":
721734
expected = expected.astype("Float64")
722735
expected = type(obj)(expected)
723736
tm.assert_equal(result, expected)
724737

725-
def test_quantile_ea_scalar(self, obj, index):
738+
def test_quantile_ea_scalar(self, request, obj, index):
726739
# scalar qs
727740

728741
# result should be invariant to shuffling
@@ -733,6 +746,11 @@ def test_quantile_ea_scalar(self, obj, index):
733746
qs = 0.5
734747
result = self.compute_quantile(obj, qs)
735748

749+
if np_version_under1p21 and index.dtype == "timedelta64[ns]":
750+
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
751+
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
752+
request.node.add_marker(mark)
753+
736754
exp_dtype = index.dtype
737755
if index.dtype == "Int64":
738756
exp_dtype = "Float64"

pandas/tests/frame/methods/test_replace.py

-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import numpy as np
77
import pytest
88

9-
from pandas.compat import np_version_under1p20
10-
119
import pandas as pd
1210
from pandas import (
1311
DataFrame,
@@ -1316,12 +1314,6 @@ def test_replace_commutative(self, df, to_replace, exp):
13161314
)
13171315
def test_replace_replacer_dtype(self, request, replacer):
13181316
# GH26632
1319-
if np.isscalar(replacer) and replacer.dtype.itemsize < 8:
1320-
request.node.add_marker(
1321-
pytest.mark.xfail(
1322-
np_version_under1p20, reason="np.putmask doesn't coerce dtype"
1323-
)
1324-
)
13251317
df = DataFrame(["a"])
13261318
result = df.replace({"a": replacer, "b": replacer})
13271319
expected = DataFrame([replacer])

pandas/tests/indexing/test_iloc.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import numpy as np
1111
import pytest
1212

13-
from pandas.compat.numpy import is_numpy_min
1413
from pandas.errors import IndexingError
1514
import pandas.util._test_decorators as td
1615

@@ -1199,7 +1198,6 @@ def test_iloc_getitem_int_single_ea_block_view(self):
11991198
arr[2] = arr[-1]
12001199
assert ser[0] == arr[-1]
12011200

1202-
@pytest.mark.xfail(is_numpy_min, reason="Column A gets coerced to integer type")
12031201
def test_iloc_setitem_multicolumn_to_datetime(self, using_array_manager):
12041202

12051203
# GH#20511

pandas/tests/series/test_constructors.py

-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
iNaT,
1414
lib,
1515
)
16-
from pandas.compat.numpy import np_version_under1p20
1716
import pandas.util._test_decorators as td
1817

1918
from pandas.core.dtypes.common import (
@@ -1904,9 +1903,6 @@ def test_constructor_dtype_timedelta_ns_s_astype_int64(self):
19041903
@pytest.mark.filterwarnings(
19051904
"ignore:elementwise comparison failed:DeprecationWarning"
19061905
)
1907-
@pytest.mark.xfail(
1908-
np_version_under1p20, reason="np.array([td64nat, float, float]) raises"
1909-
)
19101906
@pytest.mark.parametrize("func", [Series, DataFrame, Index, pd.array])
19111907
def test_constructor_mismatched_null_nullable_dtype(
19121908
self, func, any_numeric_ea_dtype

setup.cfg

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ project_urls =
3131
[options]
3232
packages = find:
3333
install_requires =
34-
numpy>=1.18.5; platform_machine!='aarch64' and platform_machine!='arm64' and python_version<'3.10'
35-
numpy>=1.19.2; platform_machine=='aarch64' and python_version<'3.10'
36-
numpy>=1.20.0; platform_machine=='arm64' and python_version<'3.10'
34+
numpy>=1.20.3; python_version<'3.10'
3735
numpy>=1.21.0; python_version>='3.10'
3836
python-dateutil>=2.8.1
3937
pytz>=2020.1

0 commit comments

Comments
 (0)