Skip to content

Commit d089df3

Browse files
authored
Black (#3142)
* precommit hook * azure checks * readme * readme * azure checks * flake8 & isort settings * black as separate azure job * black --check * notes on managing merge conflicts * format with black * flake8 fixes * move comment back
1 parent f172c67 commit d089df3

File tree

138 files changed

+22296
-17964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+22296
-17964
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
- [ ] Closes #xxxx
44
- [ ] Tests added
5+
- [ ] Passes `black .` & `flake8`
56
- [ ] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://pre-commit.com/
2+
# https://github.com/python/black#version-control-integration
3+
repos:
4+
- repo: https://github.com/python/black
5+
rev: stable
6+
hooks:
7+
- id: black
8+
language_version: python3.7
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v2.2.3
11+
hooks:
12+
- id: flake8

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ xarray: N-D labeled arrays and datasets
1111
:target: https://pandas.pydata.org/speed/xarray/
1212
.. image:: https://img.shields.io/pypi/v/xarray.svg
1313
:target: https://pypi.python.org/pypi/xarray/
14+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
15+
:target: https://github.com/python/black
16+
1417

1518
**xarray** (formerly **xray**) is an open source project and Python package
1619
that makes working with labelled multi-dimensional arrays simple,

asv_bench/benchmarks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def decorator(func):
1212
func.param_names = names
1313
func.params = params
1414
return func
15+
1516
return decorator
1617

1718

@@ -28,6 +29,7 @@ def randn(shape, frac_nan=None, chunks=None, seed=0):
2829
x = rng.standard_normal(shape)
2930
else:
3031
import dask.array as da
32+
3133
rng = da.random.RandomState(seed)
3234
x = rng.standard_normal(shape, chunks=chunks)
3335

asv_bench/benchmarks/combine.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ def setup(self):
1313
data = np.random.randn(t_size, x_size, y_size)
1414

1515
self.dsA0 = xr.Dataset(
16-
{'A': xr.DataArray(data, coords={'T': t},
17-
dims=('T', 'X', 'Y'))})
16+
{"A": xr.DataArray(data, coords={"T": t}, dims=("T", "X", "Y"))}
17+
)
1818
self.dsA1 = xr.Dataset(
19-
{'A': xr.DataArray(data, coords={'T': t + t_size},
20-
dims=('T', 'X', 'Y'))})
19+
{"A": xr.DataArray(data, coords={"T": t + t_size}, dims=("T", "X", "Y"))}
20+
)
2121
self.dsB0 = xr.Dataset(
22-
{'B': xr.DataArray(data, coords={'T': t},
23-
dims=('T', 'X', 'Y'))})
22+
{"B": xr.DataArray(data, coords={"T": t}, dims=("T", "X", "Y"))}
23+
)
2424
self.dsB1 = xr.Dataset(
25-
{'B': xr.DataArray(data, coords={'T': t + t_size},
26-
dims=('T', 'X', 'Y'))})
25+
{"B": xr.DataArray(data, coords={"T": t + t_size}, dims=("T", "X", "Y"))}
26+
)
2727

2828
def time_combine_manual(self):
2929
datasets = [[self.dsA0, self.dsA1], [self.dsB0, self.dsB1]]
3030

31-
xr.combine_manual(datasets, concat_dim=[None, 't'])
31+
xr.combine_manual(datasets, concat_dim=[None, "t"])
3232

3333
def time_auto_combine(self):
3434
"""Also has to load and arrange t coordinate"""

asv_bench/benchmarks/dataarray_missing.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
def make_bench_data(shape, frac_nan, chunks):
1616
vals = randn(shape, frac_nan)
17-
coords = {'time': pd.date_range('2000-01-01', freq='D',
18-
periods=shape[0])}
19-
da = xr.DataArray(vals, dims=('time', 'x', 'y'), coords=coords)
17+
coords = {"time": pd.date_range("2000-01-01", freq="D", periods=shape[0])}
18+
da = xr.DataArray(vals, dims=("time", "x", "y"), coords=coords)
2019

2120
if chunks is not None:
2221
da = da.chunk(chunks)
@@ -28,44 +27,50 @@ def time_interpolate_na(shape, chunks, method, limit):
2827
if chunks is not None:
2928
requires_dask()
3029
da = make_bench_data(shape, 0.1, chunks=chunks)
31-
actual = da.interpolate_na(dim='time', method='linear', limit=limit)
30+
actual = da.interpolate_na(dim="time", method="linear", limit=limit)
3231

3332
if chunks is not None:
3433
actual = actual.compute()
3534

3635

37-
time_interpolate_na.param_names = ['shape', 'chunks', 'method', 'limit']
38-
time_interpolate_na.params = ([(3650, 200, 400), (100, 25, 25)],
39-
[None, {'x': 25, 'y': 25}],
40-
['linear', 'spline', 'quadratic', 'cubic'],
41-
[None, 3])
36+
time_interpolate_na.param_names = ["shape", "chunks", "method", "limit"]
37+
time_interpolate_na.params = (
38+
[(3650, 200, 400), (100, 25, 25)],
39+
[None, {"x": 25, "y": 25}],
40+
["linear", "spline", "quadratic", "cubic"],
41+
[None, 3],
42+
)
4243

4344

4445
def time_ffill(shape, chunks, limit):
4546

4647
da = make_bench_data(shape, 0.1, chunks=chunks)
47-
actual = da.ffill(dim='time', limit=limit)
48+
actual = da.ffill(dim="time", limit=limit)
4849

4950
if chunks is not None:
5051
actual = actual.compute()
5152

5253

53-
time_ffill.param_names = ['shape', 'chunks', 'limit']
54-
time_ffill.params = ([(3650, 200, 400), (100, 25, 25)],
55-
[None, {'x': 25, 'y': 25}],
56-
[None, 3])
54+
time_ffill.param_names = ["shape", "chunks", "limit"]
55+
time_ffill.params = (
56+
[(3650, 200, 400), (100, 25, 25)],
57+
[None, {"x": 25, "y": 25}],
58+
[None, 3],
59+
)
5760

5861

5962
def time_bfill(shape, chunks, limit):
6063

6164
da = make_bench_data(shape, 0.1, chunks=chunks)
62-
actual = da.bfill(dim='time', limit=limit)
65+
actual = da.bfill(dim="time", limit=limit)
6366

6467
if chunks is not None:
6568
actual = actual.compute()
6669

6770

68-
time_bfill.param_names = ['shape', 'chunks', 'limit']
69-
time_bfill.params = ([(3650, 200, 400), (100, 25, 25)],
70-
[None, {'x': 25, 'y': 25}],
71-
[None, 3])
71+
time_bfill.param_names = ["shape", "chunks", "limit"]
72+
time_bfill.params = (
73+
[(3650, 200, 400), (100, 25, 25)],
74+
[None, {"x": 25, "y": 25}],
75+
[None, 3],
76+
)

0 commit comments

Comments
 (0)