Skip to content

Commit 1482bbd

Browse files
andersy005dcherianpre-commit-ci[bot]
authored
Add pre-commit hooks (#15)
Co-authored-by: Deepak Cherian <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c1f9565 commit 1482bbd

17 files changed

+110
-42
lines changed

.github/workflows/pypi-release.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ jobs:
5656
name: releases
5757
path: dist
5858

59-
60-
6159
upload-to-pypi:
6260
needs: build-artifacts
6361
if: github.event_name == 'release'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ dmypy.json
137137
# Cython debug symbols
138138
cython_debug/
139139

140-
.vscode/
140+
.vscode/

.pre-commit-config.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ci:
2+
autoupdate_schedule: quarterly
3+
4+
exclude: |
5+
(?x)^(
6+
versioneer.py|
7+
cupy_xarray/_version.py
8+
)$
9+
10+
repos:
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v4.3.0
13+
hooks:
14+
- id: trailing-whitespace
15+
- id: end-of-file-fixer
16+
- id: check-docstring-first
17+
- id: check-json
18+
- id: check-yaml
19+
# - id: double-quote-string-fixer
20+
- id: debug-statements
21+
- id: mixed-line-ending
22+
23+
- repo: https://github.com/asottile/pyupgrade
24+
rev: v2.37.3
25+
hooks:
26+
- id: pyupgrade
27+
args:
28+
- '--py38-plus'
29+
30+
- repo: https://github.com/psf/black
31+
rev: 22.6.0
32+
hooks:
33+
- id: black
34+
- id: black-jupyter
35+
36+
- repo: https://github.com/keewis/blackdoc
37+
rev: v0.3.5
38+
hooks:
39+
- id: blackdoc
40+
41+
- repo: https://github.com/PyCQA/flake8
42+
rev: 5.0.4
43+
hooks:
44+
- id: flake8
45+
46+
- repo: https://github.com/PyCQA/isort
47+
rev: 5.10.1
48+
hooks:
49+
- id: isort
50+
51+
- repo: https://github.com/pre-commit/mirrors-prettier
52+
rev: v2.7.1
53+
hooks:
54+
- id: prettier

.prettierrc.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tabWidth = 2
2+
semi = false
3+
singleQuote = true

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sphinx:
1212

1313
# Optionally set the version of Python and requirements required to build your docs
1414
conda:
15-
environment: ci/doc.yml
15+
environment: ci/doc.yml
1616

1717
python:
1818
install:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
Interface for using cupy in xarray, providing convenience accessors.
66

7-
87
## Installation
98

109
```console

cupy_xarray/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
from ._version import get_versions
2-
3-
__version__ = get_versions()["version"]
4-
del get_versions
5-
1+
from . import _version
62
from .accessors import CupyDataArrayAccessor, CupyDatasetAccessor # noqa
73

8-
from . import _version
9-
__version__ = _version.get_versions()['version']
4+
__version__ = _version.get_versions()["version"]

cupy_xarray/accessors.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import cupy as cp
2-
32
from xarray import (
43
DataArray,
54
Dataset,
@@ -119,11 +118,11 @@ def as_cupy(self):
119118

120119
def as_numpy(self):
121120
if self.is_cupy:
122-
data_vars = {
123-
var: da.cupy.as_numpy() for var, da in self.ds.data_vars.items()
124-
}
121+
data_vars = {var: da.cupy.as_numpy() for var, da in self.ds.data_vars.items()}
125122
return Dataset(
126-
data_vars=data_vars, coords=self.ds.coords, attrs=self.ds.attrs,
123+
data_vars=data_vars,
124+
coords=self.ds.coords,
125+
attrs=self.ds.attrs,
127126
)
128127
else:
129128
return self.ds.as_numpy()

cupy_xarray/tests/test_accessors.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import numpy as np
12
import pytest
2-
33
import xarray as xr
44
from xarray.core.pycompat import dask_array_type
5-
import cupy as cp
6-
import numpy as np
7-
import cupy_xarray
5+
6+
import cupy_xarray # noqa: F401
87

98

109
@pytest.fixture
@@ -19,9 +18,7 @@ def tutorial_da_air(tutorial_ds_air):
1918

2019
@pytest.fixture
2120
def tutorial_ds_air_dask():
22-
return xr.tutorial.open_dataset(
23-
"air_temperature", chunks={"lat": 25, "lon": 25, "time": -1}
24-
)
21+
return xr.tutorial.open_dataset("air_temperature", chunks={"lat": 25, "lon": 25, "time": -1})
2522

2623

2724
@pytest.fixture

docs/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# import cupy_xarray
1010
import sphinx_autosummary_accessors
1111

12-
project = 'cupy-xarray'
13-
copyright = '2022, cupy-xarray developers'
14-
author = 'cupy-xarray developers'
15-
release = 'v0.1'
12+
project = "cupy-xarray"
13+
copyright = "2022, cupy-xarray developers"
14+
author = "cupy-xarray developers"
15+
release = "v0.1"
1616

1717
# -- General configuration ---------------------------------------------------
1818
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -38,13 +38,13 @@
3838
}
3939

4040
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
41-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'api.rst']
41+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "api.rst"]
4242

4343
# -- Options for HTML output -------------------------------------------------
4444
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
4545

46-
html_theme = 'furo'
47-
html_static_path = ['_static']
46+
html_theme = "furo"
47+
html_static_path = ["_static"]
4848

4949

5050
# Myst_nb options

0 commit comments

Comments
 (0)