Skip to content

DEPS: drop np 1.20 #52661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 20, 2023
6 changes: 3 additions & 3 deletions .github/workflows/sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ jobs:
run: |
case "${{matrix.python-version}}" in
3.8)
pip install numpy==1.20.3 ;;
pip install numpy==1.21.6 ;;
3.9)
pip install numpy==1.20.3 ;;
pip install numpy==1.21.6 ;;
3.10)
pip install numpy==1.21.2 ;;
pip install numpy==1.21.6 ;;
3.11)
pip install numpy==1.23.2 ;;
esac
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-38-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:

# required dependencies
- python-dateutil=2.8.2
- numpy=1.20.3
- numpy=1.21.6
- pytz=2020.1

# optional dependencies
Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pandas requires the following dependencies.
================================================================ ==========================
Package Minimum supported version
================================================================ ==========================
`NumPy <https://numpy.org>`__ 1.20.3
`NumPy <https://numpy.org>`__ 1.21.6
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
================================================================ ==========================
Expand Down
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ If installed, we now require:
+-----------------+-----------------+----------+---------+
| Package | Minimum Version | Required | Changed |
+=================+=================+==========+=========+
| numpy | 1.21.6 | X | X |
+-----------------+-----------------+----------+---------+
| mypy (dev) | 1.2 | | X |
+-----------------+-----------------+----------+---------+
| beautifulsoup4 | 4.11.1 | | X |
Expand Down
6 changes: 1 addition & 5 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
PYPY,
)
import pandas.compat.compressors
from pandas.compat.numpy import (
is_numpy_dev,
np_version_under1p21,
)
from pandas.compat.numpy import is_numpy_dev
from pandas.compat.pyarrow import (
pa_version_under7p0,
pa_version_under8p0,
Expand Down Expand Up @@ -159,7 +156,6 @@ def get_lzma_file() -> type[pandas.compat.compressors.LZMAFile]:

__all__ = [
"is_numpy_dev",
"np_version_under1p21",
"pa_version_under7p0",
"pa_version_under8p0",
"pa_version_under9p0",
Expand Down
9 changes: 2 additions & 7 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
# numpy versioning
_np_version = np.__version__
_nlv = Version(_np_version)
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"
_min_numpy_ver = "1.21.6"

if is_numpy_dev or not np_version_under1p22:
np_percentile_argname = "method"
else:
np_percentile_argname = "interpolation"
np_percentile_argname = "interpolation" if np_version_under1p22 else "method"


if _nlv < Version(_min_numpy_ver):
Expand Down
4 changes: 0 additions & 4 deletions pandas/core/array_algos/putmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import numpy as np

from pandas._libs import lib
from pandas.compat import np_version_under1p21

from pandas.core.dtypes.cast import infer_dtype_from
from pandas.core.dtypes.common import is_list_like
Expand Down Expand Up @@ -73,9 +72,6 @@ def putmask_without_repeat(
mask : np.ndarray[bool]
new : Any
"""
if np_version_under1p21:
new = setitem_datetimelike_compat(values, mask.sum(), new)

if getattr(new, "ndim", 0) >= 1:
new = new.astype(values.dtype, copy=False)

Expand Down
9 changes: 3 additions & 6 deletions pandas/tests/extension/base/casting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import pytest

from pandas.compat import np_version_under1p21
import pandas.util._test_decorators as td

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

# earlier numpy raises TypeError on e.g. np.dtype(np.int64) == "Int64"
if not np_version_under1p21:
# check that we can compare the dtypes
comp = result.dtypes == df.dtypes
assert not comp.any()
# check that we can compare the dtypes
comp = result.dtypes == df.dtypes
assert not comp.any()

def test_tolist(self, data):
result = pd.Series(data).tolist()
Expand Down
9 changes: 1 addition & 8 deletions pandas/tests/extension/base/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@ def test_check_dtype(self, data):
{"A": pd.Series(data, dtype=dtype), "B": data, "C": "foo", "D": 1}
)
result = df.dtypes == str(dtype)

try:
new_numpy_behavior = np.dtype("int64") != "Int64"
except TypeError:
# numpy<=1.20.3 this comparison could raise or in some cases
# come back True
new_numpy_behavior = True
assert new_numpy_behavior
assert np.dtype("int64") != "Int64"

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

Expand Down
11 changes: 0 additions & 11 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,6 @@ def test_in_numeric_groupby(self, data_for_grouping):


class TestBaseDtype(base.BaseDtypeTests):
def test_check_dtype(self, data, request):
pa_dtype = data.dtype.pyarrow_dtype
if pa.types.is_decimal(pa_dtype) and pa_version_under8p0:
request.node.add_marker(
pytest.mark.xfail(
raises=ValueError,
reason="decimal string repr affects numpy comparison",
)
)
super().test_check_dtype(data)

def test_construct_from_string_own_name(self, dtype, request):
pa_dtype = dtype.pyarrow_dtype
if pa.types.is_decimal(pa_dtype):
Expand Down
15 changes: 1 addition & 14 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import numpy as np
import pytest

from pandas.compat.numpy import (
np_percentile_argname,
np_version_under1p21,
)
from pandas.compat.numpy import np_percentile_argname

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

if np_version_under1p21 and index.dtype == "timedelta64[ns]":
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
request.node.add_marker(mark)

exp_dtype = index.dtype
if index.dtype == "Int64":
# match non-nullable casting behavior
Expand Down Expand Up @@ -914,11 +906,6 @@ def test_quantile_ea_scalar(self, request, obj, index):
qs = 0.5
result = self.compute_quantile(obj, qs)

if np_version_under1p21 and index.dtype == "timedelta64[ns]":
msg = "failed on Numpy 1.20.3; TypeError: data type 'Int64' not understood"
mark = pytest.mark.xfail(reason=msg, raises=TypeError)
request.node.add_marker(mark)

exp_dtype = index.dtype
if index.dtype == "Int64":
exp_dtype = "Float64"
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ authors = [
license = {file = 'LICENSE'}
requires-python = '>=3.8'
dependencies = [
"numpy>=1.20.3; python_version<'3.10'",
"numpy>=1.21.0; python_version>='3.10'",
"numpy>=1.21.6; python_version<'3.11'",
"numpy>=1.23.2; python_version>='3.11'",
"python-dateutil>=2.8.2",
"pytz>=2020.1",
Expand Down