Skip to content

Commit 971b1f5

Browse files
TomNicholaskeewisdcherian
authored
Update minimum dependencies for 0.20 (#5917)
* 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]>
1 parent e3b689d commit 971b1f5

18 files changed

+59
-129
lines changed

ci/requirements/py37-bare-minimum.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ dependencies:
1010
- pytest-cov
1111
- pytest-env
1212
- pytest-xdist
13-
- numpy=1.17
14-
- pandas=1.0
13+
- numpy=1.18
14+
- pandas=1.1
1515
- typing_extensions=3.7

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,31 @@ dependencies:
1010
- python=3.7
1111
- boto3=1.13
1212
- bottleneck=1.3
13+
# cartopy 0.18 conflicts with pynio
1314
- cartopy=0.17
1415
- cdms2=3.1
1516
- cfgrib=0.9
16-
- cftime=1.1
17+
- cftime=1.2
1718
- coveralls
18-
- dask=2.24
19-
- distributed=2.24
19+
- dask=2.30
20+
- distributed=2.30
2021
- h5netcdf=0.8
2122
- h5py=2.10
23+
# hdf5 1.12 conflicts with h5py=2.10
2224
- hdf5=1.10
2325
- hypothesis
2426
- iris=2.4
25-
- lxml=4.5 # Optional dep of pydap
26-
- matplotlib-base=3.2
27+
- lxml=4.6 # Optional dep of pydap
28+
- matplotlib-base=3.3
2729
- nc-time-axis=1.2
2830
# netcdf follows a 1.major.minor[.patch] convention
2931
# (see https://github.com/Unidata/netcdf4-python/issues/1090)
3032
# bumping the netCDF4 version is currently blocked by #4491
3133
- netcdf4=1.5.3
32-
- numba=0.49
33-
- numpy=1.17
34-
- pandas=1.0
35-
- pint=0.15
34+
- numba=0.51
35+
- numpy=1.18
36+
- pandas=1.1
37+
- pint=0.16
3638
- pip
3739
- pseudonetcdf=3.1
3840
- pydap=3.2
@@ -42,13 +44,11 @@ dependencies:
4244
- pytest-env
4345
- pytest-xdist
4446
- rasterio=1.1
45-
- scipy=1.4
46-
- seaborn=0.10
47-
# don't need to pin setuptools, now that we don't depend on it
48-
- setuptools
49-
- sparse=0.8
50-
- toolz=0.10
47+
- scipy=1.5
48+
- seaborn=0.11
49+
- sparse=0.11
50+
- toolz=0.11
5151
- typing_extensions=3.7
52-
- zarr=2.4
52+
- zarr=2.5
5353
- pip:
5454
- numbagg==0.1

doc/whats-new.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,24 @@ Breaking changes
4949
~~~~~~~~~~~~~~~~
5050
- The minimum versions of some dependencies were changed:
5151

52-
============ ====== ====
53-
Package Old New
54-
============ ====== ====
55-
dask 2.15 2.24
56-
distributed 2.15 2.24
57-
============ ====== ====
52+
=============== ====== ====
53+
Package Old New
54+
=============== ====== ====
55+
cftime 1.1 1.2
56+
dask 2.15 2.30
57+
distributed 2.15 2.30
58+
lxml 4.5 4.6
59+
matplotlib-base 3.2 3.3
60+
numba 0.49 0.51
61+
numpy 1.17 1.18
62+
pandas 1.0 1.1
63+
pint 0.15 0.16
64+
scipy 1.4 1.5
65+
seaborn 0.10 0.11
66+
sparse 0.8 0.11
67+
toolz 0.10 0.11
68+
zarr 2.4 2.5
69+
=============== ====== ====
5870

5971
- The ``__repr__`` of a :py:class:`xarray.Dataset`'s ``coords`` and ``data_vars``
6072
ignore ``xarray.set_option(display_max_rows=...)`` and show the full output

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.htm
7676
include_package_data = True
7777
python_requires = >=3.7
7878
install_requires =
79-
numpy >= 1.17
80-
pandas >= 1.0
79+
numpy >= 1.18
80+
pandas >= 1.1
8181
importlib-metadata; python_version < '3.8'
8282
typing_extensions >= 3.7; python_version < '3.8'
8383

xarray/backends/zarr.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import warnings
3-
from distutils.version import LooseVersion
43

54
import numpy as np
65

@@ -353,10 +352,7 @@ def open_group(
353352
synchronizer=synchronizer,
354353
path=group,
355354
)
356-
if LooseVersion(zarr.__version__) >= "2.5.0":
357-
open_kwargs["storage_options"] = storage_options
358-
elif storage_options:
359-
raise ValueError("Storage options only compatible with zarr>=2.5.0")
355+
open_kwargs["storage_options"] = storage_options
360356

