Skip to content

Commit 6fd1340

Browse files
Fixing warnings in the test suite (#3029)
Fixng the warnings ``` tests/test_field.py::test_vectorfield_init_different_time_intervals /Users/erik/Codes/parcels/tests/test_field.py:93: FutureWarning: In a future version of xarray the default value for compat will change from compat='no_conflicts' to compat='override'. This is likely to lead to different results when combining overlapping variables with the same name. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set compat explicitly. ds = xr.merge([dsU, dsV]) tests/test_spatialhash.py::test_nan_node_invalidates_touching_faces /Users/erik/Codes/parcels/.pixi/envs/default/lib/python3.14/site-packages/numpy/linalg/_linalg.py:2406: RuntimeWarning: invalid value encountered in det r = _umath_linalg.det(a, signature=signature) ```
1 parent 31c6a1b commit 6fd1340

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/parcels/_core/spatialhash.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,9 @@ def _spherical_face_bounds(verts):
696696
# A triangle with no area encloses nothing. Rather
697697
# than let np.linalg.solve raise on it, conver those faces' weights to NaN.
698698
weights = np.full(M.shape[:-1] + (len(_AXIS_POINTS),), np.nan)
699-
has_area = np.abs(np.linalg.det(M)) > 1e-14
699+
# Faces with NaN nodes give a NaN determinant
700+
with np.errstate(invalid="ignore"):
701+
has_area = np.abs(np.linalg.det(M)) > 1e-14
700702
if has_area.any():
701703
weights[has_area] = np.linalg.solve(M[has_area], _AXIS_POINTS.T)
702704

‎tests/test_field.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_vectorfield_init_different_time_intervals():
9090
dsV["timeV"] = dsV["timeV"] + np.timedelta64(1, "D")
9191
dsV["timeV"].attrs["axis"] = "T"
9292

93-
ds = xr.merge([dsU, dsV])
93+
ds = xr.merge([dsU, dsV], compat="no_conflicts")
9494
with pytest.raises(ValueError, match="Multiple time coordinates"):
9595
FieldSet.from_sgrid_conventions(ds)
9696

‎tests/test_fieldset.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_vectorfields_without_time():
445445
"""Test that vector fields without a time dimension can be evaluated."""
446446
ds1 = datasets_structured["ds_2d_left"][["U_A_grid", "V_A_grid", "grid"]].rename({"U_A_grid": "U", "V_A_grid": "V"})
447447
ds2 = ds1.isel(time=0).drop_vars("time").rename({"U": "U_const", "V": "V_const"})
448-
ds = xr.merge([ds1, ds2])
448+
ds = xr.merge([ds1, ds2], compat="no_conflicts")
449449

450450
fset = FieldSet.from_sgrid_conventions(ds, vector_fields={"UV_const": ("U_const", "V_const")})
451451
fset.UV_const.eval(t=0, z=0, y=0, x=0)

0 commit comments

Comments
 (0)