3838 ("scrip" , "scrip/outCSne8" , "outCSne8.nc" ),
3939 ("icon" , "icon/R02B04" , "icon_grid_0010_R02B04_G.nc" ),
4040 ("fesom" , "fesom/pi" , None ), # Special case - multiple files
41+ ("healpix" , None , None ), # Constructed via classmethod
4142]
4243
4344# Formats that support writing
@@ -57,6 +58,9 @@ def grid_from_format(request):
5758 fesom_data_path = current_path / "meshfiles" / subpath / "data"
5859 fesom_mesh_path = current_path / "meshfiles" / subpath
5960 grid = ux .open_grid (fesom_mesh_path , fesom_data_path )
61+ elif format_name == "healpix" :
62+ # Construct a basic HEALPix grid
63+ grid = ux .Grid .from_healpix (zoom = 1 , pixels_only = False )
6064 else :
6165 grid_path = current_path / "meshfiles" / subpath / filename
6266 if not grid_path .exists ():
@@ -82,9 +86,9 @@ def test_return_type(self, grid_from_format):
8286
8387 # Basic validation
8488 assert isinstance (grid , ux .Grid )
85- assert hasattr ( grid , 'face_node_connectivity' )
86- assert hasattr ( grid , 'node_lon' )
87- assert hasattr ( grid , 'node_lat' )
89+ assert 'face_node_connectivity' in grid . connectivity
90+ assert 'node_lon' in grid . coordinates
91+ assert 'node_lat' in grid . coordinates
8892
8993 # Check required dimensions
9094 assert 'n_node' in grid .dims
@@ -111,36 +115,21 @@ def test_ugrid_compliance(self, grid_from_format):
111115 # 3. Check that grid has been properly standardized by uxarray
112116 # (Not all input files have Conventions attribute, but uxarray should handle them)
113117
114- def test_grid_properties_consistency (self ):
118+ def test_grid_properties_consistency (self , grid_from_format ):
115119 """Test that all grids have consistent basic properties after loading."""
116- grids = []
117-
118- # Load all different format grids
119- for format_name , subpath , filename in IO_READ_TEST_FORMATS :
120- if filename is None : # Special case for fesom
121- # Skip fesom for now as it requires multiple files
122- continue
123-
124- grid_path = current_path / "meshfiles" / subpath / filename
125- if not grid_path .exists ():
126- continue
127-
128- if format_name == "mpas" :
129- grid = ux .open_grid (grid_path , use_dual = False )
130- else :
131- grid = ux .open_grid (grid_path )
132-
133- # Check that all grids have the essential properties
134- assert hasattr (grid , 'n_node' )
135- assert hasattr (grid , 'n_face' )
136- assert hasattr (grid , 'face_node_connectivity' )
137- assert hasattr (grid , 'node_lon' )
138- assert hasattr (grid , 'node_lat' )
139-
140- # Check data types are consistent
141- assert grid .face_node_connectivity .dtype in [np .int32 , np .int64 , INT_DTYPE ]
142- assert grid .node_lon .dtype in [np .float32 , np .float64 ]
143- assert grid .node_lat .dtype in [np .float32 , np .float64 ]
120+ grid = grid_from_format
121+
122+ # Check that all grids have the essential properties
123+ assert hasattr (grid , 'n_node' )
124+ assert hasattr (grid , 'n_face' )
125+ assert 'face_node_connectivity' in grid .connectivity
126+ assert 'node_lon' in grid .coordinates
127+ assert 'node_lat' in grid .coordinates
128+
129+ # Check data types are consistent
130+ assert grid .face_node_connectivity .dtype in [np .int32 , np .int64 , INT_DTYPE ]
131+ assert np .issubdtype (grid .node_lon .dtype , np .floating )
132+ assert np .issubdtype (grid .node_lat .dtype , np .floating )
144133
145134
146135
0 commit comments