From e7f464aee94a56f6098fe2aa0fc6bd39c514e0b1 Mon Sep 17 00:00:00 2001 From: Alexandre Georges Date: Mon, 9 Feb 2026 09:48:33 -0800 Subject: [PATCH 1/3] Fix: Failing test_isel caused by uxgrid/sxgrid mismatch In SxDataArray constructor, pop incoming uxgrid from kwargs and assign to sxgrid before calling super().__init__. This prevents isel (and potentially other paths leading to UxDataArray/SxDataArray reconstructions) from passing uxgrid in kwargs and causing multiple-value errors. --- suxarray/core/dataarray.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/suxarray/core/dataarray.py b/suxarray/core/dataarray.py index df252dc..16d7472 100644 --- a/suxarray/core/dataarray.py +++ b/suxarray/core/dataarray.py @@ -18,6 +18,14 @@ def __init__(self, *args, sxgrid: Grid = None, **kwargs): if sxgrid is not None and not isinstance(sxgrid, Grid): raise RuntimeError("sxgrid must be a Grid object") + # temporary fix to avoid passing uxgrid to parent class through kwargs. + if "uxgrid" in kwargs: # check if uxgrid is in kwargs + if isinstance(kwargs["uxgrid"], Grid): # type check + sxgrid = kwargs["uxgrid"] # assign to sxgrid + kwargs.pop( + "uxgrid" + ) # remove uxgrid from kwargs to avoid passing it to parent class + super().__init__(*args, uxgrid=sxgrid, **kwargs) subset = UncachedAccessor(DataArraySubsetAccessor) @@ -32,7 +40,6 @@ def isel(self, ignore_grid=False, *args, **kwargs): da_new.uxgrid = da_new.uxgrid.sgrid_isel(**kwargs) return da_new - def depth_average(self) -> SxDataArray: """Calculate depth-average of a variable From 2029e972c57c2fc305f71e70dc1f231856f1a29a Mon Sep 17 00:00:00 2001 From: Alexandre Georges Date: Mon, 9 Feb 2026 10:33:28 -0800 Subject: [PATCH 2/3] Fix: Temporary patch for dimension renaming in _read_schism_grid/_rename_coords to address issues with uxarray uxarray's _read_ugrid function does not properly rename nSCHISM_hgrid_edge dimension to n_edge anymore. Added temporary path to rename this dimension (and n_face and n_node for future) on our side when _read_schism_grid is called. Fixes failing test_integrate_nodal. --- suxarray/io/_schismgrid.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/suxarray/io/_schismgrid.py b/suxarray/io/_schismgrid.py index c10b07e..c49caa8 100644 --- a/suxarray/io/_schismgrid.py +++ b/suxarray/io/_schismgrid.py @@ -55,6 +55,12 @@ def _read_schism_grid( # Use uxarray _read_ugrid to remap the dimensions # Note that it does not update the grid_topology information though # variable names are updated. + + # Note, as of uxarray==2025.9.0 _read_ugrid does not correctly rename the + # n_edge dimension to nSCHISM_hgrid_edge, which causes issues with the isel + # method. This is a temporary patch to rename the dimensions back to n_edge, + # n_face, and n_node after reading the grid. This will need to be removed + # once the issue is fixed in uxarray. ds_out2d, dim_dict = _read_ugrid(ds_out2d) ds_out2d = _rename_coords(ds_out2d) @@ -205,7 +211,7 @@ def _transform_coordinates( def _rename_coords( - data: Union[xr.DataArray, xr.Dataset] + data: Union[xr.DataArray, xr.Dataset], ) -> Union[xr.DataArray, xr.Dataset]: if SCHISM_CARTESIAN_NODE_COORDINATES[0] in data: coord_dict = { @@ -225,11 +231,19 @@ def _rename_coords( SCHISM_CARTESIAN_FACE_COORDINATES[1]: CARTESIAN_FACE_COORDINATES[1], } data = data.rename(coord_dict) + # Patch for dimension name renaming. + if "nSCHISM_hgrid_edge" in data.dims: + data = data.rename({"nSCHISM_hgrid_edge": "n_edge"}) + if "nSCHISM_hgrid_face" in data.dims: + data = data.rename({"nSCHISM_hgrid_face": "n_face"}) + if "nSCHISM_hgrid_node" in data.dims: + data = data.rename({"nSCHISM_hgrid_node": "n_node"}) + return data def _rename_coords_back( - data: Union[xr.DataArray, xr.Dataset] + data: Union[xr.DataArray, xr.Dataset], ) -> Union[xr.DataArray, xr.Dataset]: if CARTESIAN_NODE_COORDINATES[0] in data.coords: coord_dict = { From 4fd23b697267f67c30010addcbaeab63c66f88f3 Mon Sep 17 00:00:00 2001 From: Alexandre Georges Date: Mon, 9 Feb 2026 10:40:24 -0800 Subject: [PATCH 3/3] Update uxarray version to 2025.12.0 in requirements_dev.txt --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 770a3e2..0f3644b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -10,7 +10,7 @@ twine==1.14.0 Click==7.1.2 pytest==6.2.4 shapely>=2.0 -uxarray==2025.6.0 +uxarray==2025.12.0 netcdf>=1.6 xarray>=2023.4.1 holoviews>=1.16.0