361357
if chunk_store:
362358
open_kwargs["chunk_store"] = chunk_store

xarray/coding/cftime_offsets.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
import re
4444
from datetime import timedelta
45-
from distutils.version import LooseVersion
4645
from functools import partial
4746
from typing import ClassVar, Optional
4847

@@ -243,14 +242,7 @@ def _shift_month(date, months, day_option="start"):
243242
day = _days_in_month(reference)
244243
else:
245244
raise ValueError(day_option)
246-
if LooseVersion(cftime.__version__) < LooseVersion("1.0.4"):
247-
# dayofwk=-1 is required to update the dayofwk and dayofyr attributes of
248-
# the returned date object in versions of cftime between 1.0.2 and
249-
# 1.0.3.4. It can be removed for versions of cftime greater than
250-
# 1.0.3.4.
251-
return date.replace(year=year, month=month, day=day, dayofwk=-1)
252-
else:
253-
return date.replace(year=year, month=month, day=day)
245+
return date.replace(year=year, month=month, day=day)
254246

255247

256248
def roll_qtrday(other, n, month, day_option, modby=3):

xarray/coding/cftimeindex.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ def _parse_iso8601_with_reso(date_type, timestr):
134134
# TODO: Consider adding support for sub-second resolution?
135135
replace[attr] = int(value)
136136
resolution = attr
137-
if LooseVersion(cftime.__version__) < LooseVersion("1.0.4"):
138-
# dayofwk=-1 is required to update the dayofwk and dayofyr attributes of
139-
# the returned date object in versions of cftime between 1.0.2 and
140-
# 1.0.3.4. It can be removed for versions of cftime greater than
141-
# 1.0.3.4.
142-
replace["dayofwk"] = -1
143137
return default.replace(**replace), resolution
144138

145139

xarray/coding/times.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import re
22
import warnings
33
from datetime import datetime, timedelta
4-
from distutils.version import LooseVersion
54
from functools import partial
65

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

270269

271270
def to_timedelta_unboxed(value, **kwargs):
272-
if LooseVersion(pd.__version__) < "0.25.0":
273-
result = pd.to_timedelta(value, **kwargs, box=False)
274-
else:
275-
result = pd.to_timedelta(value, **kwargs).to_numpy()
271+
result = pd.to_timedelta(value, **kwargs).to_numpy()
276272
assert result.dtype == "timedelta64[ns]"
277273
return result
278274

279275

280276
def to_datetime_unboxed(value, **kwargs):
281-
if LooseVersion(pd.__version__) < "0.25.0":
282-
result = pd.to_datetime(value, **kwargs, box=False)
283-
else:
284-
result = pd.to_datetime(value, **kwargs).to_numpy()
277+
result = pd.to_datetime(value, **kwargs).to_numpy()
285278
assert result.dtype == "datetime64[ns]"
286279
return result
287280

xarray/core/accessor_dt.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import warnings
2-
from distutils.version import LooseVersion
32

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

339-
if LooseVersion(pd.__version__) < "1.1.0":
340-
raise AttributeError("'isocalendar' not available in pandas < 1.1.0")
341-
342338
values = _get_date_field(self._obj.data, "isocalendar", np.int64)
343339

344340
obj_type = type(self._obj)
@@ -383,12 +379,7 @@ def weekofyear(self):
383379
FutureWarning,
384380
)
385381

386-
if LooseVersion(pd.__version__) < "1.1.0":
387-
weekofyear = Properties._tslib_field_accessor(
388-
"weekofyear", "The week ordinal of the year", np.int64
389-
).fget(self)
390-
else:
391-
weekofyear = self.isocalendar().week
382+
weekofyear = self.isocalendar().week
392383

393384
return weekofyear
394385

