Skip to content

Commit dd26c1a

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

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

tests/test_field.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def test_field_init_param_types():
1616
data = datasets_structured["ds_2d_left"]
1717
grid = XGrid.from_dataset(data)
1818

19-
with pytest.raises(
20-
TypeError, match="Expected a string for variable name, got int instead."
21-
):
19+
with pytest.raises(TypeError, match="Expected a string for variable name, got int instead."):
2220
Field(name=123, data=data["data_g"], grid=grid)
2321

2422
for name in ["a b", "123"]:
@@ -40,9 +38,7 @@ def test_field_init_param_types():
4038
):
4139
Field(name="test", data=123, grid=grid)
4240

43-
with pytest.raises(
44-
ValueError, match="Expected `grid` to be a parcels UxGrid, or parcels XGrid"
45-
):
41+
with pytest.raises(ValueError, match="Expected `grid` to be a parcels UxGrid, or parcels XGrid"):
4642
Field(name="test", data=data["data_g"], grid=123)
4743

4844

@@ -163,9 +159,7 @@ def test_vectorfield_invalid_interpolator():
163159
ds = datasets_structured["ds_2d_left"]
164160
grid = XGrid.from_dataset(ds)
165161

166-
def invalid_interpolator_wrong_signature(
167-
self, ti, position, tau, t, z, y, applyConversion, invalid
168-
):
162+
def invalid_interpolator_wrong_signature(self, ti, position, tau, t, z, y, applyConversion, invalid):
169163
return 0.0
170164

171165
# Create component fields
@@ -187,9 +181,7 @@ def test_field_unstructured_z_linear():
187181
The example dataset is a FESOM2 square Delaunay grid with uniform z-coordinate. Cell centered and layer registered data are defined to be
188182
linear functions of the vertical coordinate. This allows for testing of exactness of the interpolation methods.
189183
"""
190-
ds = datasets_unstructured["fesom2_square_delaunay_uniform_z_coordinate"].copy(
191-
deep=True
192-
)
184+
ds = datasets_unstructured["fesom2_square_delaunay_uniform_z_coordinate"].copy(deep=True)
193185

194186
# Change the pressure values to be linearly dependent on the vertical coordinate
195187
for k, z in enumerate(ds.coords["nz1"]):
@@ -205,43 +197,31 @@ def test_field_unstructured_z_linear():
205197

206198
# Test above first cell center - for piecewise constant, should return the depth of the first cell center
207199
assert np.isclose(
208-
P.eval(
209-
time=ds.time[0].values, z=[10.0], y=[30.0], x=[30.0], applyConversion=False
210-
),
200+
P.eval(time=ds.time[0].values, z=[10.0], y=[30.0], x=[30.0], applyConversion=False),
211201
55.555557,
212202
)
213203
# Test below first cell center, but in the first layer - for piecewise constant, should return the depth of the first cell center
214204
assert np.isclose(
215-
P.eval(
216-
time=ds.time[0].values, z=[65.0], y=[30.0], x=[30.0], applyConversion=False
217-
),
205+
P.eval(time=ds.time[0].values, z=[65.0], y=[30.0], x=[30.0], applyConversion=False),
218206
55.555557,
219207
)
220208
# Test bottom layer - for piecewise constant, should return the depth of the of the bottom layer cell center
221209
assert np.isclose(
222-
P.eval(
223-
time=ds.time[0].values, z=[900.0], y=[30.0], x=[30.0], applyConversion=False
224-
),
210+
P.eval(time=ds.time[0].values, z=[900.0], y=[30.0], x=[30.0], applyConversion=False),
225211
944.44445801,
226212
)
227213

228214
W = Field(name="W", data=ds.W, grid=grid, interp_method=UXPiecewiseLinearNode)
229215
assert np.isclose(
230-
W.eval(
231-
time=ds.time[0].values, z=[10.0], y=[30.0], x=[30.0], applyConversion=False
232-
),
216+
W.eval(time=ds.time[0].values, z=[10.0], y=[30.0], x=[30.0], applyConversion=False),
233217
10.0,
234218
)
235219
assert np.isclose(
236-
W.eval(
237-
time=ds.time[0].values, z=[65.0], y=[30.0], x=[30.0], applyConversion=False
238-
),
220+
W.eval(time=ds.time[0].values, z=[65.0], y=[30.0], x=[30.0], applyConversion=False),
239221
65.0,
240222
)
241223
assert np.isclose(
242-
W.eval(
243-
time=ds.time[0].values, z=[900.0], y=[30.0], x=[30.0], applyConversion=False
244-
),
224+
W.eval(time=ds.time[0].values, z=[900.0], y=[30.0], x=[30.0], applyConversion=False),
245225
900.0,
246226
)
247227

0 commit comments

Comments
 (0)