Skip to content

Commit d684dad

Browse files
committed
Merge branch 'main' into kvikio-entrypoint
2 parents 95efa18 + 3f84de0 commit d684dad

18 files changed

+214
-90
lines changed

.github/workflows/pypi-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: |
4646
python -m twine check dist/*
4747
pwd
48-
if [ -f dist/cupy-xarray-0.0.0.tar.gz ]; then
48+
if [ -f dist/cupy_xarray-0.0.0.tar.gz ]; then
4949
echo "❌ INVALID VERSION NUMBER"
5050
exit 1
5151
else
@@ -61,7 +61,7 @@ jobs:
6161
if: github.event_name == 'release'
6262
runs-on: ubuntu-latest
6363
steps:
64-
- uses: actions/download-artifact@v3
64+
- uses: actions/download-artifact@v4.1.7
6565
with:
6666
name: releases
6767
path: dist

.pre-commit-config.yaml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exclude: |
99
1010
repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.5.0
12+
rev: v5.0.0
1313
hooks:
1414
- id: trailing-whitespace
1515
- id: end-of-file-fixer
@@ -21,32 +21,25 @@ repos:
2121
- id: mixed-line-ending
2222

2323
- repo: https://github.com/asottile/pyupgrade
24-
rev: v3.15.2
24+
rev: v3.17.0
2525
hooks:
2626
- id: pyupgrade
2727
args:
2828
- "--py38-plus"
2929

30-
- repo: https://github.com/psf/black
31-
rev: 24.3.0
32-
hooks:
33-
- id: black
34-
- id: black-jupyter
35-
3630
- repo: https://github.com/keewis/blackdoc
3731
rev: v0.3.9
3832
hooks:
3933
- id: blackdoc
4034

41-
- repo: https://github.com/PyCQA/flake8
42-
rev: 7.0.0
43-
hooks:
44-
- id: flake8
45-
46-
- repo: https://github.com/PyCQA/isort
47-
rev: 5.13.2
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.6.9
4837
hooks:
49-
- id: isort
38+
- id: ruff
39+
types_or: [python, pyi, jupyter]
40+
args: [--fix]
41+
- id: ruff-format
42+
types_or: [python, pyi, jupyter]
5043

5144
- repo: https://github.com/pre-commit/mirrors-prettier
5245
rev: v4.0.0-alpha.8

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
version: 2
33

44
build:
5-
os: "ubuntu-20.04"
5+
os: "ubuntu-24.04"
66
tools:
7-
python: "mambaforge-4.10"
7+
python: "mambaforge-23.11"
88

99
# Optionally set the version of Python and requirements required to build your docs
1010
conda:

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
include versioneer.py
22
include cupy_xarray/_version.py
3-
include requirements.txt
43
include LICENSE
54
include README.md
65
include pyproject.toml
76
prune cupy_xarray/tests*
87

9-
108
recursive-exclude * __pycache__
119
recursive-exclude * *.py[co]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Interface for using cupy in xarray, providing convenience accessors.
1616

1717
## Installation
1818

19+
> `cupy-xarray` will use an existing cupy installation, hence cupy needs to be installed manually! Please follow cupy's install instructions at <https://docs.cupy.dev/en/stable/install.html>.
20+
1921
From anaconda:
2022

2123
```console

ci/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- ipython
1313
- ipykernel
1414
- ipywidgets
15-
- furo
15+
- furo>=2024.8.6
1616
- myst-nb
1717
- xarray
1818
- zarr

cupy_xarray/accessors.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
import cupy as cp
1+
import warnings
2+
from typing import TYPE_CHECKING, Any
3+
4+
try:
5+
import cupy as cp
6+
except ImportError as e:
7+
warnings.warn(
8+
"Cupy is not installed. cupy-xarray expects cupy to be manually installed. Please install "
9+
"cupy by following the instructions at https://docs.cupy.dev/en/stable/install.html.",
10+
ImportWarning,
11+
stacklevel=2,
12+
)
13+
raise e
214
from xarray import (
315
DataArray,
416
Dataset,
517
register_dataarray_accessor,
618
register_dataset_accessor,
719
)
8-
from xarray.namedarray.pycompat import DuckArrayModule
920

10-
dsk = DuckArrayModule("dask")
11-
dask_array_type = dsk.type
21+
if TYPE_CHECKING:
22+
DuckArrayTypes = tuple[type[Any], ...]
23+
dask_array_type: DuckArrayTypes
24+
25+
try:
26+
import dask.array
27+
28+
dask_array_type = (dask.array.Array,)
29+
except ImportError:
30+
dask_array_type = ()
1231

1332

1433
@register_dataarray_accessor("cupy")
@@ -55,7 +74,7 @@ def as_cupy(self):
5574
>>> da = xr.tutorial.load_dataset("air_temperature").air
5675
>>> gda = da.cupy.as_cupy()
5776
>>> type(gda.data)
58-
<class 'cupy.core.core.ndarray'>
77+
<class 'cupy.ndarray'>
5978
6079
"""
6180
if isinstance(self.da.data, dask_array_type):
@@ -127,7 +146,7 @@ def is_cupy(self):
127146
is_cupy: bool
128147
Whether the underlying data is a cupy array.
129148
"""
130-
return all([da.cupy.is_cupy for da in self.ds.data_vars.values()])
149+
return all(da.cupy.is_cupy for da in self.ds.data_vars.values())
131150

132151
def as_cupy(self):
133152
"""

cupy_xarray/tests/test_accessors.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import numpy as np
22
import pytest
33
import xarray as xr
4-
from xarray.core.pycompat import dask_array_type
54

65
import cupy_xarray # noqa: F401
76

7+
try:
8+
import dask.array
9+
10+
dask_array_type = dask.array.Array
11+
except ImportError:
12+
dask_array_type = None
13+
814

915
@pytest.fixture
1016
def tutorial_ds_air():

docs/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
API
2-
===
1+
API Reference
2+
=============
33

44
.. currentmodule:: xarray
55

docs/changelog.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Changelog
2+
3+
## Version 0.1.4 - 2024-07-27
4+
5+
This release brings several documentation improvements at
6+
<https://cupy-xarray.readthedocs.io> with a new User Guide, Tutorials and Presentations,
7+
Contributing Guide and API reference. It also fixes a `No module named
8+
'xarray.core.pycompat'` bug, and will require a minimum version of `xarray>=2024.02.0`.
9+
10+
### What's Changed
11+
12+
- Documentation Updates 📖 ([#35](https://github.com/xarray-contrib/cupy-xarray/pull/35))
13+
- Update accessors.py ([#42](https://github.com/xarray-contrib/cupy-xarray/pull/42))
14+
- Enable API reference docs to show accessor methods ([#44](https://github.com/xarray-contrib/cupy-xarray/pull/44))
15+
- Migrate flake8, isort, black rules to ruff ([#49](https://github.com/xarray-contrib/cupy-xarray/pull/49))
16+
- Fix broken doctest and tests on accessors ([#46](https://github.com/xarray-contrib/cupy-xarray/pull/46))
17+
- Migrate from setup.cfg to pyproject.toml ([#48](https://github.com/xarray-contrib/cupy-xarray/pull/48))
18+
19+
### Contributors
20+
21+
- [Wei Ji Leong](https://github.com/weiji14)
22+
- [Negin Sobhani](https://github.com/negin513)
23+
- [Sai Shashank](https://github.com/saishashank85)
24+
25+
**Full Changelog**: <https://github.com/xarray-contrib/cupy-xarray/compare/0.1.3...0.1.4>
26+
27+
---
28+
29+
## Version 0.1.3 - 2023-02-22
30+
31+
### What's Changed
32+
33+
- Set encoding for Windows ([#20](https://github.com/xarray-contrib/cupy-xarray/pull/20))
34+
- Fix broken dask_array_type import ([#24](https://github.com/xarray-contrib/cupy-xarray/pull/24))
35+
- Min xarray >= 0.19.0 ([#25](https://github.com/xarray-contrib/cupy-xarray/pull/25))
36+
- Expand installation doc ([#27](https://github.com/xarray-contrib/cupy-xarray/pull/27))
37+
38+
### Contributors
39+
40+
- [Deepak Cherian](https://github.com/dcherian)
41+
- [Aaron Zuspan](https://github.com/aazuspan)
42+
- [Aleksandr Kadykov](https://github.com/kadykov)
43+
44+
**Full Changelog**: <https://github.com/xarray-contrib/cupy-xarray/compare/0.1.2...0.1.3>
45+
46+
---
47+
48+
## Version 0.1.2 - 2022-08-25
49+
50+
### What's Changed
51+
52+
- Add badges ([#16](https://github.com/xarray-contrib/cupy-xarray/pull/16))
53+
- update PyPI workflow: double-check we're shipping everything we need ([#17](https://github.com/xarray-contrib/cupy-xarray/pull/17))
54+
- PyPI workflow: re-introduce upload job ([#18](https://github.com/xarray-contrib/cupy-xarray/pull/18))
55+
- Revert back to previous version of PyPI workflow ([#19](https://github.com/xarray-contrib/cupy-xarray/pull/19))
56+
57+
### Contributors
58+
59+
- [Deepak Cherian](https://github.com/dcherian)
60+
- [Anderson Banihirwe](https://github.com/andersy005)
61+
62+
**Full Changelog**: <https://github.com/xarray-contrib/cupy-xarray/compare/0.1.1...0.1.2>
63+
64+
---
65+
66+
## Version 0.1.1 - 2022-08-19
67+
68+
_First release!_
69+
70+
### What's Changed
71+
72+
- Add LICENSE ([#2](https://github.com/xarray-contrib/cupy-xarray/pull/2))
73+
- Update path of repo ([#3](https://github.com/xarray-contrib/cupy-xarray/pull/3))
74+
- Add docs ([#4](https://github.com/xarray-contrib/cupy-xarray/pull/4))
75+
- Update versioneer ([#12](https://github.com/xarray-contrib/cupy-xarray/pull/12))
76+
- Add PyPI release workflow ([#13](https://github.com/xarray-contrib/cupy-xarray/pull/13))
77+
- Fix CI job dependency ([#14](https://github.com/xarray-contrib/cupy-xarray/pull/14))
78+
79+
### Contributors
80+
81+
- [Jacob Tomlinson](https://github.com/jacobtomlinson)
82+
- [Ray Bell](https://github.com/raybellwaves)
83+
- [Deepak Cherian](https://github.com/dcherian)
84+
- [Anderson Banihirwe](https://github.com/andersy005)
85+
86+
**Full Changelog**: <https://github.com/xarray-contrib/cupy-xarray/compare/0.1.0...0.1.1>
87+
88+
---
89+
90+
## Version 0.1.0 - 2020-07-23
91+
92+
_Pre-release_
93+
94+
### Contributors
95+
96+
- [Jacob Tomlinson](https://github.com/jacobtomlinson)
97+
98+
**Full Changelog**: <https://github.com/xarray-contrib/cupy-xarray/compare/0.0.1...0.1.0>

0 commit comments

Comments
 (0)