Skip to content

Commit

Permalink
General dependencies bump; repair CI (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Jan 23, 2024
1 parent fc0138c commit b883383
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
python-version: '3.8'
requirements: latest
- os: macos
python-version: '3.12'
python-version: '3.11'
requirements: latest
- os: windows
python-version: '3.8'
requirements: latest
- os: windows
python-version: '3.12'
python-version: '3.11'
requirements: latest
# Test on minimal requirements
- os: ubuntu
Expand Down
10 changes: 5 additions & 5 deletions ci/requirements-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: xarray-extras-minimal
channels:
- conda-forge
dependencies:
- dask=2021.4
- numba=0.52
- numpy=1.18
- dask=2022.6.0
- numba=0.56
- numpy=1.23
- pandas=1.5
- pytest
- pytest-cov
- scipy=1.5
- xarray=0.16
- scipy=1.9
- xarray=2022.6.0
29 changes: 20 additions & 9 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ What's New

v0.6.0 (Unreleased)
-------------------
- Added explicit CI tests for Python 3.10 and 3.11
(v0.5.0 already supports it, although not formally).
- Dropped support for Python 3.7
- Added support for recent versions of Pandas (tested up to 2.2)
- Increased minimum version of Pandas from 1.1 to 1.5
- Bumped minimum version of all dependencies:

========== ====== ========
Dependency v0.5.0 v0.6.0
========== ====== ========
python 3.7 3.8
dask 2021.4.0 2022.6.0
numba 0.52 0.56
numpy 1.18 1.23
pandas 1.1 1.5
scipy 1.5 1.9
xarray 0.16 2022.6.0
========== ====== ========

- Added support for Python 3.10 and 3.11
- Added support for recent versions of Pandas (tested up to 2.2) and xarray
- Added support for :cls:`pathlib.Path` in function arguments

.. _whats-new.0.5.0:
Expand All @@ -20,17 +31,17 @@ v0.5.0 (2021-12-01)
-------------------
- Bumped minimum version of all dependencies:

========== ====== ======
========== ====== ========
Dependency v0.4.2 v0.5.0
========== ====== ======
========== ====== ========
python 3.5 3.7
dask 0.19 2021.4
dask 0.19 2021.4.0
numba 0.34 0.52
numpy 1.13 1.18
pandas 0.21 1.1
scipy 1.0 1.5
xarray 0.10.1 0.16
========== ====== ======
========== ====== ========

- Added support for Python 3.8 and 3.9
- Removed ``xarray_extras.backports`` module
Expand Down
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.htm
include_package_data = True
python_requires = >=3.8
install_requires =
dask >= 2021.4
numba >= 0.52
numpy >= 1.18
dask >= 2022.6
numba >= 0.56
numpy >= 1.23
pandas >= 1.5
scipy >= 1.5
xarray >= 0.16
scipy >= 1.9
xarray >= 2022.6.0

setup_requires = setuptools_scm

Expand Down
16 changes: 11 additions & 5 deletions xarray_extras/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from collections.abc import Callable
from pathlib import Path
from typing import Any
from typing import TYPE_CHECKING, Any, cast

import xarray
from dask.base import tokenize
Expand All @@ -17,8 +17,14 @@

__all__ = ("to_csv",)

if TYPE_CHECKING:
# TODO remove TYPE_CHECKING (requires dask >=2023.9.1)
from dask.typing import DaskCollection, Key

def to_csv(x: xarray.DataArray, path: str | Path, *, nogil: bool = True, **kwargs: Any):

def to_csv(
x: xarray.DataArray, path: str | Path, *, nogil: bool = True, **kwargs: Any
) -> Any:
"""Print DataArray to CSV.
When x has numpy backend, this function is functionally equivalent to (but
Expand Down Expand Up @@ -110,7 +116,7 @@ def to_csv(x: xarray.DataArray, path: str | Path, *, nogil: bool = True, **kwarg
return None

# Merge chunks on all dimensions beyond the first
x = x.chunk((x.chunks[0],) + tuple((s,) for s in x.shape[1:]))
x = x.chunk((x.chunks[0], *((s,) for s in x.shape[1:]))) # type: ignore[arg-type]

# Manually define the dask graph
tok = tokenize(x.data, index, columns, compression, path, kwargs)
Expand All @@ -119,7 +125,7 @@ def to_csv(x: xarray.DataArray, path: str | Path, *, nogil: bool = True, **kwarg
name3 = "to_csv_write-" + tok
name4 = "to_csv-" + tok

dsk: dict[str | tuple, tuple] = {}
dsk: dict[Key, Any] = {}

assert x.chunks
assert x.chunks[0]
Expand Down Expand Up @@ -172,7 +178,7 @@ def to_csv(x: xarray.DataArray, path: str | Path, *, nogil: bool = True, **kwarg
# Rename final key
dsk[name4] = dsk.pop((name3, i))

hlg = HighLevelGraph.from_collections(name4, dsk, (x,))
hlg = HighLevelGraph.from_collections(name4, dsk, [cast("DaskCollection", x)])
return Delayed(name4, hlg)


Expand Down
4 changes: 2 additions & 2 deletions xarray_extras/cumulatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def cummean(x: T, dim: Hashable, skipna: bool | None = None) -> T:
n = xarray.DataArray(n, dims=[dim], coords={dim: x.coords[dim]})
else:
# heavier computation
n = (~x.isnull()).cumsum(dim, skipna=False)
n = (~x.isnull()).cumsum((dim,), skipna=False)

return x.cumsum(dim, skipna=skipna) / n
return x.cumsum((dim,), skipna=skipna) / n


def compound_sum(x: T, c: xarray.DataArray, xdim: Hashable, cdim: Hashable) -> T:
Expand Down
11 changes: 9 additions & 2 deletions xarray_extras/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
import dask.array as da
import numpy as np
import xarray
from xarray.core.pycompat import dask_array_type

from xarray_extras.kernels import interpolate as kernels

try:
from xarray.core.pycompat import array_type

dask_array_type = array_type("dask")
except ImportError: # xarray <2022.11.0
from xarray.core.pycompat import dask_array_type # type: ignore


__all__ = ("splrep", "splev")


Expand Down Expand Up @@ -113,7 +120,7 @@ def splrep(a: xarray.DataArray, dim: Hashable, k: int = 3) -> xarray.Dataset:


def splev(
x_new: xarray.DataArray, tck: xarray.Dataset, extrapolate: bool | str = True
x_new: object, tck: xarray.Dataset, extrapolate: bool | str = True
) -> xarray.DataArray:
"""Evaluate the B-spline generated with :func:`splrep`.
Expand Down
2 changes: 1 addition & 1 deletion xarray_extras/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def proper_unstack(array: T, dim: Hashable) -> T:
array.coords[dim] = mindex

# Invoke builtin unstack
array = array.unstack(dim)
array = array.unstack((dim,))

# Convert numpy arrays of Python objects to numpy arrays of C floats, ints,
# strings, etc.
Expand Down

0 comments on commit b883383

Please sign in to comment.