Skip to content

Commit

Permalink
added marker for missing neighbors
Browse files Browse the repository at this point in the history
  • Loading branch information
nfarabullini committed Jan 14, 2025
1 parent 062eaba commit 15e9e4b
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class TestApplyDiffusionToThetaAndExner(StencilTest):
PROGRAM = apply_diffusion_to_theta_and_exner
OUTPUTS = ("theta_v", "exner")
MARKER = (pytest.mark.embedded_skip,) # TODO: add pytest.mark.miss_neighbors # TODO: understand why values do not verify intermittently
MARKER = (pytest.mark.embedded_skip, pytest.mark.miss_neighbors)

@staticmethod
def reference(
Expand Down Expand Up @@ -94,7 +94,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

kh_smag_e = random_field(grid, dims.EdgeDim, dims.KDim)
inv_dual_edge_length = random_field(grid, dims.EdgeDim)
theta_v_in = random_field(grid, dims.CellDim, dims.KDim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
class TestCalculateNabla2AndSmagCoefficientsForVn(StencilTest):
PROGRAM = calculate_nabla2_and_smag_coefficients_for_vn
OUTPUTS = ("kh_smag_e", "kh_smag_ec", "z_nabla2_e")

# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(
Expand Down Expand Up @@ -150,7 +149,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

u_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=vpfloat)
v_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=vpfloat)
smag_offset = vpfloat("9.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def calculate_nabla4_numpy(
class TestCalculateNabla4(StencilTest):
PROGRAM = calculate_nabla4
OUTPUTS = ("z_nabla4_e2",)
# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(
Expand Down Expand Up @@ -94,7 +94,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

u_vert = random_field(grid, dims.VertexDim, dims.KDim, dtype=vpfloat)
v_vert = random_field(grid, dims.VertexDim, dims.KDim, dtype=vpfloat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def truly_horizontal_diffusion_nabla_of_theta_over_steep_points_numpy(
class TestTrulyHorizontalDiffusionNablaOfThetaOverSteepPoints(StencilTest):
PROGRAM = truly_horizontal_diffusion_nabla_of_theta_over_steep_points
OUTPUTS = ("z_temp",)
MARKER = (pytest.mark.embedded_skip,) # TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.embedded_skip, pytest.mark.miss_neighbors)

@staticmethod
def reference(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
class TestAddVerticalWindDerivativeToDivergenceDamping(StencilTest):
PROGRAM = add_vertical_wind_derivative_to_divergence_damping
OUTPUTS = ("z_graddiv_vn",)

# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(
Expand All @@ -48,7 +47,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

hmask_dd3d = random_field(grid, dims.EdgeDim, dtype=wpfloat)
scalfac_dd3d = random_field(grid, dims.KDim, dtype=wpfloat)
inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def compute_advective_normal_wind_tendency_numpy(
class TestComputeAdvectiveNormalWindTendency(StencilTest):
PROGRAM = compute_advective_normal_wind_tendency
OUTPUTS = ("ddt_vn_apc",)

# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(
Expand Down Expand Up @@ -87,7 +86,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

z_kin_hor_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat)
coeff_gradekin = data_alloc.random_field(grid, dims.EdgeDim, dims.E2CDim, dtype=vpfloat)
coeff_gradekin_new = data_alloc.as_1D_sparse_field(coeff_gradekin, dims.ECDim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
class TestComputeBtraj(StencilTest):
PROGRAM = compute_horizontal_advection_of_rho_and_theta
OUTPUTS = ("z_rho_e", "z_theta_v_e")

# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def compute_btraj_numpy(
Expand Down Expand Up @@ -184,7 +183,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

p_vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat)
p_vt = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat)
pos_on_tplane_e_1 = random_field(grid, dims.EdgeDim, dims.E2CDim, dtype=wpfloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class TestComputeHorizontalGradientOfExnerPressureForFlatCoordinates(StencilTest):
PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates
OUTPUTS = ("z_gradh_exner",)
# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(grid, inv_dual_edge_length: np.array, z_exner_ex_pr: np.array, **kwargs) -> dict:
Expand All @@ -35,7 +35,6 @@ def reference(grid, inv_dual_edge_length: np.array, z_exner_ex_pr: np.array, **k

@pytest.fixture
def input_data(self, grid):

inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat)
z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat)
z_gradh_exner = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class TestComputeHorizontalGradientOfExnerPressureForMultipleLevels(StencilTest):
PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_multiple_levels
OUTPUTS = ("z_gradh_exner",)
MARKER = (pytest.mark.embedded_skip,) # TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.embedded_skip, pytest.mark.miss_neighbors)

@staticmethod
def reference(
Expand Down Expand Up @@ -72,7 +72,6 @@ def at_neighbor(i):

@pytest.fixture
def input_data(self, grid):

inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat)
z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat)
zdiff_gradp = random_field(grid, dims.EdgeDim, dims.E2CDim, dims.KDim, dtype=vpfloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
class TestComputeHorizontalGradientOfExnerPressureForNonflatCoordinates(StencilTest):
PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates
OUTPUTS = ("z_gradh_exner",)

# TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.miss_neighbors,)

@staticmethod
def reference(
Expand All @@ -48,7 +47,6 @@ def reference(

@pytest.fixture
def input_data(self, grid):

inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat)
z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat)
ddxn_z_full = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class TestComputeHydrostaticCorrectionTerm(StencilTest):
OUTPUTS = ("z_hydro_corr",)
PROGRAM = compute_hydrostatic_correction_term
MARKER = (pytest.mark.embedded_skip,) # TODO: add pytest.mark.miss_neighbors
MARKER = (pytest.mark.embedded_skip, pytest.mark.miss_neighbors)

@staticmethod
def reference(
Expand Down Expand Up @@ -95,7 +95,6 @@ def _apply_index_field(shape, to_index, neighbor_table, offset_field):

@pytest.fixture
def input_data(self, grid):

ikoffset = zero_field(grid, dims.EdgeDim, dims.E2CDim, dims.KDim, dtype=gtx.int32)
rng = np.random.default_rng()
for k in range(grid.num_levels):
Expand Down
6 changes: 5 additions & 1 deletion model/testing/src/icon4py/model/testing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ class Output:
def _test_validation(self, grid, backend, input_data):
if self.MARKER is not None:
for marker in self.MARKER:
if marker.markname == "embedded_skip":
if marker.markname in "embedded_skip":
pytest.skip("test not compatible with embedded backend")
elif marker.markname == "miss_neighbors":
pytest.xfail("Stencil does not support missing neighbors.")
reference_outputs = self.reference(
grid,
**{k: v.asnumpy() if isinstance(v, gt_common.Field) else v for k, v in input_data.items()},
Expand Down Expand Up @@ -112,6 +114,8 @@ def _test_execution_benchmark(self, pytestconfig, grid, backend, input_data, ben
for marker in self.MARKER:
if marker.markname == "embedded_skip":
pytest.skip("test not compatible with embedded backend")
elif marker.markname == "miss_neighbors":
pytest.xfail("Stencil does not support missing neighbors.")
if pytestconfig.getoption(
"--benchmark-disable"
): # skipping as otherwise program calls are duplicated in tests.
Expand Down

0 comments on commit 15e9e4b

Please sign in to comment.