Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#6221)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
pre-commit-ci[bot] committed Jan 31, 2022
1 parent b09de81 commit 0a1e7e4
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -26,7 +26,7 @@ repos:
- "--py37-plus"
# https://github.com/python/black#version-control-integration
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
- id: black-jupyter
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/common.py
Expand Up @@ -65,7 +65,7 @@ def robust_getitem(array, key, catch=Exception, max_retries=6, initial_delay=500
except catch:
if n == max_retries:
raise
base_delay = initial_delay * 2 ** n
base_delay = initial_delay * 2**n
next_delay = base_delay + np.random.randint(base_delay)
msg = (
f"getitem failed, waiting {next_delay} ms before trying again "
Expand Down
2 changes: 1 addition & 1 deletion xarray/coding/cftime_offsets.py
Expand Up @@ -671,7 +671,7 @@ def __apply__(self, other):


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


# pandas defines these offsets as "Tick" objects, which for instance have
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/weighted.py
Expand Up @@ -189,7 +189,7 @@ def _sum_of_squares(

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

return self._reduce((demeaned ** 2), self.weights, dim=dim, skipna=skipna)
return self._reduce((demeaned**2), self.weights, dim=dim, skipna=skipna)

def _weighted_sum(
self,
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Expand Up @@ -1444,7 +1444,7 @@ def test_encoding_chunksizes_unlimited(self):
"complevel": 0,
"fletcher32": False,
"contiguous": False,
"chunksizes": (2 ** 20,),
"chunksizes": (2**20,),
"original_shape": (3,),
}
with self.roundtrip(ds) as actual:
Expand Down
13 changes: 5 additions & 8 deletions xarray/tests/test_computation.py
Expand Up @@ -475,13 +475,10 @@ def test_unified_dim_sizes() -> None:
"x": 1,
"y": 2,
}
assert (
unified_dim_sizes(
[xr.Variable(("x", "z"), [[1]]), xr.Variable(("y", "z"), [[1, 2], [3, 4]])],
exclude_dims={"z"},
)
== {"x": 1, "y": 2}
)
assert unified_dim_sizes(
[xr.Variable(("x", "z"), [[1]]), xr.Variable(("y", "z"), [[1, 2], [3, 4]])],
exclude_dims={"z"},
) == {"x": 1, "y": 2}

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

da = xr.DataArray(
np.stack((1.0 + x + 2.0 * x ** 2, 1.0 + 2.0 * x + 3.0 * x ** 2)),
np.stack((1.0 + x + 2.0 * x**2, 1.0 + 2.0 * x + 3.0 * x**2)),
dims=("d", "x"),
coords={"x": xcoord, "d": [0, 1]},
)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataarray.py
Expand Up @@ -3727,7 +3727,7 @@ def test_polyfit(self, use_dask, use_datetime):

da_raw = DataArray(
np.stack(
(10 + 1e-15 * x + 2e-28 * x ** 2, 30 + 2e-14 * x + 1e-29 * x ** 2)
(10 + 1e-15 * x + 2e-28 * x**2, 30 + 2e-14 * x + 1e-29 * x**2)
),
dims=("d", "x"),
coords={"x": xcoord, "d": [0, 1]},
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataset.py
Expand Up @@ -3644,7 +3644,7 @@ def test_assign(self):
assert list(actual.variables) == ["x", "y"]
assert_identical(ds, Dataset())

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

Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_interp.py
Expand Up @@ -30,7 +30,7 @@ def get_example_data(case):
data = xr.DataArray(
np.sin(x[:, np.newaxis]) * np.cos(y),
dims=["x", "y"],
coords={"x": x, "y": y, "x2": ("x", x ** 2)},
coords={"x": x, "y": y, "x2": ("x", x**2)},
)

if case == 0:
Expand All @@ -46,7 +46,7 @@ def get_example_data(case):
return xr.DataArray(
np.sin(x[:, np.newaxis, np.newaxis]) * np.cos(y[:, np.newaxis]) * z,
dims=["x", "y", "z"],
coords={"x": x, "y": y, "x2": ("x", x ** 2), "z": z},
coords={"x": x, "y": y, "x2": ("x", x**2), "z": z},
)
elif case == 4:
return get_example_data(3).chunk({"z": 5})
Expand Down Expand Up @@ -440,7 +440,7 @@ def test_sorted():
da = xr.DataArray(
np.cos(x[:, np.newaxis, np.newaxis]) * np.cos(y[:, np.newaxis]) * z,
dims=["x", "y", "z"],
coords={"x": x, "y": y, "x2": ("x", x ** 2), "z": z},
coords={"x": x, "y": y, "x2": ("x", x**2), "z": z},
)

x_new = np.linspace(0, 1, 30)
Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_plot.py
Expand Up @@ -550,7 +550,7 @@ def test_geo_data(self):
[-137.85, -120.99, -103.28, -85.28, -67.62],
]
)
data = np.sqrt(lon ** 2 + lat ** 2)
data = np.sqrt(lon**2 + lat**2)
da = DataArray(
data,
dims=("y", "x"),
Expand Down Expand Up @@ -2886,8 +2886,8 @@ def test_plot_transposes_properly(plotfunc):
def test_facetgrid_single_contour():
# regression test for GH3569
x, y = np.meshgrid(np.arange(12), np.arange(12))
z = xr.DataArray(np.sqrt(x ** 2 + y ** 2))
z2 = xr.DataArray(np.sqrt(x ** 2 + y ** 2) + 1)
z = xr.DataArray(np.sqrt(x**2 + y**2))
z2 = xr.DataArray(np.sqrt(x**2 + y**2) + 1)
ds = xr.concat([z, z2], dim="time")
ds["time"] = [0, 1]

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_units.py
Expand Up @@ -5459,7 +5459,7 @@ def test_grouped_operations(self, func, variant, dtype):
def test_content_manipulation(self, func, variant, dtype):
variants = {
"data": (
(unit_registry.m ** 3, unit_registry.Pa, unit_registry.degK),
(unit_registry.m**3, unit_registry.Pa, unit_registry.degK),
1,
1,
),
Expand Down
10 changes: 5 additions & 5 deletions xarray/tests/test_variable.py
Expand Up @@ -343,8 +343,8 @@ def test_1d_math(self):
assert_identical(base_v, 0 + v)
assert_identical(base_v, v * 1)
# binary ops with numpy arrays
assert_array_equal((v * x).values, x ** 2)
assert_array_equal((x * v).values, x ** 2)
assert_array_equal((v * x).values, x**2)
assert_array_equal((x * v).values, x**2)
assert_array_equal(v - y, v - 1)
assert_array_equal(y - v, 1 - v)
# verify attributes are dropped
Expand All @@ -358,7 +358,7 @@ def test_1d_math(self):
assert_array_equal((v * w).values, x * y)

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

def test_timedelta64_conversion_scalar(self):
expected = np.timedelta64(24 * 60 * 60 * 10 ** 9, "ns")
expected = np.timedelta64(24 * 60 * 60 * 10**9, "ns")
for values in [
np.timedelta64(1, "D"),
pd.Timedelta("1 day"),
Expand Down Expand Up @@ -1048,7 +1048,7 @@ def test_0d_timedelta(self):
for td in [pd.to_timedelta("1s"), np.timedelta64(1, "s")]:
v = Variable([], td)
assert v.dtype == np.dtype("timedelta64[ns]")
assert v.values == np.timedelta64(10 ** 9, "ns")
assert v.values == np.timedelta64(10**9, "ns")

def test_equals_and_identical(self):
d = np.random.rand(10, 3)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_weighted.py
Expand Up @@ -393,7 +393,7 @@ def expected_weighted(da, weights, dim, skipna, operation):
return weighted_mean

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

if operation == "sum_of_squares":
return sum_of_squares
Expand Down
2 changes: 1 addition & 1 deletion xarray/tutorial.py
Expand Up @@ -246,7 +246,7 @@ def scatter_example_dataset(*, seed=None) -> Dataset:
"w": 0.1 * rng.standard_normal(4),
},
)
B = 0.1 * A.x ** 2 + A.y ** 2.5 + 0.1 * A.z * A.w
B = 0.1 * A.x**2 + A.y**2.5 + 0.1 * A.z * A.w
A = -0.1 * A.x + A.y / (5 + A.z) + A.w
ds = Dataset({"A": A, "B": B})
ds["w"] = ["one", "two", "three", "five"]
Expand Down

0 comments on commit 0a1e7e4

Please sign in to comment.