66from numpy .testing import assert_allclose
77
88from parcels import xgcm
9- from parcels ._datasets .structured .generic import T , X , Y , Z , datasets
9+ from parcels ._datasets .structured .generic import X , Y , Z , datasets
1010from parcels .xgrid import XGrid , _search_1d_array
1111
1212GridTestCase = namedtuple ("GridTestCase" , ["Grid" , "attr" , "expected" ])
1616 GridTestCase (datasets ["ds_2d_left" ], "lat" , datasets ["ds_2d_left" ].YG .values ),
1717 GridTestCase (datasets ["ds_2d_left" ], "depth" , datasets ["ds_2d_left" ].ZG .values ),
1818 GridTestCase (datasets ["ds_2d_left" ], "time" , datasets ["ds_2d_left" ].time .values .astype (np .float64 ) / 1e9 ),
19- GridTestCase (datasets ["ds_2d_left" ], "xdim" , X ),
20- GridTestCase (datasets ["ds_2d_left" ], "ydim" , Y ),
21- GridTestCase (datasets ["ds_2d_left" ], "zdim" , Z ),
22- GridTestCase (datasets ["ds_2d_left" ], "tdim" , T ),
2319]
2420
2521
@@ -45,9 +41,18 @@ def test_xgrid_init_on_generic_datasets(ds):
4541 XGrid (xgcm .Grid (ds , periodic = False ))
4642
4743
48- def test_xgrid_axes ():
49- # Tests that the xgrid.axes property correctly identifies the axes and ordering
50- ...
44+ @pytest .mark .parametrize ("ds" , [datasets ["ds_2d_left" ]])
45+ def test_xgrid_axes (ds ):
46+ grid = XGrid (xgcm .Grid (ds , periodic = False ))
47+ assert grid .axes == ["Z" , "Y" , "X" ]
48+
49+
50+ @pytest .mark .parametrize ("ds" , [datasets ["ds_2d_left" ]])
51+ def test_xgrid_get_axis_dim (ds ):
52+ grid = XGrid (xgcm .Grid (ds , periodic = False ))
53+ assert grid .get_axis_dim ("Z" ) == Z
54+ assert grid .get_axis_dim ("Y" ) == Y
55+ assert grid .get_axis_dim ("X" ) == X
5156
5257
5358def test_invalid_xgrid_field_array ():
0 commit comments