Skip to content

Commit 65be282

Browse files
Fix some deprecation warnings (#2240)
1 parent a4cb13d commit 65be282

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

parcels/fieldset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from parcels.field import Field, VectorField
1616
from parcels.tools.converters import Geographic, GeographicPolar
1717
from parcels.tools.loggers import logger
18-
from parcels.xgrid import XGrid
18+
from parcels.xgrid import _DEFAULT_XGCM_KWARGS, XGrid
1919

2020
if TYPE_CHECKING:
2121
from parcels._typing import TimeLike
@@ -134,7 +134,7 @@ def add_constant_field(self, name: str, value, mesh: Mesh = "flat"):
134134
2. flat: No conversion, lat/lon are assumed to be in m.
135135
"""
136136
ds = xr.Dataset({name: (["time", "lat", "lon", "depth"], np.full((1, 1, 1, 1), value))})
137-
grid = XGrid(xgcm.Grid(ds))
137+
grid = XGrid(xgcm.Grid(ds, **_DEFAULT_XGCM_KWARGS))
138138
self.add_field(
139139
Field(
140140
name,
@@ -226,6 +226,7 @@ def from_copernicusmarine(ds: xr.Dataset):
226226
},
227227
},
228228
autoparse_metadata=False,
229+
**_DEFAULT_XGCM_KWARGS,
229230
)
230231
)
231232

tests/v4/test_datasets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import xgcm
22

33
from parcels._datasets.structured.generic import datasets
4+
from parcels.xgrid import _DEFAULT_XGCM_KWARGS
45

56

67
def test_left_indexed_dataset():
78
"""Checks that 'ds_2d_left' is right indexed on all variables."""
89
ds = datasets["ds_2d_left"]
9-
grid = xgcm.Grid(ds)
10+
grid = xgcm.Grid(ds, **_DEFAULT_XGCM_KWARGS)
1011

1112
for _axis_name, axis in grid.axes.items():
1213
for pos, _dim_name in axis.coords.items():
@@ -16,7 +17,7 @@ def test_left_indexed_dataset():
1617
def test_right_indexed_dataset():
1718
"""Checks that 'ds_2d_right' is right indexed on all variables."""
1819
ds = datasets["ds_2d_right"]
19-
grid = xgcm.Grid(ds)
20+
grid = xgcm.Grid(ds, **_DEFAULT_XGCM_KWARGS)
2021
for _axis_name, axis in grid.axes.items():
2122
for pos, _dim_name in axis.coords.items():
2223
assert pos in ["center", "right"]

tests/v4/test_particleset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_pset_remove_index(fieldset, npart=100):
178178
indices_to_remove = [0, 10, 20]
179179
pset.remove_indices(indices_to_remove)
180180
assert pset.size == 97
181-
assert not np.any(np.in1d(pset.trajectory, indices_to_remove))
181+
assert not np.any(np.isin(pset.trajectory, indices_to_remove))
182182

183183

184184
def test_pset_iterator(fieldset):

tests/v4/test_particleset_execute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def fieldset() -> FieldSet:
3838
@pytest.fixture
3939
def fieldset_no_time_interval() -> FieldSet:
4040
# i.e., no time variation
41-
ds = datasets_structured["ds_2d_left"].isel(time=0).drop("time")
41+
ds = datasets_structured["ds_2d_left"].isel(time=0).drop_vars("time")
4242

4343
grid = XGrid.from_dataset(ds, mesh="flat")
4444
U = Field("U", ds["U (A grid)"], grid)

0 commit comments

Comments
 (0)