xarray/core/missing.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime as dt
22
import warnings
3-
from distutils.version import LooseVersion
43
from functools import partial
54
from numbers import Number
65
from typing import Any, Callable, Dict, Hashable, Sequence, Union
@@ -557,16 +556,8 @@ def _localize(var, indexes_coords):
557556
"""
558557
indexes = {}
559558
for dim, [x, new_x] in indexes_coords.items():
560-
if np.issubdtype(new_x.dtype, np.datetime64) and LooseVersion(
561-
np.__version__
562-
) < LooseVersion("1.18"):
563-
# np.nanmin/max changed behaviour for datetime types in numpy 1.18,
564-
# see https://github.com/pydata/xarray/pull/3924/files
565-
minval = np.min(new_x.values)
566-
maxval = np.max(new_x.values)
567-
else:
568-
minval = np.nanmin(new_x.values)
569-
maxval = np.nanmax(new_x.values)
559+
minval = np.nanmin(new_x.values)
560+
maxval = np.nanmax(new_x.values)
570561
index = x.to_index()
571562
imin = index.get_loc(minval, method="nearest")
572563
imax = index.get_loc(maxval, method="nearest")

xarray/tests/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ def LooseVersion(vstring):
6161

6262

6363
has_matplotlib, requires_matplotlib = _importorskip("matplotlib")
64-
has_matplotlib_3_3_0, requires_matplotlib_3_3_0 = _importorskip(
65-
"matplotlib", minversion="3.3.0"
66-
)
6764
has_scipy, requires_scipy = _importorskip("scipy")
6865
has_pydap, requires_pydap = _importorskip("pydap.client")
6966
has_netCDF4, requires_netCDF4 = _importorskip("netCDF4")
@@ -77,7 +74,6 @@ def LooseVersion(vstring):
7774
has_nc_time_axis, requires_nc_time_axis = _importorskip("nc_time_axis")
7875
has_rasterio, requires_rasterio = _importorskip("rasterio")
7976
has_zarr, requires_zarr = _importorskip("zarr")
80-
has_zarr_2_5_0, requires_zarr_2_5_0 = _importorskip("zarr", minversion="2.5.0")
8177
has_fsspec, requires_fsspec = _importorskip("fsspec")
8278
has_iris, requires_iris = _importorskip("iris")
8379
has_cfgrib, requires_cfgrib = _importorskip("cfgrib")
@@ -86,8 +82,7 @@ def LooseVersion(vstring):
8682
has_sparse, requires_sparse = _importorskip("sparse")
8783
has_cupy, requires_cupy = _importorskip("cupy")
8884
has_cartopy, requires_cartopy = _importorskip("cartopy")
89-
# Need Pint 0.15 for __dask_tokenize__ tests for Quantity wrapped Dask Arrays
90-
has_pint_0_15, requires_pint_0_15 = _importorskip("pint", minversion="0.15")
85+
has_pint, requires_pint = _importorskip("pint")
9186
has_numexpr, requires_numexpr = _importorskip("numexpr")
9287

9388
# some special cases

xarray/tests/test_accessor_dt.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def setup(self):
7171
)
7272
def test_field_access(self, field) -> None:
7373

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

101-
if LooseVersion(pd.__version__) < "1.1.0":
102-
with pytest.raises(
103-
AttributeError, match=r"'isocalendar' not available in pandas < 1.1.0"
104-
):
105-
self.data.time.dt.isocalendar()[field]
106-
return
107-
108101
# pandas isocalendar has dtypy UInt32Dtype, convert to Int64
109102
expected = pd.Int64Index(getattr(self.times.isocalendar(), pandas_field))
110103
expected = xr.DataArray(
@@ -185,13 +178,6 @@ def test_dask_field_access(self, field) -> None:
185178
def test_isocalendar_dask(self, field) -> None:
186179
import dask.array as da
187180

188-
if LooseVersion(pd.__version__) < "1.1.0":
189-
with pytest.raises(
190-
AttributeError, match=r"'isocalendar' not available in pandas < 1.1.0"
191-
):
192-
self.data.time.dt.isocalendar()[field]
193-
return
194-
195181
expected = getattr(self.times_data.dt.isocalendar(), field)
196182

197183
dask_times_arr = da.from_array(self.times_arr, chunks=(5, 5, 50))

xarray/tests/test_backends.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
requires_scipy,
7272
requires_scipy_or_netCDF4,
7373
requires_zarr,
74-
requires_zarr_2_5_0,
7574
)
7675
from .test_coding_times import (
7776
_ALL_CALENDARS,
@@ -2400,7 +2399,6 @@ def create_zarr_target(self):
24002399

24012400

24022401
@requires_fsspec
2403-
@requires_zarr_2_5_0
24042402
def test_zarr_storage_options():
24052403
pytest.importorskip("aiobotocore")
24062404
ds = create_test_data()

xarray/tests/test_dask.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
assert_frame_equal,
2525
assert_identical,
2626
raise_if_dask_computes,
27-
requires_pint_0_15,
27+
requires_pint,
2828
requires_scipy_or_netCDF4,
2929
)
3030
from .test_backends import create_tmp_file
@@ -297,7 +297,7 @@ def test_persist(self):
297297
self.assertLazyAndAllClose(u + 1, v)
298298
self.assertLazyAndAllClose(u + 1, v2)
299299

300-
@requires_pint_0_15(reason="Need __dask_tokenize__")
300+
@requires_pint
301301
def test_tokenize_duck_dask_array(self):
302302
import pint
303303

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

751-
@requires_pint_0_15(reason="Need __dask_tokenize__")
751+
@requires_pint
752752
def test_tokenize_duck_dask_array(self):
753753
import pint
754754

0 commit comments

Comments
 (0)