Skip to content

DEPS: drop numpy 1.16 #40814 #40851

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 14 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
vmImage: ${{ parameters.vmImage }}
strategy:
matrix:
py37_np16:
py37_np17:
ENV_FILE: ci/deps/azure-windows-37.yaml
CONDA_PY: "37"
PATTERN: "not slow and not network"
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-37-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:
- jinja2=2.10
- numba=0.46.0
- numexpr=2.6.8
- numpy=1.16.5
- numpy=1.17.3
- openpyxl=3.0.0
- pytables=3.5.1
- python-dateutil=2.7.3
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/azure-macos-37.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
- matplotlib=2.2.3
- nomkl
- numexpr
- numpy=1.16.5
- numpy=1.17.3
- openpyxl
- pyarrow=0.15.1
- pytables
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/azure-windows-37.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- moto>=1.3.14
- flask
- numexpr
- numpy=1.16.*
- numpy=1.17.*
- openpyxl
- pyarrow=0.15
- pytables
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 @@ -222,7 +222,7 @@ Dependencies
Package Minimum supported version
================================================================ ==========================
`setuptools <https://setuptools.readthedocs.io/en/latest/>`__ 38.6.0
`NumPy <https://numpy.org>`__ 1.16.5
`NumPy <https://numpy.org>`__ 1.17.3
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.7.3
`pytz <https://pypi.org/project/pytz/>`__ 2017.3
================================================================ ==========================
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ If installed, we now require:
+-----------------+-----------------+----------+---------+
| Package | Minimum Version | Required | Changed |
+=================+=================+==========+=========+
| numpy | 1.16.5 | X | |
| numpy | 1.17.3 | X | X |
+-----------------+-----------------+----------+---------+
| pytz | 2017.3 | X | |
+-----------------+-----------------+----------+---------+
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
# required
- numpy>=1.16.5
- numpy>=1.17.3
- python=3
- python-dateutil>=2.7.3
- pytz
Expand Down
1 change: 0 additions & 1 deletion pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

# numpy compat
from pandas.compat import (
np_version_under1p17 as _np_version_under1p17,
np_version_under1p18 as _np_version_under1p18,
is_numpy_dev as _is_numpy_dev,
)
Expand Down
2 changes: 0 additions & 2 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
is_numpy_dev,
np_array_datetime64_compat,
np_datetime64_compat,
np_version_under1p17,
np_version_under1p18,
np_version_under1p19,
np_version_under1p20,
Expand Down Expand Up @@ -133,7 +132,6 @@ def get_lzma_file(lzma):
"is_numpy_dev",
"np_array_datetime64_compat",
"np_datetime64_compat",
"np_version_under1p17",
"np_version_under1p18",
"np_version_under1p19",
"np_version_under1p20",
Expand Down
4 changes: 1 addition & 3 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
# numpy versioning
_np_version = np.__version__
_nlv = LooseVersion(_np_version)
np_version_under1p17 = _nlv < LooseVersion("1.17")
np_version_under1p18 = _nlv < LooseVersion("1.18")
np_version_under1p19 = _nlv < LooseVersion("1.19")
np_version_under1p20 = _nlv < LooseVersion("1.20")
is_numpy_dev = ".dev" in str(_nlv)
_min_numpy_ver = "1.16.5"
_min_numpy_ver = "1.17.3"


if _nlv < _min_numpy_ver:
Expand Down Expand Up @@ -65,6 +64,5 @@ def np_array_datetime64_compat(arr, dtype="M8[ns]"):
__all__ = [
"np",
"_np_version",
"np_version_under1p17",
"is_numpy_dev",
]
7 changes: 1 addition & 6 deletions pandas/core/array_algos/masked_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np

from pandas._libs import missing as libmissing
from pandas.compat import np_version_under1p17

from pandas.core.nanops import check_below_min_count

