From 12f481b235a0102c2d17ca1f3aa302992cb57f5a Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Fri, 27 Feb 2026 17:02:10 +0100 Subject: [PATCH 1/2] refactor: remove deprecated functions --- ndsl/dsl/gt4py_utils.py | 20 -------------------- ndsl/stencils/corners.py | 25 +++---------------------- 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/ndsl/dsl/gt4py_utils.py b/ndsl/dsl/gt4py_utils.py index 39afa30d..e4dcb532 100644 --- a/ndsl/dsl/gt4py_utils.py +++ b/ndsl/dsl/gt4py_utils.py @@ -1,4 +1,3 @@ -import warnings from collections.abc import Callable, Sequence from functools import wraps from typing import Any @@ -447,25 +446,6 @@ def asarray(array, to_type=np.ndarray, dtype=None, order=None): return cp.asarray(array, dtype, order) -def is_gpu_backend(backend: Backend) -> bool: - warnings.warn( - "Function `gt4py_utils.is_gpu_backend` is deprecated, please use `Backend.is_gpu_backend()`", - category=DeprecationWarning, - stacklevel=2, - ) - return backend.is_gpu_backend() - - -def backend_is_fortran_aligned(backend: Backend) -> bool: - warnings.warn( - "Function `gt4py_utils.backend_is_fortran_aligned` is deprecated " - "please use `Backend.backend_is_fortran_aligned()`", - category=DeprecationWarning, - stacklevel=2, - ) - return backend.is_fortran_aligned() - - def zeros(shape, dtype=Float, *, backend: Backend): storage_type = cp.ndarray if backend.is_gpu_backend() else np.ndarray xp = cp if cp and storage_type is cp.ndarray else np diff --git a/ndsl/stencils/corners.py b/ndsl/stencils/corners.py index cdce6ae0..d9d8c6db 100644 --- a/ndsl/stencils/corners.py +++ b/ndsl/stencils/corners.py @@ -1,4 +1,3 @@ -import warnings from typing import Literal, TypeAlias, no_type_check from gt4py.cartesian import gtscript @@ -10,19 +9,10 @@ from ndsl.dsl.typing import FloatField -FillCornersDirection: TypeAlias = Literal["i", "x", "j", "y"] +FillCornersDirection: TypeAlias = Literal["i", "j"] GridType: TypeAlias = Literal["A", "B"] # Arakawa grid type -def _check_for_deprecation(axis: str) -> None: - if axis in ["x", "y"]: - warnings.warn( - f"Corners direction {axis} is deprecated use 'i' or 'j'", - category=DeprecationWarning, - stacklevel=2, - ) - - def kslice_from_inputs( kstart: int, nk: int | None, grid_indexer: GridIndexing ) -> tuple[slice, int]: @@ -365,10 +355,9 @@ def __init__( domain = default_domain """The full domain required to do corner computation everywhere""" - _check_for_deprecation(direction) - if direction in ["x", "i"]: + if direction in ["i"]: defn = fill_corners_bgrid_x_defn - elif direction in ["y", "j"]: + elif direction in ["j"]: defn = fill_corners_bgrid_y_defn else: raise ValueError("Direction must be either 'x' or 'y'") @@ -519,7 +508,6 @@ def fill_sw_corner_2d_bgrid( direction: FillCornersDirection, grid_indexer: GridIndexing, ) -> None: - _check_for_deprecation(direction) if direction in ["x", "i"]: q[grid_indexer.isc - i, grid_indexer.jsc - j, :] = q[ grid_indexer.isc - j, grid_indexer.jsc + i, : @@ -537,7 +525,6 @@ def fill_nw_corner_2d_bgrid( direction: FillCornersDirection, grid_indexer: GridIndexing, ) -> None: - _check_for_deprecation(direction) if direction in ["x", "i"]: q[grid_indexer.isc - i, grid_indexer.jec + 1 + j, :] = q[ grid_indexer.isc - j, grid_indexer.jec + 1 - i, : @@ -555,7 +542,6 @@ def fill_se_corner_2d_bgrid( direction: FillCornersDirection, grid_indexer: GridIndexing, ) -> None: - _check_for_deprecation(direction) if direction in ["x", "i"]: q[grid_indexer.iec + 1 + i, grid_indexer.jsc - j, :] = q[ grid_indexer.iec + 1 + j, grid_indexer.jsc + i, : @@ -573,7 +559,6 @@ def fill_ne_corner_2d_bgrid( direction: FillCornersDirection, grid_indexer: GridIndexing, ) -> None: - _check_for_deprecation(direction) if direction in ["x", "i"]: q[grid_indexer.iec + 1 + i, grid_indexer.jec + 1 + j :] = q[ grid_indexer.iec + 1 + j, grid_indexer.jec + 1 - i, : @@ -593,7 +578,6 @@ def fill_sw_corner_2d_agrid( kstart: int = 0, nk: int | None = None, ) -> None: - _check_for_deprecation(direction) kslice, nk = kslice_from_inputs(kstart, nk, grid_indexer) if direction in ["x", "i"]: q[grid_indexer.isc - i, grid_indexer.jsc - j, kslice] = q[ @@ -614,7 +598,6 @@ def fill_nw_corner_2d_agrid( kstart: int = 0, nk: int | None = None, ) -> None: - _check_for_deprecation(direction) kslice, nk = kslice_from_inputs(kstart, nk, grid_indexer) if direction in ["x", "i"]: q[grid_indexer.isc - i, grid_indexer.jec + j, kslice] = q[ @@ -635,7 +618,6 @@ def fill_se_corner_2d_agrid( kstart: int = 0, nk: int | None = None, ) -> None: - _check_for_deprecation(direction) kslice, nk = kslice_from_inputs(kstart, nk, grid_indexer) if direction in ["x", "i"]: q[grid_indexer.iec + i, grid_indexer.jsc - j, kslice] = q[ @@ -656,7 +638,6 @@ def fill_ne_corner_2d_agrid( kstart: int = 0, nk: int | None = None, ) -> None: - _check_for_deprecation(direction) kslice, nk = kslice_from_inputs(kstart, nk, grid_indexer) if direction in ["x", "i"]: q[grid_indexer.iec + i, grid_indexer.jec + j, kslice] = q[ From ddd4b10b6e029524c9146b207aa40941c61f2d4f Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Fri, 27 Feb 2026 17:06:28 +0100 Subject: [PATCH 2/2] refactor: remove support for `X_DIM` and friends --- examples/NDSL/03_orchestration_basics.ipynb | 8 ++++---- ndsl/constants.py | 14 +++++++------- ndsl/stencils/corners.py | 2 +- tests/test_zarr_monitor.py | 3 +-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/NDSL/03_orchestration_basics.ipynb b/examples/NDSL/03_orchestration_basics.ipynb index 93f818d5..39320f56 100644 --- a/examples/NDSL/03_orchestration_basics.ipynb +++ b/examples/NDSL/03_orchestration_basics.ipynb @@ -35,7 +35,7 @@ " orchestrate,\n", " QuantityFactory,\n", ")\n", - "from ndsl.constants import X_DIM, Y_DIM, Z_DIM\n", + "from ndsl.constants import I_DIM, J_DIM, K_DIM\n", "from ndsl.dsl.typing import FloatField, Float\n", "from ndsl.boilerplate import get_factories_single_tile_orchestrated" ] @@ -93,7 +93,7 @@ " domain=grid_indexing.domain_compute(),\n", " )\n", " self._tmp_field = quantity_factory.zeros(\n", - " [X_DIM, Y_DIM, Z_DIM], \"n/a\", dtype=dtype\n", + " [I_DIM, J_DIM, K_DIM], \"n/a\", dtype=dtype\n", " )\n", " self._n_halo = quantity_factory.sizer.n_halo\n", "\n", @@ -134,9 +134,9 @@ " )\n", " local_sum = LocalSum(stencil_factory, qty_factory)\n", "\n", - " in_field = qty_factory.zeros([X_DIM, Y_DIM, Z_DIM], \"n/a\", dtype=dtype)\n", + " in_field = qty_factory.zeros([I_DIM, J_DIM, K_DIM], \"n/a\", dtype=dtype)\n", " in_field.view[:] = 2.0\n", - " out_field = qty_factory.zeros([X_DIM, Y_DIM, Z_DIM], \"n/a\", dtype=dtype)\n", + " out_field = qty_factory.zeros([I_DIM, J_DIM, K_DIM], \"n/a\", dtype=dtype)\n", "\n", " # Run\n", " local_sum(in_field, out_field)" diff --git a/ndsl/constants.py b/ndsl/constants.py index d1685f1e..840df528 100644 --- a/ndsl/constants.py +++ b/ndsl/constants.py @@ -38,13 +38,13 @@ def _get_constant_version( # Common constants ##################### -I_DIM = X_DIM = "i" -I_INTERFACE_DIM = X_INTERFACE_DIM = "i_interface" -J_DIM = Y_DIM = "j" -J_INTERFACE_DIM = Y_INTERFACE_DIM = "j_interface" -K_DIM = Z_DIM = "k" -K_INTERFACE_DIM = Z_INTERFACE_DIM = "k_interface" -K_SOIL_DIM = Z_SOIL_DIM = "k_soil" +I_DIM = "i" +I_INTERFACE_DIM = "i_interface" +J_DIM = "j" +J_INTERFACE_DIM = "j_interface" +K_DIM = "k" +K_INTERFACE_DIM = "k_interface" +K_SOIL_DIM = "k_soil" I_DIMS = (I_DIM, I_INTERFACE_DIM) J_DIMS = (J_DIM, J_INTERFACE_DIM) diff --git a/ndsl/stencils/corners.py b/ndsl/stencils/corners.py index d9d8c6db..23873f5c 100644 --- a/ndsl/stencils/corners.py +++ b/ndsl/stencils/corners.py @@ -360,7 +360,7 @@ def __init__( elif direction in ["j"]: defn = fill_corners_bgrid_y_defn else: - raise ValueError("Direction must be either 'x' or 'y'") + raise ValueError("Direction must be either 'i' or 'j'") externals = stencil_factory.grid_indexing.axis_offsets( origin=origin, domain=domain ) diff --git a/tests/test_zarr_monitor.py b/tests/test_zarr_monitor.py index 68b5f07e..7c0a6757 100644 --- a/tests/test_zarr_monitor.py +++ b/tests/test_zarr_monitor.py @@ -18,7 +18,6 @@ J_INTERFACE_DIM, K_DIM, K_SOIL_DIM, - X_DIM, ) from ndsl.monitor.zarr_monitor import ZarrMonitor, array_chunks, get_calendar from ndsl.optional_imports import zarr @@ -95,7 +94,7 @@ def base_state(request, nz, ny, nx, numpy) -> dict: return { "var1": Quantity( numpy.ones([ny, nx]), - dims=(J_DIM, X_DIM), + dims=(J_DIM, I_DIM), units="m", backend=Backend.python(), )