Skip to content

Commit ef5717a

Browse files
DropDhavogt
andauthored
Update to GT4Py v1.1.8: adapt type hints (and ignores) (#1096)
Reduce blanket type ignores at the price of adding a handful specific ones. --------- Co-authored-by: Hannes Vogt <vogt@hey.com>
1 parent fb1e5ad commit ef5717a

36 files changed

Lines changed: 102 additions & 117 deletions

File tree

‎model/atmosphere/advection/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
# workspace members
2727
"icon4py-common>=0.0.6",
2828
# external dependencies
29-
"gt4py==1.1.7",
29+
"gt4py==1.1.8",
3030
'packaging>=20.0'
3131
]
3232
description = "ICON advection."

‎model/atmosphere/advection/src/icon4py/model/atmosphere/advection/stencils/apply_positive_definite_horizontal_multiplicative_flux_factor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def apply_positive_definite_horizontal_multiplicative_flux_factor(
3737
horizontal_end: gtx.int32,
3838
vertical_start: gtx.int32,
3939
vertical_end: gtx.int32,
40-
):
40+
) -> None:
4141
_apply_positive_definite_horizontal_multiplicative_flux_factor(
4242
r_m,
4343
p_mflx_tracer_h,

‎model/atmosphere/advection/src/icon4py/model/atmosphere/advection/stencils/compute_ppm_all_face_values.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _compute_ppm_all_face_values(
4040

4141
p_face = concat_where(dims.KDim == elevp1, p_cc(Koff[-1]), p_face)
4242

43-
return p_face # type: ignore[return-value] # concat_where leads to static type-erasure
43+
return p_face
4444

4545

4646
@gtx.program(grid_type=gtx.GridType.UNSTRUCTURED)

‎model/atmosphere/advection/src/icon4py/model/atmosphere/advection/stencils/compute_ppm_slope.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _compute_ppm_slope(
5858
_compute_ppm_slope_a(p_cc, p_cellhgt_mc_now),
5959
)
6060

61-
return z_slope # type: ignore[return-value] # concat_where leads to static type erasure
61+
return z_slope
6262

6363

6464
@gtx.program(grid_type=gtx.GridType.UNSTRUCTURED)

‎model/atmosphere/diffusion/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
# workspace members
2727
"icon4py-common>=0.0.6",
2828
# external dependencies
29-
"gt4py==1.1.7",
29+
"gt4py==1.1.8",
3030
'packaging>=20.0'
3131
]
3232
description = "ICON diffusion."

‎model/atmosphere/dycore/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
# workspace members
2727
"icon4py-common>=0.0.6",
2828
# external dependencies
29-
"gt4py==1.1.7",
29+
"gt4py==1.1.8",
3030
'packaging>=20.0'
3131
]
3232
description = "ICON dynamical core."

‎model/atmosphere/dycore/tests/dycore/integration_tests/test_benchmark_solve_nonhydro.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131
from icon4py.model.common.interpolation import interpolation_attributes, interpolation_factory
3232
from icon4py.model.common.metrics import metrics_attributes, metrics_factory
33-
from icon4py.model.common.states import prognostic_state as prognostics
33+
from icon4py.model.common.states import factory, prognostic_state as prognostics
3434
from icon4py.model.common.utils import data_allocation as data_alloc
3535
from icon4py.model.testing.fixtures.benchmark import (
3636
geometry_field_source,
@@ -171,7 +171,7 @@ def solve_nonhydro(
171171
ddxn_z_full=metrics_field_source.get(metrics_attributes.DDXN_Z_FULL),
172172
zdiff_gradp=metrics_field_source.get(metrics_attributes.ZDIFF_GRADP),
173173
vertoffset_gradp=metrics_field_source.get(metrics_attributes.VERTOFFSET_GRADP),
174-
nflat_gradp=metrics_field_source.get(metrics_attributes.NFLAT_GRADP),
174+
nflat_gradp=metrics_field_source.get_int32(metrics_attributes.NFLAT_GRADP),
175175
pg_exdist=metrics_field_source.get(metrics_attributes.PG_EXDIST_DSL),
176176
ddqz_z_full_e=metrics_field_source.get(metrics_attributes.DDQZ_Z_FULL_E),
177177
ddxt_z_full=metrics_field_source.get(metrics_attributes.DDXT_Z_FULL),

‎model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_vertical_momentum_equation.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def interpolate_contravariant_vertical_velocity_to_full_levels_numpy(
7676
)
7777
contravariant_corrected_w_at_cells_on_model_levels = 0.5 * (
7878
contravariant_corrected_w_with_surface[:, :-1]
79-
+ contravariant_corrected_w_with_surface[:, 1:]
79+
+ contravariant_corrected_w_with_surface[:, 1:] # type: ignore[operator] # unclear why mypy complains (might be fixable in gt4py mypy plugin)
8080
)
8181
return contravariant_corrected_w_at_cells_on_model_levels
8282

‎model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_of_rho_and_theta.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ def reference(
252252
return dict(out=(z_rho_e, z_theta_v_e))
253253

254254
@pytest.fixture
255-
def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]:
255+
def input_data(
256+
self, grid: base.Grid
257+
) -> dict[str, gtx.Field | state_utils.ScalarType | gtx.Domain | tuple[gtx.Field, ...]]:
256258
p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat)
257259
p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat)
258260
pos_on_tplane_e_1 = data_alloc.random_field(

‎model/atmosphere/dycore/tests/dycore/stencil_tests/test_dycore_utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def fourth_order_divdamp_scaling_coeff_numpy(
31-
a: np.ndarray, divdamp_order: int, factor: float, mean_cell_area: float
31+
a: np.ndarray, divdamp_order: gtx.int32, factor: float, mean_cell_area: float
3232
) -> np.ndarray:
3333
b = np.maximum(0.0, a - 0.25 * factor) if divdamp_order == 24 else np.full_like(a, factor)
3434
return -b * mean_cell_area**2
@@ -44,7 +44,7 @@ def test_calculate_fourth_order_divdamp_scaling_coeff_order_24(
4444
backend: gtx_typing.Backend,
4545
) -> None:
4646
second_order_divdamp_factor = 3.0
47-
divdamp_order = 24
47+
divdamp_order = gtx.int32(24)
4848
mean_cell_area = 1000.0
4949
grid = simple_grid.simple_grid(allocator=backend)
5050
interpolated_fourth_order_divdamp_factor = data_alloc.random_field(

0 commit comments

Comments
 (0)