From 631e3ce7c87f7ab97823facc4885559271ce23f8 Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Thu, 25 Jun 2026 13:09:23 +0200 Subject: [PATCH 1/3] Make "dace" import non-ambiguous + cleanup Because we have a "dace/" directory in `ndsl/dsl`, the previous import could be resolved as a local import. If that happened (depending on import order), then the DaCe's `Config` object would not be found there. Resolved by importing `Config` from `dace.config`, which is unambiguous to resolve. In addition, this PR adds light cleanup when selecting origin/domain form dims. --- ndsl/dsl/stencil.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ndsl/dsl/stencil.py b/ndsl/dsl/stencil.py index d5d37264..96d00946 100644 --- a/ndsl/dsl/stencil.py +++ b/ndsl/dsl/stencil.py @@ -7,8 +7,8 @@ from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, cast -import dace import numpy as np +from dace.config import Config as DaceConfig from gt4py.cartesian import config as gt_config from gt4py.cartesian import definitions as gt_definitions from gt4py.cartesian import gtscript @@ -321,7 +321,7 @@ def __init__( BackendFramework.DACE == self.stencil_config.compilation_config.backend.framework ): - dace.Config.set( + DaceConfig.set( "default_build_folder", value="{gt_root}/{gt_cache}/dacecache".format( gt_root=gt_config.cache_settings["root_path"], @@ -881,6 +881,8 @@ def _origin_from_dims(self, dims: Iterable[str]) -> list[int]: return_origin.append(self.origin[1]) elif dim in K_DIMS: return_origin.append(self.origin[2]) + else: + raise ValueError(f"Unknown dimension '{dim}'.") return return_origin def _domain_from_dims(self, dimensions: Iterable[str]) -> list[int]: @@ -888,16 +890,18 @@ def _domain_from_dims(self, dimensions: Iterable[str]) -> list[int]: for dimension in dimensions: if dimension == I_DIM: result.append(self.domain[0]) - if dimension == I_INTERFACE_DIM: + elif dimension == I_INTERFACE_DIM: result.append(self.domain[0] + 1) - if dimension == J_DIM: + elif dimension == J_DIM: result.append(self.domain[1]) - if dimension == J_INTERFACE_DIM: + elif dimension == J_INTERFACE_DIM: result.append(self.domain[1] + 1) - if dimension == K_DIM: + elif dimension == K_DIM: result.append(self.domain[2]) - if dimension == K_INTERFACE_DIM: + elif dimension == K_INTERFACE_DIM: result.append(self.domain[2] + 1) + else: + raise ValueError(f"Unknown dimension '{dimension}'.") return result def get_shape( From 139ad981bb082645efe3c3d158ecc379937829cb Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Tue, 23 Jun 2026 11:27:05 -0400 Subject: [PATCH 2/3] Push `matplolib` import into the plotting function --- ndsl/quantity/quantity.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ndsl/quantity/quantity.py b/ndsl/quantity/quantity.py index 0624a8c0..bc63531a 100644 --- a/ndsl/quantity/quantity.py +++ b/ndsl/quantity/quantity.py @@ -6,7 +6,6 @@ from typing import Any, cast import dace -import matplotlib.pyplot as plt import numpy as np import xarray as xr from gt4py import storage as gt_storage @@ -459,6 +458,8 @@ def transpose( return transposed def plot_k_level(self, k_index: int = 0) -> None: + import matplotlib.pyplot as plt + field = self._data plt.xlabel("I") plt.ylabel("J") From 195ef5799068ccb198703e42e3a6aba272260d95 Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Wed, 1 Jul 2026 15:06:49 +0200 Subject: [PATCH 3/3] just a space missing in the warning message --- ndsl/quantity/quantity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndsl/quantity/quantity.py b/ndsl/quantity/quantity.py index bc63531a..d493fe5f 100644 --- a/ndsl/quantity/quantity.py +++ b/ndsl/quantity/quantity.py @@ -286,7 +286,7 @@ def field(self) -> np.ndarray | cupy.ndarray: def data(self) -> np.ndarray | cupy.ndarray: """The underlying array of data""" warnings.warn( - "Quantity.data accessor is now deprecated. Use a slicing operation directly on" + "Quantity.data accessor is now deprecated. Use a slicing operation directly on " "the quantity, e.g. `my_quantity[:]` instead of `my_quantity.data[:]`", category=UserWarning, stacklevel=2,