Skip to content

Commit 427bfa3

Browse files
committed
Update dummy sgrid dataset generation
1 parent fc99fa2 commit 427bfa3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/utils/test_sgrid.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
import xarray as xr
44
import xgcm
5-
from hypothesis import example, given
5+
from hypothesis import assume, example, given
66

77
from parcels._core.utils import sgrid
88
from tests.strategies import sgrid as sgrid_strategies
@@ -41,6 +41,9 @@ def dummy_sgrid_ds(grid: sgrid.Grid2DMetadata | sgrid.Grid3DMetadata) -> xr.Data
4141
def dummy_sgrid_2d_ds(grid: sgrid.Grid2DMetadata) -> xr.Dataset:
4242
ds = dummy_comodo_3d_ds()
4343

44+
# Can't rename dimensions that already exist in the dataset
45+
assume(get_unique_dim_names(grid) & set(ds.dims) == set())
46+
4447
renamings = {}
4548
if grid.vertical_dimensions is None:
4649
ds = ds.isel(ZC=0, ZG=0)
@@ -63,6 +66,9 @@ def dummy_sgrid_2d_ds(grid: sgrid.Grid2DMetadata) -> xr.Dataset:
6366
def dummy_sgrid_3d_ds(grid: sgrid.Grid3DMetadata) -> xr.Dataset:
6467
ds = dummy_comodo_3d_ds()
6568

69+
# Can't rename dimensions that already exist in the dataset
70+
assume(get_unique_dim_names(grid) & set(ds.dims) == set())
71+
6672
renamings = {}
6773
for old, new in zip(["XG", "YG", "ZG"], grid.node_dimensions, strict=True):
6874
renamings[old] = new

0 commit comments

Comments
 (0)