Skip to content

Commit df26fc7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9be6e3c commit df26fc7

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

xarray_array_testing/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import hypothesis.strategies as st
22
import xarray.testing.strategies as xrst
3-
from hypothesis import given, settings, HealthCheck
3+
from hypothesis import HealthCheck, given, settings
44

55
from xarray_array_testing.base import DuckArrayTestMixin
66

xarray_array_testing/reduction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import hypothesis.strategies as st
44
import xarray.testing.strategies as xrst
5-
from hypothesis import given, settings, HealthCheck, note
5+
from hypothesis import HealthCheck, given, note, settings
66

77
from xarray_array_testing.base import DuckArrayTestMixin
88

xarray_array_testing/tests/test_cubed.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
from typing import ContextManager
21
from contextlib import nullcontext
2+
from typing import ContextManager
33

4-
import pytest
4+
import cubed
5+
import cubed.random
56
import hypothesis.strategies as st
6-
from hypothesis import note
77
import numpy as np
88
import numpy.testing as npt
9+
import pytest
10+
from hypothesis import note
911

1012
from xarray_array_testing.base import DuckArrayTestMixin
1113
from xarray_array_testing.creation import CreationTests
1214
from xarray_array_testing.reduction import ReductionTests
1315

14-
import cubed
15-
import cubed.random
16-
1716

1817
def cubed_random_array(shape: tuple[int], dtype: np.dtype) -> cubed.Array:
1918
"""
2019
Generates a random cubed array
21-
20+
2221
Supports integer and float dtypes.
2322
"""
2423
# TODO hypothesis doesn't like us using random inside strategies
2524
rng = np.random.default_rng()
26-
25+
2726
if np.issubdtype(dtype, np.integer):
2827
arr = rng.integers(low=0, high=+3, size=shape, dtype=dtype)
2928
return cubed.from_array(arr)
@@ -34,7 +33,9 @@ def cubed_random_array(shape: tuple[int], dtype: np.dtype) -> cubed.Array:
3433

3534

3635
def random_cubed_arrays_fn(
37-
*, shape: tuple[int, ...], dtype: np.dtype,
36+
*,
37+
shape: tuple[int, ...],
38+
dtype: np.dtype,
3839
) -> st.SearchStrategy[cubed.Array]:
3940
return st.builds(cubed_random_array, shape=st.just(shape), dtype=st.just(dtype))
4041

@@ -57,21 +58,26 @@ def assert_equal(a: cubed.Array, b: cubed.Array):
5758
npt.assert_equal(a.compute(), b.compute())
5859

5960

60-
6161
class TestCreationCubed(CreationTests, CubedTestMixin):
6262
pass
6363

6464

6565
class TestReductionCubed(ReductionTests, CubedTestMixin):
6666
@staticmethod
6767
def expected_errors(op, **parameters) -> ContextManager:
68-
var = parameters.get('variable')
68+
var = parameters.get("variable")
6969

7070
note(f"op = {op}")
7171
note(f"dtype = {var.dtype}")
7272
note(f"is_integer = {cubed.array_api.isdtype(var.dtype, 'integral')}")
7373

74-
if op == 'mean' and cubed.array_api.isdtype(var.dtype, "integral") or var.dtype == np.dtype('float16'):
75-
return pytest.raises(TypeError, match='Only real floating-point dtypes are allowed in mean')
74+
if (
75+
op == "mean"
76+
and cubed.array_api.isdtype(var.dtype, "integral")
77+
or var.dtype == np.dtype("float16")
78+
):
79+
return pytest.raises(
80+
TypeError, match="Only real floating-point dtypes are allowed in mean"
81+
)
7682
else:
7783
return nullcontext()

0 commit comments

Comments
 (0)