Skip to content
forked from pydata/xarray

Commit

Permalink
Update minimum dependencies for 0.20 (pydata#5917)
Browse files Browse the repository at this point in the history
* conda ci requirements

* update setup.cfg for 0.20

* update dependency list in whatsnew

* try removing setuptools

* Fix

* update

* Update ci/requirements/py37-min-all-deps.yml

* fix test

* add notes

* fix pint

* fix accessor

* One more fix

* one last fix?

Co-authored-by: keewis <[email protected]>
Co-authored-by: dcherian <[email protected]>
Co-authored-by: Deepak Cherian <[email protected]>
  • Loading branch information
4 people authored Nov 1, 2021
1 parent e3b689d commit 971b1f5
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 129 deletions.
4 changes: 2 additions & 2 deletions ci/requirements/py37-bare-minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:
- pytest-cov
- pytest-env
- pytest-xdist
- numpy=1.17
- pandas=1.0
- numpy=1.18
- pandas=1.1
- typing_extensions=3.7
32 changes: 16 additions & 16 deletions ci/requirements/py37-min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,31 @@ dependencies:
- python=3.7
- boto3=1.13
- bottleneck=1.3
# cartopy 0.18 conflicts with pynio
- cartopy=0.17
- cdms2=3.1
- cfgrib=0.9
- cftime=1.1
- cftime=1.2
- coveralls
- dask=2.24
- distributed=2.24
- dask=2.30
- distributed=2.30
- h5netcdf=0.8
- h5py=2.10
# hdf5 1.12 conflicts with h5py=2.10
- hdf5=1.10
- hypothesis
- iris=2.4
- lxml=4.5 # Optional dep of pydap
- matplotlib-base=3.2
- lxml=4.6 # Optional dep of pydap
- matplotlib-base=3.3
- nc-time-axis=1.2
# netcdf follows a 1.major.minor[.patch] convention
# (see https://github.com/Unidata/netcdf4-python/issues/1090)
# bumping the netCDF4 version is currently blocked by #4491
- netcdf4=1.5.3
- numba=0.49
- numpy=1.17
- pandas=1.0
- pint=0.15
- numba=0.51
- numpy=1.18
- pandas=1.1
- pint=0.16
- pip
- pseudonetcdf=3.1
- pydap=3.2
Expand All @@ -42,13 +44,11 @@ dependencies:
- pytest-env
- pytest-xdist
- rasterio=1.1
- scipy=1.4
- seaborn=0.10
# don't need to pin setuptools, now that we don't depend on it
- setuptools
- sparse=0.8
- toolz=0.10
- scipy=1.5
- seaborn=0.11
- sparse=0.11
- toolz=0.11
- typing_extensions=3.7
- zarr=2.4
- zarr=2.5
- pip:
- numbagg==0.1
24 changes: 18 additions & 6 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,24 @@ Breaking changes
~~~~~~~~~~~~~~~~
- The minimum versions of some dependencies were changed:

============ ====== ====
Package Old New
============ ====== ====
dask 2.15 2.24
distributed 2.15 2.24
============ ====== ====
=============== ====== ====
Package Old New
=============== ====== ====
cftime 1.1 1.2
dask 2.15 2.30
distributed 2.15 2.30
lxml 4.5 4.6
matplotlib-base 3.2 3.3
numba 0.49 0.51
numpy 1.17 1.18
pandas 1.0 1.1
pint 0.15 0.16
scipy 1.4 1.5
seaborn 0.10 0.11
sparse 0.8 0.11
toolz 0.10 0.11
zarr 2.4 2.5
=============== ====== ====

- The ``__repr__`` of a :py:class:`xarray.Dataset`'s ``coords`` and ``data_vars``
ignore ``xarray.set_option(display_max_rows=...)`` and show the full output
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.htm
include_package_data = True
python_requires = >=3.7
install_requires =
numpy >= 1.17
pandas >= 1.0
numpy >= 1.18
pandas >= 1.1
importlib-metadata; python_version < '3.8'
typing_extensions >= 3.7; python_version < '3.8'

Expand Down
6 changes: 1 addition & 5 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import warnings
from distutils.version import LooseVersion

import numpy as np

Expand Down Expand Up @@ -353,10 +352,7 @@ def open_group(
synchronizer=synchronizer,
path=group,
)
if LooseVersion(zarr.__version__) >= "2.5.0":
open_kwargs["storage_options"] = storage_options
elif storage_options:
raise ValueError("Storage options only compatible with zarr>=2.5.0")
open_kwargs["storage_options"] = storage_options

if chunk_store:
open_kwargs["chunk_store"] = chunk_store
Expand Down
10 changes: 1 addition & 9 deletions xarray/coding/cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import re
from datetime import timedelta
from distutils.version import LooseVersion
from functools import partial
from typing import ClassVar, Optional

Expand Down Expand Up @@ -243,14 +242,7 @@ def _shift_month(date, months, day_option="start"):
day = _days_in_month(reference)
else:
raise ValueError(day_option)
if LooseVersion(cftime.__version__) < LooseVersion("1.0.4"):
# dayofwk=-1 is required to update the dayofwk and dayofyr attributes of
# the returned date object in versions of cftime between 1.0.2 and
# 1.0.3.4. It can be removed for versions of cftime greater than
# 1.0.3.4.
return date.replace(year=year, month=month, day=day, dayofwk=-1)
else:
return date.replace(year=year, month=month, day=day)
return date.replace(year=year, month=month, day=day)


def roll_qtrday(other, n, month, day_option, modby=3):
Expand Down
6 changes: 0 additions & 6 deletions xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ def _parse_iso8601_with_reso(date_type, timestr):
# TODO: Consider adding support for sub-second resolution?
replace[attr] = int(value)
resolution = attr
if LooseVersion(cftime.__version__) < LooseVersion("1.0.4"):
# dayofwk=-1 is required to update the dayofwk and dayofyr attributes of
# the returned date object in versions of cftime between 1.0.2 and
# 1.0.3.4. It can be removed for versions of cftime greater than
# 1.0.3.4.
replace["dayofwk"] = -1
return default.replace(**replace), resolution


Expand Down
11 changes: 2 additions & 9 deletions xarray/coding/times.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import warnings
from datetime import datetime, timedelta
from distutils.version import LooseVersion
from functools import partial

import numpy as np
Expand Down Expand Up @@ -269,19 +268,13 @@ def decode_cf_datetime(num_dates, units, calendar=None, use_cftime=None):


def to_timedelta_unboxed(value, **kwargs):
if LooseVersion(pd.__version__) < "0.25.0":
result = pd.to_timedelta(value, **kwargs, box=False)
else:
result = pd.to_timedelta(value, **kwargs).to_numpy()
result = pd.to_timedelta(value, **kwargs).to_numpy()
assert result.dtype == "timedelta64[ns]"
return result


def to_datetime_unboxed(value, **kwargs):
if LooseVersion(pd.__version__) < "0.25.0":
result = pd.to_datetime(value, **kwargs, box=False)
else:
result = pd.to_datetime(value, **kwargs).to_numpy()
result = pd.to_datetime(value, **kwargs).to_numpy()
assert result.dtype == "datetime64[ns]"
return result

Expand Down
11 changes: 1 addition & 10 deletions xarray/core/accessor_dt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warnings
from distutils.version import LooseVersion

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -336,9 +335,6 @@ def isocalendar(self):
if not is_np_datetime_like(self._obj.data.dtype):
raise AttributeError("'CFTimeIndex' object has no attribute 'isocalendar'")

if LooseVersion(pd.__version__) < "1.1.0":
raise AttributeError("'isocalendar' not available in pandas < 1.1.0")

values = _get_date_field(self._obj.data, "isocalendar", np.int64)

obj_type = type(self._obj)
Expand Down Expand Up @@ -383,12 +379,7 @@ def weekofyear(self):
FutureWarning,
)

