From cd8532ce9e56b8a1ecb5f6485b271691c8abb759 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 11:29:58 -0600 Subject: [PATCH 1/7] Bump dependencies incl `pandas>=2` --- ci/requirements/bare-minimum.yml | 4 ++-- ci/requirements/min-all-deps.yml | 20 ++++++++++---------- doc/whats-new.rst | 16 ++++++++++++++++ pyproject.toml | 4 ++-- xarray/tests/__init__.py | 5 ----- xarray/tests/test_dataset.py | 2 -- xarray/tests/test_groupby.py | 7 ++----- xarray/tests/test_variable.py | 10 ++-------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ci/requirements/bare-minimum.yml b/ci/requirements/bare-minimum.yml index 56af319f0bb..105e90ce109 100644 --- a/ci/requirements/bare-minimum.yml +++ b/ci/requirements/bare-minimum.yml @@ -12,5 +12,5 @@ dependencies: - pytest-xdist - pytest-timeout - numpy=1.23 - - packaging=22.0 - - pandas=1.5 + - packaging=23.1 + - pandas=2.0 diff --git a/ci/requirements/min-all-deps.yml b/ci/requirements/min-all-deps.yml index d2965fb3fc5..1e4f2fd27f5 100644 --- a/ci/requirements/min-all-deps.yml +++ b/ci/requirements/min-all-deps.yml @@ -9,13 +9,13 @@ dependencies: # doc/user-guide/installing.rst, doc/user-guide/plotting.rst and setup.py. - python=3.9 - array-api-strict=1.0 # dependency for testing the array api compat - - boto3=1.24 + - boto3=1.26 - bottleneck=1.3 - cartopy=0.21 - cftime=1.6 - coveralls - - dask-core=2022.12 - - distributed=2022.12 + - dask-core=2023.4 + - distributed=2023.4 # Flox > 0.8 has a bug with numbagg versions # It will require numbagg > 0.6 # so we should just skip that series eventually @@ -30,7 +30,7 @@ dependencies: - hypothesis - iris=3.4 - lxml=4.9 # Optional dep of pydap - - matplotlib-base=3.6 + - matplotlib-base=3.7 - nc-time-axis=1.4 # netcdf follows a 1.major.minor[.patch] convention # (see https://github.com/Unidata/netcdf4-python/issues/1090) @@ -38,11 +38,11 @@ dependencies: - numba=0.56 - numbagg=0.2.1 - numpy=1.23 - - packaging=22.0 - - pandas=1.5 + - packaging=23.1 + - pandas=2.0 - pint=0.22 - pip - - pydap=3.3 + - pydap=3.4 - pytest - pytest-cov - pytest-env @@ -51,7 +51,7 @@ dependencies: - rasterio=1.3 - scipy=1.10 - seaborn=0.12 - - sparse=0.13 + - sparse=0.14 - toolz=0.12 - - typing_extensions=4.4 - - zarr=2.13 + - typing_extensions=4.5 + - zarr=2.14 diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 2332f7f236b..f50ff1c3896 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -33,6 +33,22 @@ New Features Breaking changes ~~~~~~~~~~~~~~~~ +- The minimum versions of some dependencies were changed, in particular our minimum supported pandas version is now Pandas 2. + + ===================== ========= ======== + Package Old New + ===================== ========= ======== + dask-core 2022.12 2023.4 + distributed 2022.12 2023.4 + matplotlib-base 3.6 3.7 + packaging 22.0 23.1 + pandas 1.5 2.0 + pydap 3.3 3.4 + sparse 0.13 0.14 + typing_extensions 4.4 4.5 + zarr 2.14 2.14 + ===================== ========= ======== + Bug fixes ~~~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index 0fc26e5b82e..dc1b9d65de6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,8 +24,8 @@ requires-python = ">=3.9" dependencies = [ "numpy>=1.23", - "packaging>=22", - "pandas>=1.5", + "packaging>=23.1", + "pandas>=2.0", ] [project.optional-dependencies] diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py index 3ce788dfb7f..08894abfcb7 100644 --- a/xarray/tests/__init__.py +++ b/xarray/tests/__init__.py @@ -142,11 +142,6 @@ def _importorskip( requires_numbagg_or_bottleneck = pytest.mark.skipif( not has_scipy_or_netCDF4, reason="requires scipy or netCDF4" ) -# _importorskip does not work for development versions -has_pandas_version_two = Version(pd.__version__).major >= 2 -requires_pandas_version_two = pytest.mark.skipif( - not has_pandas_version_two, reason="requires pandas 2.0.0" -) has_numpy_array_api, requires_numpy_array_api = _importorskip("numpy", "1.26.0") has_h5netcdf_ros3, requires_h5netcdf_ros3 = _importorskip("h5netcdf", "1.3.0") diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index a948fafc815..e853031a1da 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -61,7 +61,6 @@ requires_cupy, requires_dask, requires_numexpr, - requires_pandas_version_two, requires_pint, requires_scipy, requires_sparse, @@ -3431,7 +3430,6 @@ def test_expand_dims_kwargs_python36plus(self) -> None: ) assert_identical(other_way_expected, other_way) - @requires_pandas_version_two def test_expand_dims_non_nanosecond_conversion(self) -> None: # Regression test for https://github.com/pydata/xarray/issues/7493#issuecomment-1953091000 with pytest.warns(UserWarning, match="non-nanosecond precision"): diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py index afe4d669628..e9e4eb1364c 100644 --- a/xarray/tests/test_groupby.py +++ b/xarray/tests/test_groupby.py @@ -22,7 +22,6 @@ create_test_data, has_cftime, has_flox, - has_pandas_version_two, requires_dask, requires_flox, requires_scipy, @@ -93,7 +92,7 @@ def test_groupby_sizes_property(dataset) -> None: assert dataset.groupby("x").sizes == dataset.isel(x=1).sizes with pytest.warns(UserWarning, match="The `squeeze` kwarg"): assert dataset.groupby("y").sizes == dataset.isel(y=1).sizes - dataset = dataset.drop("cat") + dataset = dataset.drop_vars("cat") stacked = dataset.stack({"xy": ("x", "y")}) with pytest.warns(UserWarning, match="The `squeeze` kwarg"): assert stacked.groupby("xy").sizes == stacked.isel(xy=0).sizes @@ -2172,7 +2171,6 @@ def test_upsample_interpolate_dask(self, chunked_time: bool) -> None: # done here due to floating point arithmetic assert_allclose(expected, actual, rtol=1e-16) - @pytest.mark.skipif(has_pandas_version_two, reason="requires pandas < 2.0.0") def test_resample_base(self) -> None: times = pd.date_range("2000-01-01T02:03:01", freq="6h", periods=10) array = DataArray(np.arange(10), [("time", times)]) @@ -2204,11 +2202,10 @@ def test_resample_origin(self) -> None: expected = DataArray(array.to_series().resample("24h", origin=origin).mean()) assert_identical(expected, actual) - @pytest.mark.skipif(has_pandas_version_two, reason="requires pandas < 2.0.0") @pytest.mark.parametrize( "loffset", [ - "-12H", + "-12h", datetime.timedelta(hours=-12), pd.Timedelta(hours=-12), pd.DateOffset(hours=-12), diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index 8a9345e74d4..2d4868e446e 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -36,12 +36,10 @@ assert_equal, assert_identical, assert_no_warnings, - has_pandas_version_two, raise_if_dask_computes, requires_bottleneck, requires_cupy, requires_dask, - requires_pandas_version_two, requires_pint, requires_sparse, source_ndarray, @@ -2645,7 +2643,6 @@ def test_datetime(self): assert np.ndarray == type(actual) assert np.dtype("datetime64[ns]") == actual.dtype - @requires_pandas_version_two def test_tz_datetime(self) -> None: tz = pytz.timezone("America/New_York") times_ns = pd.date_range("2000", periods=1, tz=tz) @@ -2959,7 +2956,7 @@ def test_from_pint_wrapping_dask(self, Var): ) def test_datetime_conversion_warning(values, warns_under_pandas_version_two) -> None: dims = ["time"] if isinstance(values, (np.ndarray, pd.Index, pd.Series)) else [] - if warns_under_pandas_version_two and has_pandas_version_two: + if warns_under_pandas_version_two: with pytest.warns(UserWarning, match="non-nanosecond precision datetime"): var = Variable(dims, values) else: @@ -2979,7 +2976,6 @@ def test_datetime_conversion_warning(values, warns_under_pandas_version_two) -> ) -@requires_pandas_version_two def test_pandas_two_only_datetime_conversion_warnings() -> None: # Note these tests rely on pandas features that are only present in pandas # 2.0.0 and above, and so for now cannot be parametrized. @@ -3028,7 +3024,7 @@ def test_pandas_two_only_datetime_conversion_warnings() -> None: ) def test_timedelta_conversion_warning(values, warns_under_pandas_version_two) -> None: dims = ["time"] if isinstance(values, (np.ndarray, pd.Index)) else [] - if warns_under_pandas_version_two and has_pandas_version_two: + if warns_under_pandas_version_two: with pytest.warns(UserWarning, match="non-nanosecond precision timedelta"): var = Variable(dims, values) else: @@ -3039,7 +3035,6 @@ def test_timedelta_conversion_warning(values, warns_under_pandas_version_two) -> assert var.dtype == np.dtype("timedelta64[ns]") -@requires_pandas_version_two def test_pandas_two_only_timedelta_conversion_warning() -> None: # Note this test relies on a pandas feature that is only present in pandas # 2.0.0 and above, and so for now cannot be parametrized. @@ -3050,7 +3045,6 @@ def test_pandas_two_only_timedelta_conversion_warning() -> None: assert var.dtype == np.dtype("timedelta64[ns]") -@requires_pandas_version_two @pytest.mark.parametrize( ("index", "dtype"), [ From 446658c070e1736a3e2abfb61e8f3755d87cff1c Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 12:24:04 -0600 Subject: [PATCH 2/7] fix whats-new --- doc/whats-new.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f50ff1c3896..f7140e07b4c 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -35,11 +35,11 @@ Breaking changes - The minimum versions of some dependencies were changed, in particular our minimum supported pandas version is now Pandas 2. - ===================== ========= ======== + ===================== ========= ======= Package Old New - ===================== ========= ======== - dask-core 2022.12 2023.4 - distributed 2022.12 2023.4 + ===================== ========= ======= + dask-core 2022.12 2023.4 + distributed 2022.12 2023.4 matplotlib-base 3.6 3.7 packaging 22.0 23.1 pandas 1.5 2.0 From 8748da2fc05fb0c6bc0bdfa1a9c900bbf00478a1 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 13:21:11 -0600 Subject: [PATCH 3/7] fix whats-new again --- doc/whats-new.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index f7140e07b4c..867af349bf1 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -46,8 +46,8 @@ Breaking changes pydap 3.3 3.4 sparse 0.13 0.14 typing_extensions 4.4 4.5 - zarr 2.14 2.14 - ===================== ========= ======== + zarr 2.13 2.14 + ===================== ========= ======= Bug fixes From 10ea5aee943909eeae89b803a2f41ff6078d16c2 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 13:21:59 -0600 Subject: [PATCH 4/7] clean up test --- xarray/tests/test_variable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index 2d4868e446e..c7d0fbb886a 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -2935,7 +2935,7 @@ def test_from_pint_wrapping_dask(self, Var): @pytest.mark.parametrize( - ("values", "warns_under_pandas_version_two"), + ("values", "warns"), [ (np.datetime64("2000-01-01", "ns"), False), (np.datetime64("2000-01-01", "s"), True), @@ -2954,9 +2954,9 @@ def test_from_pint_wrapping_dask(self, Var): ], ids=lambda x: f"{x}", ) -def test_datetime_conversion_warning(values, warns_under_pandas_version_two) -> None: +def test_datetime_conversion_warning(values, warns) -> None: dims = ["time"] if isinstance(values, (np.ndarray, pd.Index, pd.Series)) else [] - if warns_under_pandas_version_two: + if warns: with pytest.warns(UserWarning, match="non-nanosecond precision datetime"): var = Variable(dims, values) else: From 1f97e7b91597839a8ca4fbad93becab6a921920d Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 13:24:21 -0600 Subject: [PATCH 5/7] bump h5py and hdf5 --- ci/requirements/min-all-deps.yml | 4 ++-- doc/whats-new.rst | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/requirements/min-all-deps.yml b/ci/requirements/min-all-deps.yml index 1e4f2fd27f5..59cd38cf20a 100644 --- a/ci/requirements/min-all-deps.yml +++ b/ci/requirements/min-all-deps.yml @@ -25,8 +25,8 @@ dependencies: # h5py and hdf5 tend to cause conflicts # for e.g. hdf5 1.12 conflicts with h5py=3.1 # prioritize bumping other packages instead - - h5py=3.7 - - hdf5=1.12 + - h5py=3.8 + - hdf5=1.14 - hypothesis - iris=3.4 - lxml=4.9 # Optional dep of pydap diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 867af349bf1..37383be1773 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -40,6 +40,8 @@ Breaking changes ===================== ========= ======= dask-core 2022.12 2023.4 distributed 2022.12 2023.4 + h5py 3.7 3.8 + hdf5 1.12 1.14 matplotlib-base 3.6 3.7 packaging 22.0 23.1 pandas 1.5 2.0 From 14c737b81f5d2eef1a0d60aca00f63b77f8acc24 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 24 Apr 2024 13:29:35 -0600 Subject: [PATCH 6/7] Skip hdf5 --- ci/requirements/min-all-deps.yml | 2 +- doc/whats-new.rst | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/requirements/min-all-deps.yml b/ci/requirements/min-all-deps.yml index 59cd38cf20a..64f4327bbcb 100644 --- a/ci/requirements/min-all-deps.yml +++ b/ci/requirements/min-all-deps.yml @@ -26,7 +26,7 @@ dependencies: # for e.g. hdf5 1.12 conflicts with h5py=3.1 # prioritize bumping other packages instead - h5py=3.8 - - hdf5=1.14 + - hdf5=1.12 - hypothesis - iris=3.4 - lxml=4.9 # Optional dep of pydap diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 37383be1773..257b4af8476 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -41,7 +41,6 @@ Breaking changes dask-core 2022.12 2023.4 distributed 2022.12 2023.4 h5py 3.7 3.8 - hdf5 1.12 1.14 matplotlib-base 3.6 3.7 packaging 22.0 23.1 pandas 1.5 2.0 From 14c8379d86d5c6eb63a7e57bc6a226fefb8a15b0 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Thu, 25 Apr 2024 09:03:21 -0600 Subject: [PATCH 7/7] one more cleanup --- xarray/tests/test_variable.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index c7d0fbb886a..3167de2e2f0 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -3010,7 +3010,7 @@ def test_pandas_two_only_datetime_conversion_warnings() -> None: @pytest.mark.parametrize( - ("values", "warns_under_pandas_version_two"), + ("values", "warns"), [ (np.timedelta64(10, "ns"), False), (np.timedelta64(10, "s"), True), @@ -3022,9 +3022,9 @@ def test_pandas_two_only_datetime_conversion_warnings() -> None: ], ids=lambda x: f"{x}", ) -def test_timedelta_conversion_warning(values, warns_under_pandas_version_two) -> None: +def test_timedelta_conversion_warning(values, warns) -> None: dims = ["time"] if isinstance(values, (np.ndarray, pd.Index)) else [] - if warns_under_pandas_version_two: + if warns: with pytest.warns(UserWarning, match="non-nanosecond precision timedelta"): var = Variable(dims, values) else: