Skip to content

Commit 0a1e7e4

Browse files
[pre-commit.ci] pre-commit autoupdate (pydata#6221)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 21.12b0 → 22.1.0](psf/black@21.12b0...22.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b09de81 commit 0a1e7e4

14 files changed

+26
-29
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- "--py37-plus"
2727
# https://github.com/python/black#version-control-integration
2828
- repo: https://github.com/psf/black
29-
rev: 21.12b0
29+
rev: 22.1.0
3030
hooks:
3131
- id: black
3232
- id: black-jupyter

xarray/backends/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500
6565
except catch:
6666
if n == max_retries:
6767
raise
68-
base_delay = initial_delay * 2 ** n
68+
base_delay = initial_delay * 2**n
6969
next_delay = base_delay + np.random.randint(base_delay)
7070
msg = (
7171
f"getitem failed, waiting {next_delay} ms before trying again "

xarray/coding/cftime_offsets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def __apply__(self, other):
671671

672672

673673
_FREQUENCY_CONDITION = "|".join(_FREQUENCIES.keys())
674-
_PATTERN = fr"^((?P<multiple>\d+)|())(?P<freq>({_FREQUENCY_CONDITION}))$"
674+
_PATTERN = rf"^((?P<multiple>\d+)|())(?P<freq>({_FREQUENCY_CONDITION}))$"
675675

676676

677677
# pandas defines these offsets as "Tick" objects, which for instance have

xarray/core/weighted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _sum_of_squares(
189189

190190
demeaned = da - da.weighted(self.weights).mean(dim=dim)
191191

192-
return self._reduce((demeaned ** 2), self.weights, dim=dim, skipna=skipna)
192+
return self._reduce((demeaned**2), self.weights, dim=dim, skipna=skipna)
193193

194194
def _weighted_sum(
195195
self,

xarray/tests/test_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ def test_encoding_chunksizes_unlimited(self):
14441444
"complevel": 0,
14451445
"fletcher32": False,
14461446
"contiguous": False,
1447-
"chunksizes": (2 ** 20,),
1447+
"chunksizes": (2**20,),
14481448
"original_shape": (3,),
14491449
}
14501450
with self.roundtrip(ds) as actual:

xarray/tests/test_computation.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,10 @@ def test_unified_dim_sizes() -> None:
475475
"x": 1,
476476
"y": 2,
477477
}
478-
assert (
479-
unified_dim_sizes(
480-
[xr.Variable(("x", "z"), [[1]]), xr.Variable(("y", "z"), [[1, 2], [3, 4]])],
481-
exclude_dims={"z"},
482-
)
483-
== {"x": 1, "y": 2}
484-
)
478+
assert unified_dim_sizes(
479+
[xr.Variable(("x", "z"), [[1]]), xr.Variable(("y", "z"), [[1, 2], [3, 4]])],
480+
exclude_dims={"z"},
481+
) == {"x": 1, "y": 2}
485482

486483
# duplicate dimensions
487484
with pytest.raises(ValueError):
@@ -1947,7 +1944,7 @@ def test_polyval(use_dask, use_datetime) -> None:
19471944
xcoord = xr.DataArray(x, dims=("x",), name="x")
19481945

19491946
da = xr.DataArray(
1950-
np.stack((1.0 + x + 2.0 * x ** 2, 1.0 + 2.0 * x + 3.0 * x ** 2)),
1947+
np.stack((1.0 + x + 2.0 * x**2, 1.0 + 2.0 * x + 3.0 * x**2)),
19511948
dims=("d", "x"),
19521949
coords={"x": xcoord, "d": [0, 1]},
19531950
)

xarray/tests/test_dataarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3727,7 +3727,7 @@ def test_polyfit(self, use_dask, use_datetime):
37273727

37283728
da_raw = DataArray(
37293729
np.stack(
3730-
(10 + 1e-15 * x + 2e-28 * x ** 2, 30 + 2e-14 * x + 1e-29 * x ** 2)
3730+
(10 + 1e-15 * x + 2e-28 * x**2, 30 + 2e-14 * x + 1e-29 * x**2)
37313731
),
37323732
dims=("d", "x"),
37333733
coords={"x": xcoord, "d": [0, 1]},

xarray/tests/test_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3644,7 +3644,7 @@ def test_assign(self):
36443644
assert list(actual.variables) == ["x", "y"]
36453645
assert_identical(ds, Dataset())
36463646

3647-
actual = actual.assign(y=lambda ds: ds.x ** 2)
3647+
actual = actual.assign(y=lambda ds: ds.x**2)
36483648
expected = Dataset({"y": ("x", [0, 1, 4]), "x": [0, 1, 2]})
36493649
assert_identical(actual, expected)
36503650

xarray/tests/test_interp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_example_data(case):
3030
data = xr.DataArray(
3131
np.sin(x[:, np.newaxis]) * np.cos(y),
3232
dims=["x", "y"],
33-
coords={"x": x, "y": y, "x2": ("x", x ** 2)},
33+
coords={"x": x, "y": y, "x2": ("x", x**2)},
3434
)
3535

3636
if case == 0:
@@ -46,7 +46,7 @@ def get_example_data(case):
4646
return xr.DataArray(
4747
np.sin(x[:, np.newaxis, np.newaxis]) * np.cos(y[:, np.newaxis]) * z,
4848
dims=["x", "y", "z"],
49-
coords={"x": x, "y": y, "x2": ("x", x ** 2), "z": z},
49+
coords={"x": x, "y": y, "x2": ("x", x**2), "z": z},
5050
)
5151
elif case == 4:
5252
return get_example_data(3).chunk({"z": 5})
@@ -440,7 +440,7 @@ def test_sorted():
440440
da = xr.DataArray(
441441
np.cos(x[:, np.newaxis, np.newaxis]) * np.cos(y[:, np.newaxis]) * z,
442442
dims=["x", "y", "z"],
443-
coords={"x": x, "y": y, "x2": ("x", x ** 2), "z": z},
443+
coords={"x": x, "y": y, "x2": ("x", x**2), "z": z},
444444
)
445445

446446
x_new = np.linspace(0, 1, 30)

xarray/tests/test_plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def test_geo_data(self):
550550
[-137.85, -120.99, -103.28, -85.28, -67.62],
551551
]
552552
)
553-
data = np.sqrt(lon ** 2 + lat ** 2)
553+
data = np.sqrt(lon**2 + lat**2)
554554
da = DataArray(
555555
data,
556556
dims=("y", "x"),
@@ -2886,8 +2886,8 @@ def test_plot_transposes_properly(plotfunc):
28862886
def test_facetgrid_single_contour():
28872887
# regression test for GH3569
28882888
x, y = np.meshgrid(np.arange(12), np.arange(12))
2889-
z = xr.DataArray(np.sqrt(x ** 2 + y ** 2))
2890-
z2 = xr.DataArray(np.sqrt(x ** 2 + y ** 2) + 1)
2889+
z = xr.DataArray(np.sqrt(x**2 + y**2))
2890+
z2 = xr.DataArray(np.sqrt(x**2 + y**2) + 1)
28912891
ds = xr.concat([z, z2], dim="time")
28922892
ds["time"] = [0, 1]
28932893

xarray/tests/test_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5459,7 +5459,7 @@ def test_grouped_operations(self, func, variant, dtype):
54595459
def test_content_manipulation(self, func, variant, dtype):
54605460
variants = {
54615461
"data": (
5462-
(unit_registry.m ** 3, unit_registry.Pa, unit_registry.degK),
5462+
(unit_registry.m**3, unit_registry.Pa, unit_registry.degK),
54635463
1,
54645464
1,
54655465
),

xarray/tests/test_variable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ def test_1d_math(self):
343343
assert_identical(base_v, 0 + v)
344344
assert_identical(base_v, v * 1)
345345
# binary ops with numpy arrays
346-
assert_array_equal((v * x).values, x ** 2)
347-
assert_array_equal((x * v).values, x ** 2)
346+
assert_array_equal((v * x).values, x**2)
347+
assert_array_equal((x * v).values, x**2)
348348
assert_array_equal(v - y, v - 1)
349349
assert_array_equal(y - v, 1 - v)
350350
# verify attributes are dropped
@@ -358,7 +358,7 @@ def test_1d_math(self):
358358
assert_array_equal((v * w).values, x * y)
359359

360360
# something complicated
361-
assert_array_equal((v ** 2 * w - 1 + x).values, x ** 2 * y - 1 + x)
361+
assert_array_equal((v**2 * w - 1 + x).values, x**2 * y - 1 + x)
362362
# make sure dtype is preserved (for Index objects)
363363
assert float == (+v).dtype
364364
assert float == (+v).values.dtype
@@ -1019,7 +1019,7 @@ def test_datetime64_conversion_scalar(self):
10191019
assert v.values.dtype == np.dtype("datetime64[ns]")
10201020

10211021
def test_timedelta64_conversion_scalar(self):
1022-
expected = np.timedelta64(24 * 60 * 60 * 10 ** 9, "ns")
1022+
expected = np.timedelta64(24 * 60 * 60 * 10**9, "ns")
10231023
for values in [
10241024
np.timedelta64(1, "D"),
10251025
pd.Timedelta("1 day"),
@@ -1048,7 +1048,7 @@ def test_0d_timedelta(self):
10481048
for td in [pd.to_timedelta("1s"), np.timedelta64(1, "s")]:
10491049
v = Variable([], td)
10501050
assert v.dtype == np.dtype("timedelta64[ns]")
1051-
assert v.values == np.timedelta64(10 ** 9, "ns")
1051+
assert v.values == np.timedelta64(10**9, "ns")
10521052

10531053
def test_equals_and_identical(self):
10541054
d = np.random.rand(10, 3)

xarray/tests/test_weighted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def expected_weighted(da, weights, dim, skipna, operation):
393393
return weighted_mean
394394

395395
demeaned = da - weighted_mean
396-
sum_of_squares = ((demeaned ** 2) * weights).sum(dim=dim, skipna=skipna)
396+
sum_of_squares = ((demeaned**2) * weights).sum(dim=dim, skipna=skipna)
397397

398398
if operation == "sum_of_squares":
399399
return sum_of_squares

xarray/tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def scatter_example_dataset(*, seed=None) -> Dataset:
246246
"w": 0.1 * rng.standard_normal(4),
247247
},
248248
)
249-
B = 0.1 * A.x ** 2 + A.y ** 2.5 + 0.1 * A.z * A.w
249+
B = 0.1 * A.x**2 + A.y**2.5 + 0.1 * A.z * A.w
250250
A = -0.1 * A.x + A.y / (5 + A.z) + A.w
251251
ds = Dataset({"A": A, "B": B})
252252
ds["w"] = ["one", "two", "three", "five"]

0 commit comments

Comments
 (0)