if LooseVersion(pd.__version__) < "1.1.0":
weekofyear = Properties._tslib_field_accessor(
"weekofyear", "The week ordinal of the year", np.int64
).fget(self)
else:
weekofyear = self.isocalendar().week
weekofyear = self.isocalendar().week

return weekofyear

Expand Down
13 changes: 2 additions & 11 deletions xarray/core/missing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime as dt
import warnings
from distutils.version import LooseVersion
from functools import partial
from numbers import Number
from typing import Any, Callable, Dict, Hashable, Sequence, Union
Expand Down Expand Up @@ -557,16 +556,8 @@ def _localize(var, indexes_coords):
"""
indexes = {}
for dim, [x, new_x] in indexes_coords.items():
if np.issubdtype(new_x.dtype, np.datetime64) and LooseVersion(
np.__version__
) < LooseVersion("1.18"):
# np.nanmin/max changed behaviour for datetime types in numpy 1.18,
# see https://github.com/pydata/xarray/pull/3924/files
minval = np.min(new_x.values)
maxval = np.max(new_x.values)
else:
minval = np.nanmin(new_x.values)
maxval = np.nanmax(new_x.values)
minval = np.nanmin(new_x.values)
maxval = np.nanmax(new_x.values)
index = x.to_index()
imin = index.get_loc(minval, method="nearest")
imax = index.get_loc(maxval, method="nearest")
Expand Down
7 changes: 1 addition & 6 deletions xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def LooseVersion(vstring):


has_matplotlib, requires_matplotlib = _importorskip("matplotlib")
has_matplotlib_3_3_0, requires_matplotlib_3_3_0 = _importorskip(
"matplotlib", minversion="3.3.0"
)
has_scipy, requires_scipy = _importorskip("scipy")
has_pydap, requires_pydap = _importorskip("pydap.client")
has_netCDF4, requires_netCDF4 = _importorskip("netCDF4")
Expand All @@ -77,7 +74,6 @@ def LooseVersion(vstring):
has_nc_time_axis, requires_nc_time_axis = _importorskip("nc_time_axis")
has_rasterio, requires_rasterio = _importorskip("rasterio")
has_zarr, requires_zarr = _importorskip("zarr")
has_zarr_2_5_0, requires_zarr_2_5_0 = _importorskip("zarr", minversion="2.5.0")
has_fsspec, requires_fsspec = _importorskip("fsspec")
has_iris, requires_iris = _importorskip("iris")
has_cfgrib, requires_cfgrib = _importorskip("cfgrib")
Expand All @@ -86,8 +82,7 @@ def LooseVersion(vstring):
has_sparse, requires_sparse = _importorskip("sparse")
has_cupy, requires_cupy = _importorskip("cupy")
has_cartopy, requires_cartopy = _importorskip("cartopy")
# Need Pint 0.15 for __dask_tokenize__ tests for Quantity wrapped Dask Arrays
has_pint_0_15, requires_pint_0_15 = _importorskip("pint", minversion="0.15")
has_pint, requires_pint = _importorskip("pint")
has_numexpr, requires_numexpr = _importorskip("numexpr")

# some special cases
Expand Down
16 changes: 1 addition & 15 deletions xarray/tests/test_accessor_dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def setup(self):
)
def test_field_access(self, field) -> None:

if LooseVersion(pd.__version__) >= "1.1.0" and field in ["week", "weekofyear"]:
if field in ["week", "weekofyear"]:
data = self.times.isocalendar()["week"]
else:
data = getattr(self.times, field)
Expand All @@ -98,13 +98,6 @@ def test_field_access(self, field) -> None:
)
def test_isocalendar(self, field, pandas_field) -> None:

if LooseVersion(pd.__version__) < "1.1.0":
with pytest.raises(
AttributeError, match=r"'isocalendar' not available in pandas < 1.1.0"
):
self.data.time.dt.isocalendar()[field]
return

# pandas isocalendar has dtypy UInt32Dtype, convert to Int64
expected = pd.Int64Index(getattr(self.times.isocalendar(), pandas_field))
expected = xr.DataArray(
Expand Down Expand Up @@ -185,13 +178,6 @@ def test_dask_field_access(self, field) -> None:
def test_isocalendar_dask(self, field) -> None:
import dask.array as da

if LooseVersion(pd.__version__) < "1.1.0":
with pytest.raises(
AttributeError, match=r"'isocalendar' not available in pandas < 1.1.0"
):
self.data.time.dt.isocalendar()[field]
return

expected = getattr(self.times_data.dt.isocalendar(), field)

dask_times_arr = da.from_array(self.times_arr, chunks=(5, 5, 50))
Expand Down
2 changes: 0 additions & 2 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
requires_scipy,
requires_scipy_or_netCDF4,
requires_zarr,
requires_zarr_2_5_0,
)
from .test_coding_times import (
_ALL_CALENDARS,
Expand Down Expand Up @@ -2400,7 +2399,6 @@ def create_zarr_target(self):


@requires_fsspec
@requires_zarr_2_5_0
def test_zarr_storage_options():
pytest.importorskip("aiobotocore")
ds = create_test_data()
Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
assert_frame_equal,
assert_identical,
raise_if_dask_computes,
requires_pint_0_15,
requires_pint,
requires_scipy_or_netCDF4,
)
from .test_backends import create_tmp_file
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_persist(self):
self.assertLazyAndAllClose(u + 1, v)
self.assertLazyAndAllClose(u + 1, v2)

@requires_pint_0_15(reason="Need __dask_tokenize__")
@requires_pint
def test_tokenize_duck_dask_array(self):
import pint

Expand Down Expand Up @@ -748,7 +748,7 @@ def test_from_dask_variable(self):
a = DataArray(self.lazy_array.variable, coords={"x": range(4)}, name="foo")
self.assertLazyAndIdentical(self.lazy_array, a)

@requires_pint_0_15(reason="Need __dask_tokenize__")
@requires_pint
def test_tokenize_duck_dask_array(self):
import pint

Expand Down
Loading

0 comments on commit 971b1f5

Please sign in to comment.