Expand Down Expand Up @@ -46,11 +45,7 @@ def _sumprod(
else:
if check_below_min_count(values.shape, mask, min_count):
return libmissing.NA

if np_version_under1p17:
return func(values[~mask])
else:
return func(values, where=~mask)
return func(values, where=~mask)


def sum(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class TestPDApi(Base):
"_hashtable",
"_lib",
"_libs",
"_np_version_under1p17",
"_np_version_under1p18",
"_is_numpy_dev",
"_testing",
Expand Down
20 changes: 0 additions & 20 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import numpy as np
import pytest

from pandas.compat import (
is_platform_windows,
np_version_under1p17,
)
from pandas.errors import PerformanceWarning
import pandas.util._test_decorators as td

Expand Down Expand Up @@ -220,22 +216,6 @@ def test_simple_cmp_ops(self, cmp_op):

@pytest.mark.parametrize("op", _good_arith_ops)
def test_binary_arith_ops(self, op, lhs, rhs, request):

if (
op == "/"
and isinstance(lhs, DataFrame)
and isinstance(rhs, DataFrame)
and not lhs.isna().any().any()
and rhs.shape == (10, 5)
and np_version_under1p17
and is_platform_windows()
and compat.PY38
):
mark = pytest.mark.xfail(
reason="GH#37328 floating point precision on Windows builds"
)
request.node.add_marker(mark)

self.check_binary_arith_op(lhs, op, rhs)

def test_modulus(self, lhs, rhs):
Expand Down
19 changes: 0 additions & 19 deletions pandas/tests/extension/base/dim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,10 @@
import numpy as np
import pytest

from pandas.compat import np_version_under1p17

import pandas as pd
from pandas.core.arrays import (
FloatingArray,
IntegerArray,
)
from pandas.tests.extension.base.base import BaseExtensionTests


def maybe_xfail_masked_reductions(arr, request):
if (
isinstance(arr, (FloatingArray, IntegerArray))
and np_version_under1p17
and arr.ndim == 2
):
mark = pytest.mark.xfail(reason="masked_reductions does not implement")
request.node.add_marker(mark)


class Dim2CompatTests(BaseExtensionTests):
def test_swapaxes(self, data):
arr2d = data.repeat(2).reshape(-1, 2)
Expand Down Expand Up @@ -148,7 +132,6 @@ def test_reductions_2d_axis_none(self, data, method, request):
pytest.skip("test is not applicable for this type/dtype")

arr2d = data.reshape(1, -1)
maybe_xfail_masked_reductions(arr2d, request)

err_expected = None
err_result = None
Expand Down Expand Up @@ -177,7 +160,6 @@ def test_reductions_2d_axis0(self, data, method, request):
pytest.skip("test is not applicable for this type/dtype")

arr2d = data.reshape(1, -1)
maybe_xfail_masked_reductions(arr2d, request)

kwargs = {}
if method == "std":
Expand Down Expand Up @@ -225,7 +207,6 @@ def test_reductions_2d_axis1(self, data, method, request):
pytest.skip("test is not applicable for this type/dtype")

arr2d = data.reshape(1, -1)
maybe_xfail_masked_reductions(arr2d, request)

try:
result = getattr(arr2d, method)(axis=1)
Expand Down
14 changes: 2 additions & 12 deletions pandas/tests/frame/methods/test_sample.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas.compat import np_version_under1p17

from pandas import (
DataFrame,
Series,
Expand Down Expand Up @@ -155,16 +153,8 @@ def test_sample_none_weights(self, obj):
"func_str,arg",
[
("np.array", [2, 3, 1, 0]),
pytest.param(
"np.random.MT19937",
3,
marks=pytest.mark.skipif(np_version_under1p17, reason="NumPy<1.17"),
),
pytest.param(
"np.random.PCG64",
11,
marks=pytest.mark.skipif(np_version_under1p17, reason="NumPy<1.17"),
),
("np.random.MT19937", 3),
("np.random.PCG64", 11),
],
)
def test_sample_random_state(self, func_str, arg, frame_or_series):
Expand Down
16 changes: 5 additions & 11 deletions pandas/tests/indexes/multi/test_analytics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas.compat import np_version_under1p17

import pandas as pd
from pandas import (
Index,
Expand Down Expand Up @@ -246,15 +244,11 @@ def test_numpy_ufuncs(idx, func):
# test ufuncs of numpy. see:
# https://numpy.org/doc/stable/reference/ufuncs.html

if np_version_under1p17:
expected_exception = AttributeError
msg = f"'tuple' object has no attribute '{func.__name__}'"
else:
expected_exception = TypeError
msg = (
"loop of ufunc does not support argument 0 of type tuple which "
f"has no callable {func.__name__} method"
)
expected_exception = TypeError
msg = (
"loop of ufunc does not support argument 0 of type tuple which "
f"has no callable {func.__name__} method"
)
with pytest.raises(expected_exception, match=msg):
func(idx)

Expand Down
19 changes: 9 additions & 10 deletions pandas/tests/indexes/test_numpy_compat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import numpy as np
import pytest

from pandas.compat import (
np_version_under1p17,
np_version_under1p18,
)
from pandas.compat import np_version_under1p18

from pandas import (
DatetimeIndex,
Expand Down Expand Up @@ -81,18 +78,20 @@ def test_numpy_ufuncs_other(index, func, request):
# test ufuncs of numpy, see:
# https://numpy.org/doc/stable/reference/ufuncs.html
if isinstance(index, (DatetimeIndex, TimedeltaIndex)):
if isinstance(index, DatetimeIndex) and index.tz is not None:
if func in [np.isfinite, np.isnan, np.isinf]:
if not np_version_under1p17:
mark = pytest.mark.xfail(reason="__array_ufunc__ is not defined")
request.node.add_marker(mark)
if (
isinstance(index, DatetimeIndex)
and index.tz is not None
and func in [np.isfinite, np.isnan, np.isinf]
):
mark = pytest.mark.xfail(reason="__array_ufunc__ is not defined")
request.node.add_marker(mark)

if not np_version_under1p18 and func in [np.isfinite, np.isinf, np.isnan]:
# numpy 1.18(dev) changed isinf and isnan to not raise on dt64/tfd64
result = func(index)
assert isinstance(result, np.ndarray)

elif not np_version_under1p17 and func in [np.isfinite]:
elif func is np.isfinite:
# ok under numpy >= 1.17
# Results in bool array
result = func(index)
Expand Down
19 changes: 8 additions & 11 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import numpy as np
import pytest

from pandas.compat import np_version_under1p17

import pandas as pd
from pandas import Series
import pandas._testing as tm
Expand Down Expand Up @@ -72,15 +70,14 @@ def test_random_state():

# Check BitGenerators
# GH32503
if not np_version_under1p17:
assert (
com.random_state(npr.MT19937(3)).uniform()
== npr.RandomState(npr.MT19937(3)).uniform()
)
assert (
com.random_state(npr.PCG64(11)).uniform()
== npr.RandomState(npr.PCG64(11)).uniform()
)
assert (
com.random_state(npr.MT19937(3)).uniform()
== npr.RandomState(npr.MT19937(3)).uniform()
)
assert (
com.random_state(npr.PCG64(11)).uniform()
== npr.RandomState(npr.PCG64(11)).uniform()
)

# Error for floats or strings
msg = (
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ requires = [
"setuptools>=38.6.0",
"wheel",
"Cython>=0.29.21,<3", # Note: sync with setup.py
"numpy==1.16.5; python_version=='3.7'",
"numpy==1.17.3; python_version=='3.8'",
"numpy==1.17.3; python_version=='3.7'",
"numpy==1.18.3; python_version=='3.8'",
"numpy; python_version>='3.9'",
]
# uncomment to enable pep517 after versioneer problem is fixed.
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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.16.5
numpy>=1.17.3
python-dateutil>=2.7.3
pytz
asv
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ project_urls =
[options]
packages = find:
install_requires =
numpy>=1.16.5
numpy>=1.17.3
python-dateutil>=2.7.3
pytz>=2017.3
python_requires = >=3.7.1
Expand Down