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>

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import cupy_xarray # noqa: F401
1212

1313
project = "cupy-xarray"
14-
copyright = "2023, cupy-xarray developers"
14+
copyright = "2020-2024, cupy-xarray developers"
1515
author = "cupy-xarray developers"
16-
release = "v0.1"
16+
release = "v0.1.4"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ CuPy-Xarray is a Python library that leverages [CuPy](https://cupy.dev/), a GPU
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
CuPy-Xarray can be installed using `pip` or `conda`:
2022

2123
From Conda Forge:
@@ -77,11 +79,12 @@ Large parts of this documentations comes from [SciPy 2023 Xarray on GPUs tutoria
7779
source/contributing
7880
7981
80-
**API Reference**:
82+
**Reference**:
8183
8284
.. toctree::
8385
:maxdepth: 1
84-
:caption: API Reference
86+
:caption: Reference
8587
8688
api
89+
changelog
8790
```

docs/source/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Running the test suite
132132
*cupy-xarray* uses the `pytest <https://docs.pytest.org/en/latest/contents.html>`_
133133
framework for testing. You can run the test suite using::
134134

135-
pytest cupy-xarray
135+
pytest --doctest-modules cupy_xarray
136136

137137
Contributing documentation
138138
==========================

pyproject.toml

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1-
[tool.black]
2-
line-length = 100
3-
target-version = ['py38']
1+
[build-system]
2+
requires = ["setuptools", "versioneer[toml]"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "cupy-xarray"
7+
description = "Interface for using cupy in xarray, providing convenience accessors."
8+
authors = [{name = "cupy-xarray developers"}]
9+
license = {text = "Apache License"}
10+
readme = "README.md"
11+
requires-python = ">=3.8"
12+
classifiers = [
13+
"Programming Language :: Python :: 3",
14+
"Operating System :: OS Independent",
15+
]
16+
dynamic = ["version"]
17+
dependencies = [
18+
"xarray>=2024.02.0",
19+
]
20+
21+
[project.optional-dependencies]
22+
test = [
23+
"dask",
24+
"pytest",
25+
]
26+
27+
[tool.ruff]
28+
line-length = 100 # E501 (line-too-long)
29+
exclude = [
30+
"docs",
31+
"versioneer.py",
32+
"cupy_xarray/_version.py",
33+
]
34+
35+
[tool.ruff.lint]
36+
select = [
37+
"B", # flake8-bugbear
38+
"C4", # flake8-comprehensions
39+
"C90", # mccabe
40+
"E", # pycodestyle
41+
"F", # pyflakes
42+
"I", # isort
43+
"SIM", # flake8-simplify
44+
"W", # pycodestyle warnings
45+
]
46+
47+
[tool.versioneer]
48+
VCS = "git"
49+
style = "pep440"
50+
versionfile_source = "cupy_xarray/_version.py"
51+
versionfile_build = "cupy_xarray/_version.py"
52+
tag_prefix = ""
53+
parentdir_prefix = ""

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements_test.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)