From 6a0b5523634b8a802d91e2abb2090a99a43bae3a Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 11:06:58 -0500 Subject: [PATCH 01/10] DEPS: drop numpy 1.16 #40814 --- ci/azure/windows.yml | 2 +- ci/deps/actions-37-minimum_versions.yaml | 2 +- ci/deps/azure-macos-37.yaml | 2 +- ci/deps/azure-windows-37.yaml | 2 +- doc/source/getting_started/install.rst | 2 +- doc/source/whatsnew/v1.3.0.rst | 2 +- environment.yml | 2 +- pandas/__init__.py | 1 - pandas/compat/__init__.py | 2 -- pandas/compat/numpy/__init__.py | 4 +--- pandas/core/array_algos/masked_reductions.py | 7 +------ pandas/tests/api/test_api.py | 1 - pandas/tests/computation/test_eval.py | 20 -------------------- pandas/tests/extension/base/dim2.py | 19 ------------------- pandas/tests/frame/methods/test_sample.py | 14 ++------------ pandas/tests/indexes/multi/test_analytics.py | 16 +++++----------- pandas/tests/indexes/test_numpy_compat.py | 13 ++----------- pandas/tests/test_common.py | 19 ++++++++----------- pyproject.toml | 4 ++-- requirements-dev.txt | 2 +- setup.cfg | 2 +- 21 files changed, 30 insertions(+), 108 deletions(-) diff --git a/ci/azure/windows.yml b/ci/azure/windows.yml index e510f4115b25f..5644ad46714d5 100644 --- a/ci/azure/windows.yml +++ b/ci/azure/windows.yml @@ -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" diff --git a/ci/deps/actions-37-minimum_versions.yaml b/ci/deps/actions-37-minimum_versions.yaml index e14e51a36be31..8052156858a32 100644 --- a/ci/deps/actions-37-minimum_versions.yaml +++ b/ci/deps/actions-37-minimum_versions.yaml @@ -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 diff --git a/ci/deps/azure-macos-37.yaml b/ci/deps/azure-macos-37.yaml index d667adddda859..8c8b49ff3df5b 100644 --- a/ci/deps/azure-macos-37.yaml +++ b/ci/deps/azure-macos-37.yaml @@ -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 diff --git a/ci/deps/azure-windows-37.yaml b/ci/deps/azure-windows-37.yaml index e7ac4c783b855..c9d22ffbead45 100644 --- a/ci/deps/azure-windows-37.yaml +++ b/ci/deps/azure-windows-37.yaml @@ -24,7 +24,7 @@ dependencies: - moto>=1.3.14 - flask - numexpr - - numpy=1.16.* + - numpy=1.17.* - openpyxl - pyarrow=0.15 - pytables diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index f56391ab568ac..b6351ac2232ff 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -222,7 +222,7 @@ Dependencies Package Minimum supported version ================================================================ ========================== `setuptools `__ 38.6.0 -`NumPy `__ 1.16.5 +`NumPy `__ 1.17.3 `python-dateutil `__ 2.7.3 `pytz `__ 2017.3 ================================================================ ========================== diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 3a0e1b7568c91..9f88c9cfe7293 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -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 | | +-----------------+-----------------+----------+---------+ diff --git a/environment.yml b/environment.yml index b942adb764104..0c07e531051df 100644 --- a/environment.yml +++ b/environment.yml @@ -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 diff --git a/pandas/__init__.py b/pandas/__init__.py index 7cad3eded0585..db4043686bcbb 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -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, ) diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index eb6cf4f9d7d85..cddab28476ae2 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -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, @@ -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", diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index 03fb6a68bf2f2..4812a0ecba919 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -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: @@ -65,6 +64,5 @@ def np_array_datetime64_compat(arr, dtype="M8[ns]"): __all__ = [ "np", "_np_version", - "np_version_under1p17", "is_numpy_dev", ] diff --git a/pandas/core/array_algos/masked_reductions.py b/pandas/core/array_algos/masked_reductions.py index 553cdc557ec95..01bb3d50c0da7 100644 --- a/pandas/core/array_algos/masked_reductions.py +++ b/pandas/core/array_algos/masked_reductions.py @@ -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 @@ -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( diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 11bb554a0dc5a..ee90dfa3e9a52 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -192,7 +192,6 @@ class TestPDApi(Base): "_hashtable", "_lib", "_libs", - "_np_version_under1p17", "_np_version_under1p18", "_is_numpy_dev", "_testing", diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index f6cd534491544..eb2ed2c25d27c 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -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 @@ -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): diff --git a/pandas/tests/extension/base/dim2.py b/pandas/tests/extension/base/dim2.py index f9d69e8413cc7..d826a3c30bcc7 100644 --- a/pandas/tests/extension/base/dim2.py +++ b/pandas/tests/extension/base/dim2.py @@ -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) @@ -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 @@ -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": @@ -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) diff --git a/pandas/tests/frame/methods/test_sample.py b/pandas/tests/frame/methods/test_sample.py index f11e13ca2574e..1d10d702aad2e 100644 --- a/pandas/tests/frame/methods/test_sample.py +++ b/pandas/tests/frame/methods/test_sample.py @@ -1,8 +1,6 @@ import numpy as np import pytest -from pandas.compat import np_version_under1p17 - from pandas import ( DataFrame, Series, @@ -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): diff --git a/pandas/tests/indexes/multi/test_analytics.py b/pandas/tests/indexes/multi/test_analytics.py index 83515d7fb82b1..fa9cdeafff4b4 100644 --- a/pandas/tests/indexes/multi/test_analytics.py +++ b/pandas/tests/indexes/multi/test_analytics.py @@ -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, @@ -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) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 59c30c3abac03..d4d2c002cd0df 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -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, @@ -81,18 +78,12 @@ 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 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 in [np.isfinite]: # ok under numpy >= 1.17 # Results in bool array result = func(index) diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 696395e50dd02..21d3d2f7d4800 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -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 @@ -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 = ( diff --git a/pyproject.toml b/pyproject.toml index 9f11475234566..3ffda4e2149c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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. diff --git a/requirements-dev.txt b/requirements-dev.txt index 094456eb85c9a..b98f5ee26ec57 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.16.5 +numpy>=1.17.3 python-dateutil>=2.7.3 pytz asv diff --git a/setup.cfg b/setup.cfg index 2aaafa0391531..9e3deff4c7183 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 From 1440bf32b725de5ae5afe9ecb64f98dabdd51f19 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 11:58:45 -0500 Subject: [PATCH 02/10] fix xfail --- pandas/tests/indexes/test_numpy_compat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index d4d2c002cd0df..8be32188c0b6f 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -78,6 +78,11 @@ 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]: + 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) From 2814bcb8b234613e929a19d4459085aa107f6dc3 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 12:01:28 -0500 Subject: [PATCH 03/10] fix xfail --- pandas/tests/indexes/test_numpy_compat.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 8be32188c0b6f..e64f595e4c246 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -78,17 +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]: - 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 func in [np.isfinite]: + elif func is np.isfinite: # ok under numpy >= 1.17 # Results in bool array result = func(index) From 8b72600f0cf46fb7422dbf30985b19b7652550aa Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 14:02:49 -0500 Subject: [PATCH 04/10] fix param --- pandas/tests/frame/methods/test_sample.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/methods/test_sample.py b/pandas/tests/frame/methods/test_sample.py index 1d10d702aad2e..a7bb1e4baba67 100644 --- a/pandas/tests/frame/methods/test_sample.py +++ b/pandas/tests/frame/methods/test_sample.py @@ -153,8 +153,14 @@ def test_sample_none_weights(self, obj): "func_str,arg", [ ("np.array", [2, 3, 1, 0]), - ("np.random.MT19937", 3), - ("np.random.PCG64", 11), + pytest.param( + "np.random.MT19937", + 3, + ), + pytest.param( + "np.random.PCG64", + 11, + ), ], ) def test_sample_random_state(self, func_str, arg, frame_or_series): From 1ce25370186dc125ee798909b2c155dc86fc5b1f Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 16:51:04 -0500 Subject: [PATCH 05/10] debug rng related compat check --- pandas/core/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/common.py b/pandas/core/common.py index e0c00fc419bf1..4ea3ec42f64db 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -418,7 +418,7 @@ def random_state(state=None): if ( is_integer(state) or is_array_like(state) - or (not np_version_under1p18 and isinstance(state, np.random.BitGenerator)) + or isinstance(state, np.random.BitGenerator) ): return np.random.RandomState(state) elif isinstance(state, np.random.RandomState): From d9ccba1dbb94565db2128b71c7fe2cae1ccc21f9 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 16:52:33 -0500 Subject: [PATCH 06/10] debug rng related compat check --- pandas/core/common.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/common.py b/pandas/core/common.py index 4ea3ec42f64db..505a61b99625c 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -32,7 +32,6 @@ Scalar, T, ) -from pandas.compat import np_version_under1p18 from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike from pandas.core.dtypes.common import ( From 18bca22ffdf50005c8a804115f2e75a4c968f75f Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Fri, 9 Apr 2021 17:41:19 -0500 Subject: [PATCH 07/10] debug rng related compat check --- pandas/core/common.py | 3 ++- pandas/tests/frame/methods/test_sample.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandas/core/common.py b/pandas/core/common.py index 505a61b99625c..e0c00fc419bf1 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -32,6 +32,7 @@ Scalar, T, ) +from pandas.compat import np_version_under1p18 from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike from pandas.core.dtypes.common import ( @@ -417,7 +418,7 @@ def random_state(state=None): if ( is_integer(state) or is_array_like(state) - or isinstance(state, np.random.BitGenerator) + or (not np_version_under1p18 and isinstance(state, np.random.BitGenerator)) ): return np.random.RandomState(state) elif isinstance(state, np.random.RandomState): diff --git a/pandas/tests/frame/methods/test_sample.py b/pandas/tests/frame/methods/test_sample.py index a7bb1e4baba67..55ef665c55241 100644 --- a/pandas/tests/frame/methods/test_sample.py +++ b/pandas/tests/frame/methods/test_sample.py @@ -1,6 +1,8 @@ import numpy as np import pytest +from pandas.compat import np_version_under1p18 + from pandas import ( DataFrame, Series, @@ -156,10 +158,12 @@ def test_sample_none_weights(self, obj): pytest.param( "np.random.MT19937", 3, + marks=pytest.mark.skipif(np_version_under1p18, reason="NumPy<1.18"), ), pytest.param( "np.random.PCG64", 11, + marks=pytest.mark.skipif(np_version_under1p18, reason="NumPy<1.18"), ), ], ) From 94c9abe711613e75907cc562d30e1812e32b5822 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 10 Apr 2021 07:02:46 -0500 Subject: [PATCH 08/10] debug rng related compat check --- pandas/tests/test_common.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 21d3d2f7d4800..229399476773f 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -6,6 +6,8 @@ import numpy as np import pytest +from pandas.compat import np_version_under1p18 + import pandas as pd from pandas import Series import pandas._testing as tm @@ -70,14 +72,15 @@ def test_random_state(): # Check BitGenerators # GH32503 - 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() - ) + if not np_version_under1p18: + 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 = ( From b44c8a9c1ecb30c508e68ee04a4bbae55ede8db9 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 10 Apr 2021 08:10:03 -0500 Subject: [PATCH 09/10] debug rng related compat check --- pandas/tests/indexes/test_numpy_compat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index e64f595e4c246..86ef348d45523 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -82,6 +82,7 @@ def test_numpy_ufuncs_other(index, func, request): isinstance(index, DatetimeIndex) and index.tz is not None and func in [np.isfinite, np.isnan, np.isinf] + and not np_version_under1p18 ): mark = pytest.mark.xfail(reason="__array_ufunc__ is not defined") request.node.add_marker(mark) From b5a83fc2bd4a227dcc8c913acb4772ce2ae75275 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Sat, 10 Apr 2021 09:35:19 -0500 Subject: [PATCH 10/10] debug rng related compat check --- pandas/tests/indexes/test_numpy_compat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 86ef348d45523..f2ed96d0b65b8 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -82,7 +82,10 @@ def test_numpy_ufuncs_other(index, func, request): isinstance(index, DatetimeIndex) and index.tz is not None and func in [np.isfinite, np.isnan, np.isinf] - and not np_version_under1p18 + and ( + not np_version_under1p18 + or (np_version_under1p18 and func is np.isfinite) + ) ): mark = pytest.mark.xfail(reason="__array_ufunc__ is not defined") request.node.add_marker(mark)