Skip to content

Commit cc87fcd

Browse files
Patch unit test
Co-authored-by: Erik van Sebille <[email protected]> Co-authored-by: Vecko <[email protected]>
1 parent 10a44f8 commit cc87fcd

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/test_interpolation.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def create_interpolation_data():
5050
return xr.DataArray([spatial_data, spatial_data, spatial_data], dims=("time", "depth", "lat", "lon"))
5151

5252

53-
def create_interpolation_data_with_land():
53+
def create_interpolation_data_random(*, with_land_point: bool) -> xr.Dataset:
5454
tdim, zdim, ydim, xdim = 20, 5, 10, 10
5555
ds = xr.Dataset(
5656
{
@@ -66,9 +66,10 @@ def create_interpolation_data_with_land():
6666
},
6767
)
6868
# Set a land point (for testing freeslip)
69-
ds["U"][:, :, 2, 5] = 0.0
70-
ds["V"][:, :, 2, 5] = 0.0
71-
ds["W"][:, :, 2, 5] = 0.0
69+
if with_land_point:
70+
ds["U"][:, :, 2, 5] = 0.0
71+
ds["V"][:, :, 2, 5] = 0.0
72+
ds["W"][:, :, 2, 5] = 0.0
7273

7374
return ds
7475

@@ -137,16 +138,19 @@ def test_interpolator2(ctx: interpolation.InterpolationContext3D):
137138
"linear",
138139
"freeslip",
139140
"nearest",
140-
pytest.param(
141-
"cgrid_velocity", marks=pytest.mark.xfail(reason="https://github.com/OceanParcels/Parcels/pull/1834")
142-
),
141+
"cgrid_velocity",
143142
],
144143
)
145144
def test_scipy_vs_jit(interp_method):
146145
"""Test that the scipy and JIT versions of the interpolation are the same."""
147146
variables = {"U": "U", "V": "V", "W": "W"}
148147
dimensions = {"time": "time", "lon": "lon", "lat": "lat", "depth": "depth"}
149-
fieldset = FieldSet.from_xarray_dataset(create_interpolation_data_with_land(), variables, dimensions, mesh="flat")
148+
fieldset = FieldSet.from_xarray_dataset(
149+
create_interpolation_data_random(with_land_point=interp_method == "freeslip"),
150+
variables,
151+
dimensions,
152+
mesh="flat",
153+
)
150154

151155
for field in [fieldset.U, fieldset.V, fieldset.W]: # Set a land point (for testing freeslip)
152156
field.interp_method = interp_method

0 commit comments

Comments
 (0)