diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_horizontal_density_increment.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_horizontal_density_increment.py index 2b82a73a20..11872b58c3 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_horizontal_density_increment.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_horizontal_density_increment.py @@ -29,7 +29,7 @@ class TestApplyHorizontalDensityIncrement(stencil_tests.StencilTest): ), ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_rhodz_new: np.ndarray, @@ -43,7 +43,7 @@ def reference( rhodz_ast2 = np.maximum(0.1 * p_rhodz_new, p_rhodz_new) - p_dtime * tmp return dict(rhodz_ast2=rhodz_ast2) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_rhodz_new = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_mflx_contra_v = data_alloc.random_field( diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_interpolated_tracer_time_tendency.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_interpolated_tracer_time_tendency.py index 4484a4159a..529d74a9f0 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_interpolated_tracer_time_tendency.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_interpolated_tracer_time_tendency.py @@ -24,7 +24,7 @@ class TestApplyInterpolatedTracerTimeTendency(stencil_tests.StencilTest): PROGRAM = apply_interpolated_tracer_time_tendency OUTPUTS = ("p_tracer_new",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_tracer_now: np.ndarray, @@ -37,7 +37,7 @@ def reference( return dict(p_tracer_new=p_tracer_new) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_tracer_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_grf_tend_tracer = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_vertical_density_increment.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_vertical_density_increment.py index 9c428c9c60..a879903e5d 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_vertical_density_increment.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_apply_vertical_density_increment.py @@ -30,7 +30,7 @@ class TestApplyVerticalDensityIncrement(stencil_tests.StencilTest): ), ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rhodz_ast: np.ndarray, @@ -47,7 +47,7 @@ def reference( return dict(rhodz_ast2=rhodz_ast2) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: rhodz_ast = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_mflx_contra_v = data_alloc.random_field( diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_2.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_2.py index d73e3354ac..9b75471517 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_2.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_2.py @@ -24,7 +24,7 @@ class TestAverageHorizontalFluxSubcycling2(stencil_tests.StencilTest): PROGRAM = average_horizontal_flux_subcycling_2 OUTPUTS = ("p_out_e",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_tracer_mflx_1_dsl: np.ndarray, @@ -34,7 +34,7 @@ def reference( p_out_e = (z_tracer_mflx_1_dsl + z_tracer_mflx_2_dsl) / float(2) return dict(p_out_e=p_out_e) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_tracer_mflx_1_dsl = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) z_tracer_mflx_2_dsl = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_3.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_3.py index 9883b6fc5a..b9e16d4498 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_3.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_average_horizontal_flux_subcycling_3.py @@ -24,7 +24,7 @@ class TestAverageHorizontalFluxSubcycling3(stencil_tests.StencilTest): PROGRAM = average_horizontal_flux_subcycling_3 OUTPUTS = ("p_out_e",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_tracer_mflx_1_dsl: np.ndarray, @@ -35,7 +35,7 @@ def reference( p_out_e = (z_tracer_mflx_1_dsl + z_tracer_mflx_2_dsl + z_tracer_mflx_3_dsl) / float(3) return dict(p_out_e=p_out_e) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_tracer_mflx_1_dsl = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) z_tracer_mflx_2_dsl = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_antidiffusive_cell_fluxes_and_min_max.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_antidiffusive_cell_fluxes_and_min_max.py index 63dc972850..ff456c4c74 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_antidiffusive_cell_fluxes_and_min_max.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_antidiffusive_cell_fluxes_and_min_max.py @@ -28,7 +28,7 @@ class TestComputeAntidiffusiveCellFluxesAndMinMax(stencil_tests.StencilTest): "z_tracer_min", ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], geofac_div: np.ndarray, @@ -77,7 +77,7 @@ def reference( z_tracer_min=z_tracer_min, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim) p_rhodz_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory.py index 63054b2a19..53ec7ae6aa 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory.py @@ -22,7 +22,7 @@ class TestComputeBarycentricBacktrajectory(stencil_tests.StencilTest): PROGRAM = compute_barycentric_backtrajectory OUTPUTS = ("p_cell_idx", "p_distv_bary_1", "p_distv_bary_2") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -79,7 +79,7 @@ def reference( p_distv_bary_2=p_distv_bary_2, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory_alt.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory_alt.py index 1adb8af3aa..02d3c22c0f 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory_alt.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_barycentric_backtrajectory_alt.py @@ -22,7 +22,7 @@ class TestComputeBarycentricBacktrajectoryAlt(stencil_tests.StencilTest): PROGRAM = compute_barycentric_backtrajectory_alt OUTPUTS = ("p_distv_bary_1", "p_distv_bary_2") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -72,7 +72,7 @@ def reference( p_distv_bary_2=p_distv_bary_2, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory.py index 60bb15e9cf..edfafcddd1 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory.py @@ -34,7 +34,7 @@ class TestComputeFfslBacktrajectory(stencil_tests.StencilTest): "p_coords_dreg_v_4_lat_dsl", ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -145,7 +145,7 @@ def reference( "p_coords_dreg_v_4_lat_dsl": p_coords_dreg_v_4_lat_dsl, } - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_counterclockwise_indicator.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_counterclockwise_indicator.py index 064c915c6c..544b5366bd 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_counterclockwise_indicator.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_counterclockwise_indicator.py @@ -24,7 +24,7 @@ class TestComputeFfslBacktrajectoryCounterclockwiseIndicator(stencil_tests.Stenc PROGRAM = compute_ffsl_backtrajectory_counterclockwise_indicator OUTPUTS = ("lvn_sys_pos",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -44,7 +44,7 @@ def reference( return dict(lvn_sys_pos=lvn_sys_pos) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) tangent_orientation = data_alloc.random_field(grid, dims.EdgeDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_length_indicator.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_length_indicator.py index 326d040463..198fe67ae1 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_length_indicator.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ffsl_backtrajectory_length_indicator.py @@ -22,7 +22,7 @@ class TestComputeFfslBacktrajectoryLengthIndicator(stencil_tests.StencilTest): PROGRAM = compute_ffsl_backtrajectory_length_indicator OUTPUTS = ("opt_famask_dsl",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -46,7 +46,7 @@ def reference( return dict(opt_famask_dsl=opt_famask_dsl) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_cubic_coefficients.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_cubic_coefficients.py index cdf27e4979..252f4fa548 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_cubic_coefficients.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_cubic_coefficients.py @@ -22,7 +22,7 @@ class TestComputeHorizontalTracerFluxFromCubicCoefficients(stencil_tests.Stencil PROGRAM = compute_horizontal_tracer_flux_from_cubic_coefficients OUTPUTS = ("p_out_e_hybrid_2",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_out_e_hybrid_2: np.ndarray, @@ -34,7 +34,7 @@ def reference( return dict(p_out_e_hybrid_2=p_out_e_hybrid_2) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: p_out_e_hybrid_2 = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_mass_flx_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients.py index 51e4cc49d2..152b680751 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients.py @@ -24,7 +24,7 @@ class TestComputeHorizontalTracerFluxFromLinearCoefficients(stencil_tests.Stenci PROGRAM = compute_horizontal_tracer_flux_from_linear_coefficients OUTPUTS = ("p_out_e",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_lsq_coeff_1: np.ndarray, @@ -57,7 +57,7 @@ def reference( return dict(p_out_e=p_out_e) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_lsq_coeff_1 = data_alloc.random_field(grid, dims.CellDim, dims.KDim) z_lsq_coeff_2 = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients_alt.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients_alt.py index f490a7bf82..dda62abd61 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients_alt.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_horizontal_tracer_flux_from_linear_coefficients_alt.py @@ -24,7 +24,7 @@ class TestComputeHorizontalTracerFluxFromLinearCoefficientsAlt(stencil_tests.Ste PROGRAM = compute_horizontal_tracer_flux_from_linear_coefficients_alt OUTPUTS = ("p_out_e",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_lsq_coeff_1: np.ndarray, @@ -57,7 +57,7 @@ def reference( return dict(p_out_e=p_out_e) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_lsq_coeff_1 = data_alloc.random_field(grid, dims.CellDim, dims.KDim) z_lsq_coeff_2 = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_positive_definite_horizontal_multiplicative_flux_factor.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_positive_definite_horizontal_multiplicative_flux_factor.py index c6ee1ad78e..46161cfd30 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_positive_definite_horizontal_multiplicative_flux_factor.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_positive_definite_horizontal_multiplicative_flux_factor.py @@ -22,7 +22,7 @@ class TestComputePositiveDefiniteHorizontalMultiplicativeFluxFactor(stencil_test PROGRAM = compute_positive_definite_horizontal_multiplicative_flux_factor OUTPUTS = ("r_m",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], geofac_div: np.ndarray, @@ -53,7 +53,7 @@ def reference( return dict(r_m=r_m) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim) p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm4gpu_parabola_coefficients.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm4gpu_parabola_coefficients.py index ffaeefc5c6..4289622384 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm4gpu_parabola_coefficients.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm4gpu_parabola_coefficients.py @@ -24,7 +24,7 @@ class TestComputePpm4gpuParabolaCoefficients(stencil_tests.StencilTest): PROGRAM = compute_ppm4gpu_parabola_coefficients OUTPUTS = ("z_delta_q", "z_a1") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_face_up: np.ndarray, @@ -36,7 +36,7 @@ def reference( z_a1 = p_cc - 0.5 * (z_face_up + z_face_low) return dict(z_delta_q=z_delta_q, z_a1=z_a1) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_face_up = data_alloc.random_field(grid, dims.CellDim, dims.KDim) z_face_low = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_all_face_values.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_all_face_values.py index 054cb659fe..4ba32a3eaa 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_all_face_values.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_all_face_values.py @@ -25,7 +25,7 @@ class TestComputePpmAllFaceValues(stencil_tests.StencilTest): PROGRAM = compute_ppm_all_face_values OUTPUTS = ("p_face",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -49,7 +49,7 @@ def reference( p_face[:, 1:] = np.where((k[1:] == elevp1), p_cc[:, :-1], p_face[:, 1:]) return dict(p_face=p_face) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_cellhgt_mc_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quadratic_face_values.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quadratic_face_values.py index 98095dc0f1..aa9db505ab 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quadratic_face_values.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quadratic_face_values.py @@ -27,7 +27,7 @@ class TestComputePpmQuadraticFaceValues(stencil_tests.StencilTest): PROGRAM = compute_ppm_quadratic_face_values OUTPUTS = (stencil_tests.Output("p_face", refslice=outslice, gtslice=outslice),) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -42,7 +42,7 @@ def reference( ) return dict(p_face=p_face) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_face = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quartic_face_values.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quartic_face_values.py index b6192bf216..49eb39f9e5 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quartic_face_values.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_quartic_face_values.py @@ -24,7 +24,7 @@ class TestComputePpmQuarticFaceValues(stencil_tests.StencilTest): PROGRAM = compute_ppm_quartic_face_values OUTPUTS = (stencil_tests.Output("p_face", gtslice=(slice(None), slice(2, None))),) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -68,7 +68,7 @@ def reference( ) return dict(p_face=p_face) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_cellhgt_mc_now = data_alloc.random_field( diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_slope.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_slope.py index d875fd8f2c..d896ba1a61 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_slope.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_ppm_slope.py @@ -27,7 +27,7 @@ class TestComputePpmSlope(stencil_tests.StencilTest): ), ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -64,7 +64,7 @@ def reference( z_slope = np.where(k[1:-1] < elev, z_slope_a, z_slope_b) return dict(z_slope=z_slope) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_slope = data_alloc.zero_field(grid, dims.CellDim, dims.KDim) p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_tendency.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_tendency.py index 88810d6269..b6ea0b5b20 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_tendency.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_tendency.py @@ -22,7 +22,7 @@ class TestComputeTendency(stencil_tests.StencilTest): PROGRAM = compute_tendency OUTPUTS = ("opt_ddt_tracer_adv",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_tracer_now: np.ndarray, @@ -34,7 +34,7 @@ def reference( return dict(opt_ddt_tracer_adv=opt_ddt_tracer_adv) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_tracer_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_tracer_new = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_parabola_limiter_condition.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_parabola_limiter_condition.py index e881c1f702..0c8e28eaa4 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_parabola_limiter_condition.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_parabola_limiter_condition.py @@ -24,7 +24,7 @@ class TestComputeVerticalParabolaLimiterCondition(stencil_tests.StencilTest): PROGRAM = compute_vertical_parabola_limiter_condition OUTPUTS = ("l_limit",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_face: np.ndarray, @@ -36,7 +36,7 @@ def reference( l_limit = np.where(np.abs(z_delta) < -1 * z_a6i, 1, 0) return dict(l_limit=l_limit) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_face = data_alloc.random_field(grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_tracer_flux_upwind.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_tracer_flux_upwind.py index 03d40aaa52..51bea1c2ef 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_tracer_flux_upwind.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_compute_vertical_tracer_flux_upwind.py @@ -27,7 +27,7 @@ class TestComputeVerticalTracerFluxUpwind(stencil_tests.StencilTest): PROGRAM = compute_vertical_tracer_flux_upwind OUTPUTS = (stencil_tests.Output("p_upflux", refslice=outslice, gtslice=outslice),) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -41,7 +41,7 @@ def reference( ) return dict(p_upflux=p_upflux) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) p_mflx_contra_v = data_alloc.random_field( diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_density_horizontally.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_density_horizontally.py index 6bb07ba7cb..cce7be573b 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_density_horizontally.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_density_horizontally.py @@ -29,7 +29,7 @@ class TestIntegrateTracerDensityHorizontally(stencil_tests.StencilTest): "z_tracer_new_dsl", ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_mass_flx_e: np.ndarray, @@ -61,7 +61,7 @@ def reference( z_tracer_new_dsl=z_tracer_new_dsl, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_mass_flx_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_horizontally.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_horizontally.py index f1f1134f66..a1f705c8cd 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_horizontally.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_horizontally.py @@ -24,7 +24,7 @@ class TestIntegrateTracerHorizontally(stencil_tests.StencilTest): PROGRAM = integrate_tracer_horizontally OUTPUTS = ("tracer_new_hor",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_mflx_tracer_h: np.ndarray, @@ -45,7 +45,7 @@ def reference( ) / rhodz_new return dict(tracer_new_hor=tracer_new_hor) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_mflx_tracer_h = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) deepatmo_divh = data_alloc.random_field(grid, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_vertically.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_vertically.py index 6ab7a36d13..4493b6febf 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_vertically.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_integrate_tracer_vertically.py @@ -24,7 +24,7 @@ class TestIntegrateTracerVertically(stencil_tests.StencilTest): PROGRAM = integrate_tracer_vertically OUTPUTS = ("tracer_new",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], tracer_now: np.ndarray, @@ -58,7 +58,7 @@ def reference( return dict(tracer_new=tracer_new) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: tracer_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) rhodz_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_parabola_semi_monotonically.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_parabola_semi_monotonically.py index b7079d0aca..9b113a36e8 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_parabola_semi_monotonically.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_parabola_semi_monotonically.py @@ -24,7 +24,7 @@ class TestLimitVerticalParabolaSemiMonotonically(stencil_tests.StencilTest): PROGRAM = limit_vertical_parabola_semi_monotonically OUTPUTS = ("p_face_up", "p_face_low") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], l_limit: np.ndarray, @@ -47,7 +47,7 @@ def reference( ) return dict(p_face_up=q_face_up, p_face_low=q_face_low) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: l_limit = data_alloc.random_mask(grid, dims.CellDim, dims.KDim, dtype=gtx.int32) p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_slope_semi_monotonically.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_slope_semi_monotonically.py index fb32ae1f24..8e6f278f8b 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_slope_semi_monotonically.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_limit_vertical_slope_semi_monotonically.py @@ -24,7 +24,7 @@ class TestLimitVerticalSlopeSemiMonotonically(stencil_tests.StencilTest): PROGRAM = limit_vertical_slope_semi_monotonically OUTPUTS = (stencil_tests.Output("z_slope", gtslice=(slice(None), slice(1, -1))),) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -39,7 +39,7 @@ def reference( slope = np.where(z_slope[:, 1:-1] >= 0.0, slope_l, -slope_l) return dict(z_slope=slope) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) z_slope = data_alloc.random_field(grid, dims.CellDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_postprocess_antidiffusive_cell_fluxes_and_min_max.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_postprocess_antidiffusive_cell_fluxes_and_min_max.py index 9fe005d986..6d2343092f 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_postprocess_antidiffusive_cell_fluxes_and_min_max.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_postprocess_antidiffusive_cell_fluxes_and_min_max.py @@ -24,7 +24,7 @@ class TestPostprocessAntidiffusiveCellFluxesAndMinMax(stencil_tests.StencilTest) PROGRAM = postprocess_antidiffusive_cell_fluxes_and_min_max OUTPUTS = ("z_tracer_new_low", "z_tracer_max", "z_tracer_min") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], refin_ctrl: np.ndarray, @@ -54,7 +54,7 @@ def reference( z_tracer_min=z_tracer_min_out, ) - @pytest.fixture() + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: hi_bound, lo_bound = 3, 1 refin_ctrl = data_alloc.constant_field(grid, 2, dims.CellDim, dtype=gtx.int32) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_ffsl_flux_area_patches_list.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_ffsl_flux_area_patches_list.py index bc2d3c6933..af9c1c3218 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_ffsl_flux_area_patches_list.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_ffsl_flux_area_patches_list.py @@ -113,259 +113,264 @@ def _line_intersect_numpy( return intersect_1, intersect_2 -@pytest.mark.gtfn_too_slow -class TestPrepareFfslFluxAreaPatchesList(stencil_tests.StencilTest): - PROGRAM = prepare_ffsl_flux_area_patches_list - OUTPUTS = ( - "dreg_patch0_1_lon_dsl", - "dreg_patch0_1_lat_dsl", - "dreg_patch0_2_lon_dsl", - "dreg_patch0_2_lat_dsl", - "dreg_patch0_3_lon_dsl", - "dreg_patch0_3_lat_dsl", - "dreg_patch0_4_lon_dsl", - "dreg_patch0_4_lat_dsl", - "dreg_patch1_1_lon_vmask", - "dreg_patch1_1_lat_vmask", - "dreg_patch1_2_lon_vmask", - "dreg_patch1_2_lat_vmask", - "dreg_patch1_3_lon_vmask", - "dreg_patch1_3_lat_vmask", - "dreg_patch1_4_lon_vmask", - "dreg_patch1_4_lat_vmask", - "dreg_patch2_1_lon_vmask", - "dreg_patch2_1_lat_vmask", - "dreg_patch2_2_lon_vmask", - "dreg_patch2_2_lat_vmask", - "dreg_patch2_3_lon_vmask", - "dreg_patch2_3_lat_vmask", - "dreg_patch2_4_lon_vmask", - "dreg_patch2_4_lat_vmask", +# -- Reference helpers -- +def _generate_flux_area_geometry( + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, + p_vn, + ptr_v3_lon_e, + ptr_v3_lat_e, +): + arrival_pts_1_lon_dsl = dreg_patch0_1_lon_dsl + arrival_pts_1_lat_dsl = dreg_patch0_1_lat_dsl + arrival_pts_2_lon_dsl = dreg_patch0_2_lon_dsl + arrival_pts_2_lat_dsl = dreg_patch0_2_lat_dsl + depart_pts_1_lon_dsl = dreg_patch0_4_lon_dsl + depart_pts_1_lat_dsl = dreg_patch0_4_lat_dsl + depart_pts_2_lon_dsl = dreg_patch0_3_lon_dsl + depart_pts_2_lat_dsl = dreg_patch0_3_lat_dsl + + lvn_pos = p_vn >= 0.0 + + fl_line_p1_lon = depart_pts_1_lon_dsl + fl_line_p1_lat = depart_pts_1_lat_dsl + fl_line_p2_lon = depart_pts_2_lon_dsl + fl_line_p2_lat = depart_pts_2_lat_dsl + + tri_line1_p1_lon = arrival_pts_1_lon_dsl + tri_line1_p1_lat = arrival_pts_1_lat_dsl + tri_line1_p2_lon = np.where( + lvn_pos, + np.broadcast_to(ptr_v3_lon_e[:, 0], p_vn.shape), + np.broadcast_to(ptr_v3_lon_e[:, 1], p_vn.shape), + ) + tri_line1_p2_lat = np.where( + lvn_pos, + np.broadcast_to(ptr_v3_lat_e[:, 0], p_vn.shape), + np.broadcast_to(ptr_v3_lat_e[:, 1], p_vn.shape), ) - @staticmethod - def _generate_flux_area_geometry( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - p_vn, - ptr_v3_lon_e, - ptr_v3_lat_e, - ): - arrival_pts_1_lon_dsl = dreg_patch0_1_lon_dsl - arrival_pts_1_lat_dsl = dreg_patch0_1_lat_dsl - arrival_pts_2_lon_dsl = dreg_patch0_2_lon_dsl - arrival_pts_2_lat_dsl = dreg_patch0_2_lat_dsl - depart_pts_1_lon_dsl = dreg_patch0_4_lon_dsl - depart_pts_1_lat_dsl = dreg_patch0_4_lat_dsl - depart_pts_2_lon_dsl = dreg_patch0_3_lon_dsl - depart_pts_2_lat_dsl = dreg_patch0_3_lat_dsl - - lvn_pos = p_vn >= 0.0 - - fl_line_p1_lon = depart_pts_1_lon_dsl - fl_line_p1_lat = depart_pts_1_lat_dsl - fl_line_p2_lon = depart_pts_2_lon_dsl - fl_line_p2_lat = depart_pts_2_lat_dsl - - tri_line1_p1_lon = arrival_pts_1_lon_dsl - tri_line1_p1_lat = arrival_pts_1_lat_dsl - tri_line1_p2_lon = np.where( - lvn_pos, - np.broadcast_to(ptr_v3_lon_e[:, 0], p_vn.shape), - np.broadcast_to(ptr_v3_lon_e[:, 1], p_vn.shape), - ) - tri_line1_p2_lat = np.where( - lvn_pos, - np.broadcast_to(ptr_v3_lat_e[:, 0], p_vn.shape), - np.broadcast_to(ptr_v3_lat_e[:, 1], p_vn.shape), - ) - - tri_line2_p1_lon = arrival_pts_2_lon_dsl - tri_line2_p1_lat = arrival_pts_2_lat_dsl - tri_line2_p2_lon = np.where( - lvn_pos, - np.broadcast_to(ptr_v3_lon_e[:, 0], p_vn.shape), - np.broadcast_to(ptr_v3_lon_e[:, 1], p_vn.shape), - ) - tri_line2_p2_lat = np.where( - lvn_pos, - np.broadcast_to(ptr_v3_lat_e[:, 0], p_vn.shape), - np.broadcast_to(ptr_v3_lat_e[:, 1], p_vn.shape), - ) - - return ( - fl_line_p1_lon, - fl_line_p1_lat, - fl_line_p2_lon, - fl_line_p2_lat, - tri_line1_p1_lon, - tri_line1_p1_lat, - tri_line1_p2_lon, - tri_line1_p2_lat, - tri_line2_p1_lon, - tri_line2_p1_lat, - tri_line2_p2_lon, - tri_line2_p2_lat, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, - ) + tri_line2_p1_lon = arrival_pts_2_lon_dsl + tri_line2_p1_lat = arrival_pts_2_lat_dsl + tri_line2_p2_lon = np.where( + lvn_pos, + np.broadcast_to(ptr_v3_lon_e[:, 0], p_vn.shape), + np.broadcast_to(ptr_v3_lon_e[:, 1], p_vn.shape), + ) + tri_line2_p2_lat = np.where( + lvn_pos, + np.broadcast_to(ptr_v3_lat_e[:, 0], p_vn.shape), + np.broadcast_to(ptr_v3_lat_e[:, 1], p_vn.shape), + ) - @staticmethod - def _apply_case1_patch0( - mask_case1, - lvn_sys_pos, + return ( + fl_line_p1_lon, + fl_line_p1_lat, + fl_line_p2_lon, + fl_line_p2_lat, + tri_line1_p1_lon, + tri_line1_p1_lat, + tri_line1_p2_lon, + tri_line1_p2_lat, + tri_line2_p1_lon, + tri_line2_p1_lat, + tri_line2_p2_lon, + tri_line2_p2_lat, arrival_pts_1_lon_dsl, arrival_pts_1_lat_dsl, arrival_pts_2_lon_dsl, arrival_pts_2_lat_dsl, - ps1_x, - ps1_y, - ps2_x, - ps2_y, depart_pts_1_lon_dsl, depart_pts_1_lat_dsl, depart_pts_2_lon_dsl, depart_pts_2_lat_dsl, - ): - dreg_patch0_1_lon_dsl = arrival_pts_1_lon_dsl - dreg_patch0_1_lat_dsl = arrival_pts_1_lat_dsl - dreg_patch0_2_lon_dsl = np.where( - mask_case1, - np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, ps1_x), - arrival_pts_2_lon_dsl, - ) - dreg_patch0_2_lat_dsl = np.where( - mask_case1, - np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, ps1_y), - arrival_pts_2_lat_dsl, - ) - dreg_patch0_3_lon_dsl = np.where(mask_case1, ps2_x, depart_pts_2_lon_dsl) - dreg_patch0_3_lat_dsl = np.where(mask_case1, ps2_y, depart_pts_2_lat_dsl) - dreg_patch0_4_lon_dsl = np.where( - mask_case1, - np.where(lvn_sys_pos, ps1_x, arrival_pts_2_lon_dsl), - depart_pts_1_lon_dsl, - ) - dreg_patch0_4_lat_dsl = np.where( - mask_case1, - np.where(lvn_sys_pos, ps1_y, arrival_pts_2_lat_dsl), - depart_pts_1_lat_dsl, - ) + ) - return ( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - ) - @staticmethod - def _apply_case1_patch1( +def _apply_case1_patch0( + mask_case1, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + ps1_x, + ps1_y, + ps2_x, + ps2_y, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, +): + dreg_patch0_1_lon_dsl = arrival_pts_1_lon_dsl + dreg_patch0_1_lat_dsl = arrival_pts_1_lat_dsl + dreg_patch0_2_lon_dsl = np.where( mask_case1, - lvn_sys_pos, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, + np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, ps1_x), + arrival_pts_2_lon_dsl, + ) + dreg_patch0_2_lat_dsl = np.where( + mask_case1, + np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, ps1_y), + arrival_pts_2_lat_dsl, + ) + dreg_patch0_3_lon_dsl = np.where(mask_case1, ps2_x, depart_pts_2_lon_dsl) + dreg_patch0_3_lat_dsl = np.where(mask_case1, ps2_y, depart_pts_2_lat_dsl) + dreg_patch0_4_lon_dsl = np.where( + mask_case1, + np.where(lvn_sys_pos, ps1_x, arrival_pts_2_lon_dsl), depart_pts_1_lon_dsl, + ) + dreg_patch0_4_lat_dsl = np.where( + mask_case1, + np.where(lvn_sys_pos, ps1_y, arrival_pts_2_lat_dsl), depart_pts_1_lat_dsl, - ps1_x, - ps1_y, - ): - dreg_patch1_1_lon_vmask = np.where(mask_case1, arrival_pts_1_lon_dsl, 0.0) - dreg_patch1_1_lat_vmask = np.where(mask_case1, arrival_pts_1_lat_dsl, 0.0) - dreg_patch1_4_lon_vmask = np.where(mask_case1, arrival_pts_1_lon_dsl, 0.0) - dreg_patch1_4_lat_vmask = np.where(mask_case1, arrival_pts_1_lat_dsl, 0.0) - dreg_patch1_2_lon_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, ps1_x, depart_pts_1_lon_dsl), 0.0 - ) - dreg_patch1_2_lat_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, ps1_y, depart_pts_1_lat_dsl), 0.0 - ) - dreg_patch1_3_lon_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, depart_pts_1_lon_dsl, ps1_x), 0.0 - ) - dreg_patch1_3_lat_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, depart_pts_1_lat_dsl, ps1_y), 0.0 - ) + ) - return ( - dreg_patch1_1_lon_vmask, - dreg_patch1_1_lat_vmask, - dreg_patch1_4_lon_vmask, - dreg_patch1_4_lat_vmask, - dreg_patch1_2_lon_vmask, - dreg_patch1_2_lat_vmask, - dreg_patch1_3_lon_vmask, - dreg_patch1_3_lat_vmask, - ) + return ( + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, + ) - @staticmethod - def _apply_case1_patch2( - mask_case1, - lvn_sys_pos, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, - ps2_x, - ps2_y, - ): - # Case 1 - patch 2 - dreg_patch2_1_lon_vmask = np.where(mask_case1, arrival_pts_2_lon_dsl, 0.0) - dreg_patch2_1_lat_vmask = np.where(mask_case1, arrival_pts_2_lat_dsl, 0.0) - dreg_patch2_4_lon_vmask = np.where(mask_case1, arrival_pts_2_lon_dsl, 0.0) - dreg_patch2_4_lat_vmask = np.where(mask_case1, arrival_pts_2_lat_dsl, 0.0) - dreg_patch2_2_lon_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, depart_pts_2_lon_dsl, ps2_x), 0.0 - ) - dreg_patch2_2_lat_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, depart_pts_2_lat_dsl, ps2_y), 0.0 - ) - dreg_patch2_3_lon_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, ps2_x, depart_pts_2_lon_dsl), 0.0 - ) - dreg_patch2_3_lat_vmask = np.where( - mask_case1, np.where(lvn_sys_pos, ps2_y, depart_pts_2_lat_dsl), 0.0 - ) - return ( - dreg_patch2_1_lon_vmask, - dreg_patch2_1_lat_vmask, - dreg_patch2_4_lon_vmask, - dreg_patch2_4_lat_vmask, - dreg_patch2_2_lon_vmask, - dreg_patch2_2_lat_vmask, - dreg_patch2_3_lon_vmask, - dreg_patch2_3_lat_vmask, - ) +def _apply_case1_patch1( + mask_case1, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + ps1_x, + ps1_y, +): + dreg_patch1_1_lon_vmask = np.where(mask_case1, arrival_pts_1_lon_dsl, 0.0) + dreg_patch1_1_lat_vmask = np.where(mask_case1, arrival_pts_1_lat_dsl, 0.0) + dreg_patch1_4_lon_vmask = np.where(mask_case1, arrival_pts_1_lon_dsl, 0.0) + dreg_patch1_4_lat_vmask = np.where(mask_case1, arrival_pts_1_lat_dsl, 0.0) + dreg_patch1_2_lon_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, ps1_x, depart_pts_1_lon_dsl), 0.0 + ) + dreg_patch1_2_lat_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, ps1_y, depart_pts_1_lat_dsl), 0.0 + ) + dreg_patch1_3_lon_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, depart_pts_1_lon_dsl, ps1_x), 0.0 + ) + dreg_patch1_3_lat_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, depart_pts_1_lat_dsl, ps1_y), 0.0 + ) + + return ( + dreg_patch1_1_lon_vmask, + dreg_patch1_1_lat_vmask, + dreg_patch1_4_lon_vmask, + dreg_patch1_4_lat_vmask, + dreg_patch1_2_lon_vmask, + dreg_patch1_2_lat_vmask, + dreg_patch1_3_lon_vmask, + dreg_patch1_3_lat_vmask, + ) + + +def _apply_case1_patch2( + mask_case1, + lvn_sys_pos, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, + ps2_x, + ps2_y, +): + # Case 1 - patch 2 + dreg_patch2_1_lon_vmask = np.where(mask_case1, arrival_pts_2_lon_dsl, 0.0) + dreg_patch2_1_lat_vmask = np.where(mask_case1, arrival_pts_2_lat_dsl, 0.0) + dreg_patch2_4_lon_vmask = np.where(mask_case1, arrival_pts_2_lon_dsl, 0.0) + dreg_patch2_4_lat_vmask = np.where(mask_case1, arrival_pts_2_lat_dsl, 0.0) + dreg_patch2_2_lon_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, depart_pts_2_lon_dsl, ps2_x), 0.0 + ) + dreg_patch2_2_lat_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, depart_pts_2_lat_dsl, ps2_y), 0.0 + ) + dreg_patch2_3_lon_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, ps2_x, depart_pts_2_lon_dsl), 0.0 + ) + dreg_patch2_3_lat_vmask = np.where( + mask_case1, np.where(lvn_sys_pos, ps2_y, depart_pts_2_lat_dsl), 0.0 + ) + + return ( + dreg_patch2_1_lon_vmask, + dreg_patch2_1_lat_vmask, + dreg_patch2_4_lon_vmask, + dreg_patch2_4_lat_vmask, + dreg_patch2_2_lon_vmask, + dreg_patch2_2_lat_vmask, + dreg_patch2_3_lon_vmask, + dreg_patch2_3_lat_vmask, + ) + - @staticmethod - def _apply_case2a_patch0( +def _apply_case2a_patch0( + mask_case2a, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + ps1_x, + ps1_y, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, +): + dreg_patch0_1_lon_dsl = np.where(mask_case2a, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) + dreg_patch0_1_lat_dsl = np.where(mask_case2a, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) + dreg_patch0_2_lon_dsl = np.where( mask_case2a, - lvn_sys_pos, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - ps1_x, - ps1_y, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, + np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, ps1_x), + dreg_patch0_2_lon_dsl, + ) + dreg_patch0_2_lat_dsl = np.where( + mask_case2a, + np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, ps1_y), + dreg_patch0_2_lat_dsl, + ) + dreg_patch0_3_lon_dsl = np.where(mask_case2a, depart_pts_2_lon_dsl, dreg_patch0_3_lon_dsl) + dreg_patch0_3_lat_dsl = np.where(mask_case2a, depart_pts_2_lat_dsl, dreg_patch0_3_lat_dsl) + dreg_patch0_4_lon_dsl = np.where( + mask_case2a, + np.where(lvn_sys_pos, ps1_x, arrival_pts_2_lon_dsl), + dreg_patch0_4_lon_dsl, + ) + dreg_patch0_4_lat_dsl = np.where( + mask_case2a, + np.where(lvn_sys_pos, ps1_y, arrival_pts_2_lat_dsl), + dreg_patch0_4_lat_dsl, + ) + + return ( dreg_patch0_1_lon_dsl, dreg_patch0_1_lat_dsl, dreg_patch0_2_lon_dsl, @@ -374,53 +379,53 @@ def _apply_case2a_patch0( dreg_patch0_3_lat_dsl, dreg_patch0_4_lon_dsl, dreg_patch0_4_lat_dsl, - ): - dreg_patch0_1_lon_dsl = np.where(mask_case2a, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) - dreg_patch0_1_lat_dsl = np.where(mask_case2a, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) - dreg_patch0_2_lon_dsl = np.where( - mask_case2a, - np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, ps1_x), - dreg_patch0_2_lon_dsl, - ) - dreg_patch0_2_lat_dsl = np.where( - mask_case2a, - np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, ps1_y), - dreg_patch0_2_lat_dsl, - ) - dreg_patch0_3_lon_dsl = np.where(mask_case2a, depart_pts_2_lon_dsl, dreg_patch0_3_lon_dsl) - dreg_patch0_3_lat_dsl = np.where(mask_case2a, depart_pts_2_lat_dsl, dreg_patch0_3_lat_dsl) - dreg_patch0_4_lon_dsl = np.where( - mask_case2a, - np.where(lvn_sys_pos, ps1_x, arrival_pts_2_lon_dsl), - dreg_patch0_4_lon_dsl, - ) - dreg_patch0_4_lat_dsl = np.where( - mask_case2a, - np.where(lvn_sys_pos, ps1_y, arrival_pts_2_lat_dsl), - dreg_patch0_4_lat_dsl, - ) + ) - return ( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - ) - @staticmethod - def _apply_case2a_patch1( +def _apply_case2a_patch1( + mask_case2a, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + ps1_x, + ps1_y, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + dreg_patch1_1_lon_vmask, + dreg_patch1_1_lat_vmask, + dreg_patch1_4_lon_vmask, + dreg_patch1_4_lat_vmask, + dreg_patch1_2_lon_vmask, + dreg_patch1_2_lat_vmask, + dreg_patch1_3_lon_vmask, + dreg_patch1_3_lat_vmask, +): + dreg_patch1_1_lon_vmask = np.where(mask_case2a, arrival_pts_1_lon_dsl, dreg_patch1_1_lon_vmask) + dreg_patch1_1_lat_vmask = np.where(mask_case2a, arrival_pts_1_lat_dsl, dreg_patch1_1_lat_vmask) + dreg_patch1_4_lon_vmask = np.where(mask_case2a, arrival_pts_1_lon_dsl, dreg_patch1_4_lon_vmask) + dreg_patch1_4_lat_vmask = np.where(mask_case2a, arrival_pts_1_lat_dsl, dreg_patch1_4_lat_vmask) + dreg_patch1_2_lon_vmask = np.where( mask_case2a, - lvn_sys_pos, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - ps1_x, - ps1_y, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, + np.where(lvn_sys_pos, ps1_x, depart_pts_1_lon_dsl), + dreg_patch1_2_lon_vmask, + ) + dreg_patch1_2_lat_vmask = np.where( + mask_case2a, + np.where(lvn_sys_pos, ps1_y, depart_pts_1_lat_dsl), + dreg_patch1_2_lat_vmask, + ) + dreg_patch1_3_lon_vmask = np.where( + mask_case2a, + np.where(lvn_sys_pos, depart_pts_1_lon_dsl, ps1_x), + dreg_patch1_3_lon_vmask, + ) + dreg_patch1_3_lat_vmask = np.where( + mask_case2a, + np.where(lvn_sys_pos, depart_pts_1_lat_dsl, ps1_y), + dreg_patch1_3_lat_vmask, + ) + + return ( dreg_patch1_1_lon_vmask, dreg_patch1_1_lat_vmask, dreg_patch1_4_lon_vmask, @@ -429,63 +434,55 @@ def _apply_case2a_patch1( dreg_patch1_2_lat_vmask, dreg_patch1_3_lon_vmask, dreg_patch1_3_lat_vmask, - ): - dreg_patch1_1_lon_vmask = np.where( - mask_case2a, arrival_pts_1_lon_dsl, dreg_patch1_1_lon_vmask - ) - dreg_patch1_1_lat_vmask = np.where( - mask_case2a, arrival_pts_1_lat_dsl, dreg_patch1_1_lat_vmask - ) - dreg_patch1_4_lon_vmask = np.where( - mask_case2a, arrival_pts_1_lon_dsl, dreg_patch1_4_lon_vmask - ) - dreg_patch1_4_lat_vmask = np.where( - mask_case2a, arrival_pts_1_lat_dsl, dreg_patch1_4_lat_vmask - ) - dreg_patch1_2_lon_vmask = np.where( - mask_case2a, - np.where(lvn_sys_pos, ps1_x, depart_pts_1_lon_dsl), - dreg_patch1_2_lon_vmask, - ) - dreg_patch1_2_lat_vmask = np.where( - mask_case2a, - np.where(lvn_sys_pos, ps1_y, depart_pts_1_lat_dsl), - dreg_patch1_2_lat_vmask, - ) - dreg_patch1_3_lon_vmask = np.where( - mask_case2a, - np.where(lvn_sys_pos, depart_pts_1_lon_dsl, ps1_x), - dreg_patch1_3_lon_vmask, - ) - dreg_patch1_3_lat_vmask = np.where( - mask_case2a, - np.where(lvn_sys_pos, depart_pts_1_lat_dsl, ps1_y), - dreg_patch1_3_lat_vmask, - ) + ) - return ( - dreg_patch1_1_lon_vmask, - dreg_patch1_1_lat_vmask, - dreg_patch1_4_lon_vmask, - dreg_patch1_4_lat_vmask, - dreg_patch1_2_lon_vmask, - dreg_patch1_2_lat_vmask, - dreg_patch1_3_lon_vmask, - dreg_patch1_3_lat_vmask, - ) - @staticmethod - def _apply_case2b_patch0( +def _apply_case2b_patch0( + mask_case2b, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + ps2_x, + ps2_y, + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, +): + dreg_patch0_1_lon_dsl = np.where(mask_case2b, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) + dreg_patch0_1_lat_dsl = np.where(mask_case2b, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) + dreg_patch0_2_lon_dsl = np.where( mask_case2b, - lvn_sys_pos, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, - ps2_x, - ps2_y, + np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, depart_pts_1_lon_dsl), + dreg_patch0_2_lon_dsl, + ) + dreg_patch0_2_lat_dsl = np.where( + mask_case2b, + np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, depart_pts_1_lat_dsl), + dreg_patch0_2_lat_dsl, + ) + dreg_patch0_3_lon_dsl = np.where(mask_case2b, ps2_x, dreg_patch0_3_lon_dsl) + dreg_patch0_3_lat_dsl = np.where(mask_case2b, ps2_y, dreg_patch0_3_lat_dsl) + dreg_patch0_4_lon_dsl = np.where( + mask_case2b, + np.where(lvn_sys_pos, depart_pts_1_lon_dsl, arrival_pts_2_lon_dsl), + dreg_patch0_4_lon_dsl, + ) + dreg_patch0_4_lat_dsl = np.where( + mask_case2b, + np.where(lvn_sys_pos, depart_pts_1_lat_dsl, arrival_pts_2_lat_dsl), + dreg_patch0_4_lat_dsl, + ) + + return ( dreg_patch0_1_lon_dsl, dreg_patch0_1_lat_dsl, dreg_patch0_2_lon_dsl, @@ -494,46 +491,32 @@ def _apply_case2b_patch0( dreg_patch0_3_lat_dsl, dreg_patch0_4_lon_dsl, dreg_patch0_4_lat_dsl, - ): - dreg_patch0_1_lon_dsl = np.where(mask_case2b, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) - dreg_patch0_1_lat_dsl = np.where(mask_case2b, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) - dreg_patch0_2_lon_dsl = np.where( - mask_case2b, - np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, depart_pts_1_lon_dsl), - dreg_patch0_2_lon_dsl, - ) - dreg_patch0_2_lat_dsl = np.where( - mask_case2b, - np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, depart_pts_1_lat_dsl), - dreg_patch0_2_lat_dsl, - ) - dreg_patch0_3_lon_dsl = np.where(mask_case2b, ps2_x, dreg_patch0_3_lon_dsl) - dreg_patch0_3_lat_dsl = np.where(mask_case2b, ps2_y, dreg_patch0_3_lat_dsl) - dreg_patch0_4_lon_dsl = np.where( - mask_case2b, - np.where(lvn_sys_pos, depart_pts_1_lon_dsl, arrival_pts_2_lon_dsl), - dreg_patch0_4_lon_dsl, - ) - dreg_patch0_4_lat_dsl = np.where( - mask_case2b, - np.where(lvn_sys_pos, depart_pts_1_lat_dsl, arrival_pts_2_lat_dsl), - dreg_patch0_4_lat_dsl, - ) + ) - return ( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - ) - @staticmethod - def _apply_case2b_patch1( - mask_case2b, +def _apply_case2b_patch1( + mask_case2b, + dreg_patch1_1_lon_vmask, + dreg_patch1_1_lat_vmask, + dreg_patch1_2_lon_vmask, + dreg_patch1_2_lat_vmask, + dreg_patch1_3_lon_vmask, + dreg_patch1_3_lat_vmask, + dreg_patch1_4_lon_vmask, + dreg_patch1_4_lat_vmask, +): + zeros_array = np.zeros_like(mask_case2b) + + dreg_patch1_1_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_1_lon_vmask) + dreg_patch1_1_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_1_lat_vmask) + dreg_patch1_2_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_2_lon_vmask) + dreg_patch1_2_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_2_lat_vmask) + dreg_patch1_3_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_3_lon_vmask) + dreg_patch1_3_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_3_lat_vmask) + dreg_patch1_4_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_4_lon_vmask) + dreg_patch1_4_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_4_lat_vmask) + + return ( dreg_patch1_1_lon_vmask, dreg_patch1_1_lat_vmask, dreg_patch1_2_lon_vmask, @@ -542,39 +525,53 @@ def _apply_case2b_patch1( dreg_patch1_3_lat_vmask, dreg_patch1_4_lon_vmask, dreg_patch1_4_lat_vmask, - ): - zeros_array = np.zeros_like(mask_case2b) - - dreg_patch1_1_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_1_lon_vmask) - dreg_patch1_1_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_1_lat_vmask) - dreg_patch1_2_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_2_lon_vmask) - dreg_patch1_2_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_2_lat_vmask) - dreg_patch1_3_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_3_lon_vmask) - dreg_patch1_3_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_3_lat_vmask) - dreg_patch1_4_lon_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_4_lon_vmask) - dreg_patch1_4_lat_vmask = np.where(mask_case2b, zeros_array, dreg_patch1_4_lat_vmask) - - return ( - dreg_patch1_1_lon_vmask, - dreg_patch1_1_lat_vmask, - dreg_patch1_2_lon_vmask, - dreg_patch1_2_lat_vmask, - dreg_patch1_3_lon_vmask, - dreg_patch1_3_lat_vmask, - dreg_patch1_4_lon_vmask, - dreg_patch1_4_lat_vmask, - ) + ) - @staticmethod - def _apply_case2b_patch2( + +def _apply_case2b_patch2( + mask_case2b, + lvn_sys_pos, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, + ps2_x, + ps2_y, + dreg_patch2_1_lon_vmask, + dreg_patch2_1_lat_vmask, + dreg_patch2_4_lon_vmask, + dreg_patch2_4_lat_vmask, + dreg_patch2_2_lon_vmask, + dreg_patch2_2_lat_vmask, + dreg_patch2_3_lon_vmask, + dreg_patch2_3_lat_vmask, +): + dreg_patch2_1_lon_vmask = np.where(mask_case2b, arrival_pts_2_lon_dsl, dreg_patch2_1_lon_vmask) + dreg_patch2_1_lat_vmask = np.where(mask_case2b, arrival_pts_2_lat_dsl, dreg_patch2_1_lat_vmask) + dreg_patch2_4_lon_vmask = np.where(mask_case2b, arrival_pts_2_lon_dsl, dreg_patch2_4_lon_vmask) + dreg_patch2_4_lat_vmask = np.where(mask_case2b, arrival_pts_2_lat_dsl, dreg_patch2_4_lat_vmask) + dreg_patch2_2_lon_vmask = np.where( mask_case2b, - lvn_sys_pos, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, - ps2_x, - ps2_y, + np.where(lvn_sys_pos, depart_pts_2_lon_dsl, ps2_x), + dreg_patch2_2_lon_vmask, + ) + dreg_patch2_2_lat_vmask = np.where( + mask_case2b, + np.where(lvn_sys_pos, depart_pts_2_lat_dsl, ps2_y), + dreg_patch2_2_lat_vmask, + ) + dreg_patch2_3_lon_vmask = np.where( + mask_case2b, + np.where(lvn_sys_pos, ps2_x, depart_pts_2_lon_dsl), + dreg_patch2_3_lon_vmask, + ) + dreg_patch2_3_lat_vmask = np.where( + mask_case2b, + np.where(lvn_sys_pos, ps2_y, depart_pts_2_lat_dsl), + dreg_patch2_3_lat_vmask, + ) + + return ( dreg_patch2_1_lon_vmask, dreg_patch2_1_lat_vmask, dreg_patch2_4_lon_vmask, @@ -583,63 +580,55 @@ def _apply_case2b_patch2( dreg_patch2_2_lat_vmask, dreg_patch2_3_lon_vmask, dreg_patch2_3_lat_vmask, - ): - dreg_patch2_1_lon_vmask = np.where( - mask_case2b, arrival_pts_2_lon_dsl, dreg_patch2_1_lon_vmask - ) - dreg_patch2_1_lat_vmask = np.where( - mask_case2b, arrival_pts_2_lat_dsl, dreg_patch2_1_lat_vmask - ) - dreg_patch2_4_lon_vmask = np.where( - mask_case2b, arrival_pts_2_lon_dsl, dreg_patch2_4_lon_vmask - ) - dreg_patch2_4_lat_vmask = np.where( - mask_case2b, arrival_pts_2_lat_dsl, dreg_patch2_4_lat_vmask - ) - dreg_patch2_2_lon_vmask = np.where( - mask_case2b, - np.where(lvn_sys_pos, depart_pts_2_lon_dsl, ps2_x), - dreg_patch2_2_lon_vmask, - ) - dreg_patch2_2_lat_vmask = np.where( - mask_case2b, - np.where(lvn_sys_pos, depart_pts_2_lat_dsl, ps2_y), - dreg_patch2_2_lat_vmask, - ) - dreg_patch2_3_lon_vmask = np.where( - mask_case2b, - np.where(lvn_sys_pos, ps2_x, depart_pts_2_lon_dsl), - dreg_patch2_3_lon_vmask, - ) - dreg_patch2_3_lat_vmask = np.where( - mask_case2b, - np.where(lvn_sys_pos, ps2_y, depart_pts_2_lat_dsl), - dreg_patch2_3_lat_vmask, - ) + ) - return ( - dreg_patch2_1_lon_vmask, - dreg_patch2_1_lat_vmask, - dreg_patch2_4_lon_vmask, - dreg_patch2_4_lat_vmask, - dreg_patch2_2_lon_vmask, - dreg_patch2_2_lat_vmask, - dreg_patch2_3_lon_vmask, - dreg_patch2_3_lat_vmask, - ) - @staticmethod - def _apply_case3a_patch0( +def _apply_case3a_patch0( + mask_case3a, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + lvn_sys_pos, + ps2_x, + ps2_y, + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, +): + dreg_patch0_1_lon_dsl = np.where(mask_case3a, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) + dreg_patch0_1_lat_dsl = np.where(mask_case3a, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) + dreg_patch0_2_lon_dsl = np.where( mask_case3a, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, - lvn_sys_pos, - ps2_x, - ps2_y, + np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, depart_pts_1_lon_dsl), + dreg_patch0_2_lon_dsl, + ) + dreg_patch0_2_lat_dsl = np.where( + mask_case3a, + np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, depart_pts_1_lat_dsl), + dreg_patch0_2_lat_dsl, + ) + dreg_patch0_3_lon_dsl = np.where(mask_case3a, ps2_x, dreg_patch0_3_lon_dsl) + dreg_patch0_3_lat_dsl = np.where(mask_case3a, ps2_y, dreg_patch0_3_lat_dsl) + dreg_patch0_4_lon_dsl = np.where( + mask_case3a, + np.where(lvn_sys_pos, depart_pts_1_lon_dsl, arrival_pts_2_lon_dsl), + dreg_patch0_4_lon_dsl, + ) + dreg_patch0_4_lat_dsl = np.where( + mask_case3a, + np.where(lvn_sys_pos, depart_pts_1_lat_dsl, arrival_pts_2_lat_dsl), + dreg_patch0_4_lat_dsl, + ) + + return ( dreg_patch0_1_lon_dsl, dreg_patch0_1_lat_dsl, dreg_patch0_2_lon_dsl, @@ -648,55 +637,55 @@ def _apply_case3a_patch0( dreg_patch0_3_lat_dsl, dreg_patch0_4_lon_dsl, dreg_patch0_4_lat_dsl, - ): - dreg_patch0_1_lon_dsl = np.where(mask_case3a, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) - dreg_patch0_1_lat_dsl = np.where(mask_case3a, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) - dreg_patch0_2_lon_dsl = np.where( - mask_case3a, - np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, depart_pts_1_lon_dsl), - dreg_patch0_2_lon_dsl, - ) - dreg_patch0_2_lat_dsl = np.where( - mask_case3a, - np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, depart_pts_1_lat_dsl), - dreg_patch0_2_lat_dsl, - ) - dreg_patch0_3_lon_dsl = np.where(mask_case3a, ps2_x, dreg_patch0_3_lon_dsl) - dreg_patch0_3_lat_dsl = np.where(mask_case3a, ps2_y, dreg_patch0_3_lat_dsl) - dreg_patch0_4_lon_dsl = np.where( - mask_case3a, - np.where(lvn_sys_pos, depart_pts_1_lon_dsl, arrival_pts_2_lon_dsl), - dreg_patch0_4_lon_dsl, - ) - dreg_patch0_4_lat_dsl = np.where( - mask_case3a, - np.where(lvn_sys_pos, depart_pts_1_lat_dsl, arrival_pts_2_lat_dsl), - dreg_patch0_4_lat_dsl, - ) + ) - return ( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - ) - @staticmethod - def _apply_case3a_patch1( +def _apply_case3a_patch1( + mask_case3a, + lvn_sys_pos, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + pi1_x, + pi1_y, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, + dreg_patch1_1_lon_vmask, + dreg_patch1_1_lat_vmask, + dreg_patch1_4_lon_vmask, + dreg_patch1_4_lat_vmask, + dreg_patch1_2_lon_vmask, + dreg_patch1_2_lat_vmask, + dreg_patch1_3_lon_vmask, + dreg_patch1_3_lat_vmask, +): + dreg_patch1_1_lon_vmask = np.where(mask_case3a, arrival_pts_1_lon_dsl, dreg_patch1_1_lon_vmask) + dreg_patch1_1_lat_vmask = np.where(mask_case3a, arrival_pts_1_lat_dsl, dreg_patch1_1_lat_vmask) + dreg_patch1_2_lon_vmask = np.where( mask_case3a, - lvn_sys_pos, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - pi1_x, - pi1_y, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, + np.where(lvn_sys_pos, pi1_x, depart_pts_2_lon_dsl), + dreg_patch1_2_lon_vmask, + ) + dreg_patch1_2_lat_vmask = np.where( + mask_case3a, + np.where(lvn_sys_pos, pi1_y, depart_pts_2_lat_dsl), + dreg_patch1_2_lat_vmask, + ) + dreg_patch1_3_lon_vmask = np.where(mask_case3a, depart_pts_1_lon_dsl, dreg_patch1_3_lon_vmask) + dreg_patch1_3_lat_vmask = np.where(mask_case3a, depart_pts_1_lat_dsl, dreg_patch1_3_lat_vmask) + dreg_patch1_4_lon_vmask = np.where( + mask_case3a, + np.where(lvn_sys_pos, depart_pts_1_lon_dsl, pi1_x), + dreg_patch1_4_lon_vmask, + ) + dreg_patch1_4_lat_vmask = np.where( + mask_case3a, + np.where(lvn_sys_pos, depart_pts_1_lat_dsl, pi1_y), + dreg_patch1_4_lat_vmask, + ) + + return ( dreg_patch1_1_lon_vmask, dreg_patch1_1_lat_vmask, dreg_patch1_4_lon_vmask, @@ -705,61 +694,53 @@ def _apply_case3a_patch1( dreg_patch1_2_lat_vmask, dreg_patch1_3_lon_vmask, dreg_patch1_3_lat_vmask, - ): - dreg_patch1_1_lon_vmask = np.where( - mask_case3a, arrival_pts_1_lon_dsl, dreg_patch1_1_lon_vmask - ) - dreg_patch1_1_lat_vmask = np.where( - mask_case3a, arrival_pts_1_lat_dsl, dreg_patch1_1_lat_vmask - ) - dreg_patch1_2_lon_vmask = np.where( - mask_case3a, - np.where(lvn_sys_pos, pi1_x, depart_pts_2_lon_dsl), - dreg_patch1_2_lon_vmask, - ) - dreg_patch1_2_lat_vmask = np.where( - mask_case3a, - np.where(lvn_sys_pos, pi1_y, depart_pts_2_lat_dsl), - dreg_patch1_2_lat_vmask, - ) - dreg_patch1_3_lon_vmask = np.where( - mask_case3a, depart_pts_1_lon_dsl, dreg_patch1_3_lon_vmask - ) - dreg_patch1_3_lat_vmask = np.where( - mask_case3a, depart_pts_1_lat_dsl, dreg_patch1_3_lat_vmask - ) - dreg_patch1_4_lon_vmask = np.where( - mask_case3a, - np.where(lvn_sys_pos, depart_pts_1_lon_dsl, pi1_x), - dreg_patch1_4_lon_vmask, - ) - dreg_patch1_4_lat_vmask = np.where( - mask_case3a, - np.where(lvn_sys_pos, depart_pts_1_lat_dsl, pi1_y), - dreg_patch1_4_lat_vmask, - ) + ) - return ( - dreg_patch1_1_lon_vmask, - dreg_patch1_1_lat_vmask, - dreg_patch1_4_lon_vmask, - dreg_patch1_4_lat_vmask, - dreg_patch1_2_lon_vmask, - dreg_patch1_2_lat_vmask, - dreg_patch1_3_lon_vmask, - dreg_patch1_3_lat_vmask, - ) - @staticmethod - def _apply_case3b_patch0( +def _apply_case3b_patch0( + mask_case3b, + arrival_pts_1_lon_dsl, + arrival_pts_1_lat_dsl, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + pi2_x, + pi2_y, + lvn_sys_pos, + dreg_patch0_1_lon_dsl, + dreg_patch0_1_lat_dsl, + dreg_patch0_4_lon_dsl, + dreg_patch0_4_lat_dsl, + dreg_patch0_2_lon_dsl, + dreg_patch0_2_lat_dsl, + dreg_patch0_3_lon_dsl, + dreg_patch0_3_lat_dsl, +): + dreg_patch0_1_lon_dsl = np.where(mask_case3b, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) + dreg_patch0_1_lat_dsl = np.where(mask_case3b, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) + dreg_patch0_4_lon_dsl = np.where(mask_case3b, arrival_pts_1_lon_dsl, dreg_patch0_4_lon_dsl) + dreg_patch0_4_lat_dsl = np.where(mask_case3b, arrival_pts_1_lat_dsl, dreg_patch0_4_lat_dsl) + dreg_patch0_2_lon_dsl = np.where( mask_case3b, - arrival_pts_1_lon_dsl, - arrival_pts_1_lat_dsl, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - pi2_x, - pi2_y, - lvn_sys_pos, + np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, pi2_x), + dreg_patch0_2_lon_dsl, + ) + dreg_patch0_2_lat_dsl = np.where( + mask_case3b, + np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, pi2_y), + dreg_patch0_2_lat_dsl, + ) + dreg_patch0_3_lon_dsl = np.where( + mask_case3b, + np.where(lvn_sys_pos, pi2_x, arrival_pts_2_lon_dsl), + dreg_patch0_3_lon_dsl, + ) + dreg_patch0_3_lat_dsl = np.where( + mask_case3b, + np.where(lvn_sys_pos, pi2_y, arrival_pts_2_lat_dsl), + dreg_patch0_3_lat_dsl, + ) + + return ( dreg_patch0_1_lon_dsl, dreg_patch0_1_lat_dsl, dreg_patch0_4_lon_dsl, @@ -768,55 +749,55 @@ def _apply_case3b_patch0( dreg_patch0_2_lat_dsl, dreg_patch0_3_lon_dsl, dreg_patch0_3_lat_dsl, - ): - dreg_patch0_1_lon_dsl = np.where(mask_case3b, arrival_pts_1_lon_dsl, dreg_patch0_1_lon_dsl) - dreg_patch0_1_lat_dsl = np.where(mask_case3b, arrival_pts_1_lat_dsl, dreg_patch0_1_lat_dsl) - dreg_patch0_4_lon_dsl = np.where(mask_case3b, arrival_pts_1_lon_dsl, dreg_patch0_4_lon_dsl) - dreg_patch0_4_lat_dsl = np.where(mask_case3b, arrival_pts_1_lat_dsl, dreg_patch0_4_lat_dsl) - dreg_patch0_2_lon_dsl = np.where( - mask_case3b, - np.where(lvn_sys_pos, arrival_pts_2_lon_dsl, pi2_x), - dreg_patch0_2_lon_dsl, - ) - dreg_patch0_2_lat_dsl = np.where( - mask_case3b, - np.where(lvn_sys_pos, arrival_pts_2_lat_dsl, pi2_y), - dreg_patch0_2_lat_dsl, - ) - dreg_patch0_3_lon_dsl = np.where( - mask_case3b, - np.where(lvn_sys_pos, pi2_x, arrival_pts_2_lon_dsl), - dreg_patch0_3_lon_dsl, - ) - dreg_patch0_3_lat_dsl = np.where( - mask_case3b, - np.where(lvn_sys_pos, pi2_y, arrival_pts_2_lat_dsl), - dreg_patch0_3_lat_dsl, - ) + ) - return ( - dreg_patch0_1_lon_dsl, - dreg_patch0_1_lat_dsl, - dreg_patch0_4_lon_dsl, - dreg_patch0_4_lat_dsl, - dreg_patch0_2_lon_dsl, - dreg_patch0_2_lat_dsl, - dreg_patch0_3_lon_dsl, - dreg_patch0_3_lat_dsl, - ) - @staticmethod - def _apply_case3b_patch2( +def _apply_case3b_patch2( + mask_case3b, + arrival_pts_2_lon_dsl, + arrival_pts_2_lat_dsl, + depart_pts_1_lon_dsl, + depart_pts_1_lat_dsl, + depart_pts_2_lon_dsl, + depart_pts_2_lat_dsl, + pi2_x, + pi2_y, + lvn_sys_pos, + dreg_patch2_1_lon_vmask, + dreg_patch2_1_lat_vmask, + dreg_patch2_2_lon_vmask, + dreg_patch2_2_lat_vmask, + dreg_patch2_3_lon_vmask, + dreg_patch2_3_lat_vmask, + dreg_patch2_4_lon_vmask, + dreg_patch2_4_lat_vmask, +): + dreg_patch2_1_lon_vmask = np.where(mask_case3b, arrival_pts_2_lon_dsl, dreg_patch2_1_lon_vmask) + dreg_patch2_1_lat_vmask = np.where(mask_case3b, arrival_pts_2_lat_dsl, dreg_patch2_1_lat_vmask) + dreg_patch2_2_lon_vmask = np.where( mask_case3b, - arrival_pts_2_lon_dsl, - arrival_pts_2_lat_dsl, - depart_pts_1_lon_dsl, - depart_pts_1_lat_dsl, - depart_pts_2_lon_dsl, - depart_pts_2_lat_dsl, - pi2_x, - pi2_y, - lvn_sys_pos, + np.where(lvn_sys_pos, depart_pts_2_lon_dsl, pi2_x), + dreg_patch2_2_lon_vmask, + ) + dreg_patch2_2_lat_vmask = np.where( + mask_case3b, + np.where(lvn_sys_pos, depart_pts_2_lat_dsl, pi2_y), + dreg_patch2_2_lat_vmask, + ) + dreg_patch2_3_lon_vmask = np.where(mask_case3b, depart_pts_1_lon_dsl, dreg_patch2_3_lon_vmask) + dreg_patch2_3_lat_vmask = np.where(mask_case3b, depart_pts_1_lat_dsl, dreg_patch2_3_lat_vmask) + dreg_patch2_4_lon_vmask = np.where( + mask_case3b, + np.where(lvn_sys_pos, pi2_x, depart_pts_2_lon_dsl), + dreg_patch2_4_lon_vmask, + ) + dreg_patch2_4_lat_vmask = np.where( + mask_case3b, + np.where(lvn_sys_pos, pi2_y, depart_pts_2_lat_dsl), + dreg_patch2_4_lat_vmask, + ) + + return ( dreg_patch2_1_lon_vmask, dreg_patch2_1_lat_vmask, dreg_patch2_2_lon_vmask, @@ -825,54 +806,41 @@ def _apply_case3b_patch2( dreg_patch2_3_lat_vmask, dreg_patch2_4_lon_vmask, dreg_patch2_4_lat_vmask, - ): - dreg_patch2_1_lon_vmask = np.where( - mask_case3b, arrival_pts_2_lon_dsl, dreg_patch2_1_lon_vmask - ) - dreg_patch2_1_lat_vmask = np.where( - mask_case3b, arrival_pts_2_lat_dsl, dreg_patch2_1_lat_vmask - ) - dreg_patch2_2_lon_vmask = np.where( - mask_case3b, - np.where(lvn_sys_pos, depart_pts_2_lon_dsl, pi2_x), - dreg_patch2_2_lon_vmask, - ) - dreg_patch2_2_lat_vmask = np.where( - mask_case3b, - np.where(lvn_sys_pos, depart_pts_2_lat_dsl, pi2_y), - dreg_patch2_2_lat_vmask, - ) - dreg_patch2_3_lon_vmask = np.where( - mask_case3b, depart_pts_1_lon_dsl, dreg_patch2_3_lon_vmask - ) - dreg_patch2_3_lat_vmask = np.where( - mask_case3b, depart_pts_1_lat_dsl, dreg_patch2_3_lat_vmask - ) - dreg_patch2_4_lon_vmask = np.where( - mask_case3b, - np.where(lvn_sys_pos, pi2_x, depart_pts_2_lon_dsl), - dreg_patch2_4_lon_vmask, - ) - dreg_patch2_4_lat_vmask = np.where( - mask_case3b, - np.where(lvn_sys_pos, pi2_y, depart_pts_2_lat_dsl), - dreg_patch2_4_lat_vmask, - ) + ) - return ( - dreg_patch2_1_lon_vmask, - dreg_patch2_1_lat_vmask, - dreg_patch2_2_lon_vmask, - dreg_patch2_2_lat_vmask, - dreg_patch2_3_lon_vmask, - dreg_patch2_3_lat_vmask, - dreg_patch2_4_lon_vmask, - dreg_patch2_4_lat_vmask, - ) - @classmethod +@pytest.mark.gtfn_too_slow +class TestPrepareFfslFluxAreaPatchesList(stencil_tests.StencilTest): + PROGRAM = prepare_ffsl_flux_area_patches_list + OUTPUTS = ( + "dreg_patch0_1_lon_dsl", + "dreg_patch0_1_lat_dsl", + "dreg_patch0_2_lon_dsl", + "dreg_patch0_2_lat_dsl", + "dreg_patch0_3_lon_dsl", + "dreg_patch0_3_lat_dsl", + "dreg_patch0_4_lon_dsl", + "dreg_patch0_4_lat_dsl", + "dreg_patch1_1_lon_vmask", + "dreg_patch1_1_lat_vmask", + "dreg_patch1_2_lon_vmask", + "dreg_patch1_2_lat_vmask", + "dreg_patch1_3_lon_vmask", + "dreg_patch1_3_lat_vmask", + "dreg_patch1_4_lon_vmask", + "dreg_patch1_4_lat_vmask", + "dreg_patch2_1_lon_vmask", + "dreg_patch2_1_lat_vmask", + "dreg_patch2_2_lon_vmask", + "dreg_patch2_2_lat_vmask", + "dreg_patch2_3_lon_vmask", + "dreg_patch2_3_lat_vmask", + "dreg_patch2_4_lon_vmask", + "dreg_patch2_4_lat_vmask", + ) + + @stencil_tests.static_reference def reference( - cls, connectivities: dict[gtx.Dimension, np.ndarray], famask_int, p_vn, @@ -893,7 +861,7 @@ def reference( ptr_v3_lat_e = np.expand_dims(ptr_v3_lat, axis=-1) tangent_orientation_dsl = np.expand_dims(tangent_orientation_dsl, axis=-1) - result_tuple = cls._generate_flux_area_geometry( + result_tuple = _generate_flux_area_geometry( dreg_patch0_1_lon_dsl, dreg_patch0_1_lat_dsl, dreg_patch0_2_lon_dsl, @@ -992,7 +960,7 @@ def reference( dreg_patch0_3_lat_dsl, dreg_patch0_4_lon_dsl, dreg_patch0_4_lat_dsl, - ) = cls._apply_case1_patch0( + ) = _apply_case1_patch0( mask_case1, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1018,7 +986,7 @@ def reference( dreg_patch1_2_lat_vmask, dreg_patch1_3_lon_vmask, dreg_patch1_3_lat_vmask, - ) = cls._apply_case1_patch1( + ) = _apply_case1_patch1( mask_case1, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1038,7 +1006,7 @@ def reference( dreg_patch2_2_lat_vmask, dreg_patch2_3_lon_vmask, dreg_patch2_3_lat_vmask, - ) = cls._apply_case1_patch2( + ) = _apply_case1_patch2( mask_case1, lvn_sys_pos, arrival_pts_2_lon_dsl, @@ -1051,10 +1019,14 @@ def reference( # ------------------------------------------------- Case 2a mask_case2a = np.logical_and.reduce( - [lintersect_line1, np.logical_not(lintersect_line2), famask_bool] + [ + lintersect_line1, + np.logical_not(lintersect_line2), + famask_bool, + ] ) # Case 2a - patch 0 - result_tuple_patch0 = cls._apply_case2a_patch0( + result_tuple_patch0 = _apply_case2a_patch0( mask_case2a, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1086,7 +1058,7 @@ def reference( dreg_patch0_4_lat_dsl, ) = result_tuple_patch0 # Case 2a - patch 1 - result_tuple_patch1 = cls._apply_case2a_patch1( + result_tuple_patch1 = _apply_case2a_patch1( mask_case2a, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1127,10 +1099,14 @@ def reference( # -------------------------------------------------- Case 2b mask_case2b = np.logical_and.reduce( - [lintersect_line2, np.logical_not(lintersect_line1), famask_bool] + [ + lintersect_line2, + np.logical_not(lintersect_line1), + famask_bool, + ] ) # Case 2b - patch 0 - result_tuple_patch0_case2b = cls._apply_case2b_patch0( + result_tuple_patch0_case2b = _apply_case2b_patch0( mask_case2b, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1163,7 +1139,7 @@ def reference( ) = result_tuple_patch0_case2b # Case 2b - patch 1 - result_tuple_patch1_case2b = cls._apply_case2b_patch1( + result_tuple_patch1_case2b = _apply_case2b_patch1( mask_case2b, dreg_patch1_1_lon_vmask, dreg_patch1_1_lat_vmask, @@ -1187,7 +1163,7 @@ def reference( ) = result_tuple_patch1_case2b # Case 2b - patch 2 - result_tuple_patch2_case2b = cls._apply_case2b_patch2( + result_tuple_patch2_case2b = _apply_case2b_patch2( mask_case2b, lvn_sys_pos, arrival_pts_2_lon_dsl, @@ -1251,7 +1227,7 @@ def reference( tri_line1_p2_lat, ) # Case 3a - patch 0 - result = cls._apply_case3a_patch0( + result = _apply_case3a_patch0( mask_case3a, arrival_pts_1_lon_dsl, arrival_pts_1_lat_dsl, @@ -1293,7 +1269,7 @@ def reference( dreg_patch1_2_lat_vmask, dreg_patch1_3_lon_vmask, dreg_patch1_3_lat_vmask, - ) = cls._apply_case3a_patch1( + ) = _apply_case3a_patch1( mask_case3a, lvn_sys_pos, arrival_pts_1_lon_dsl, @@ -1356,7 +1332,7 @@ def reference( dreg_patch0_2_lat_dsl, dreg_patch0_3_lon_dsl, dreg_patch0_3_lat_dsl, - ) = cls._apply_case3b_patch0( + ) = _apply_case3b_patch0( mask_case3b, arrival_pts_1_lon_dsl, arrival_pts_1_lat_dsl, @@ -1394,7 +1370,7 @@ def reference( dreg_patch2_3_lat_vmask, dreg_patch2_4_lon_vmask, dreg_patch2_4_lat_vmask, - ) = cls._apply_case3b_patch2( + ) = _apply_case3b_patch2( mask_case3b, arrival_pts_2_lon_dsl, arrival_pts_2_lat_dsl, @@ -1418,11 +1394,20 @@ def reference( # NB: Next line acts as the "ELSE IF", indices that already previously matched one of the above conditions # can't be overwritten by this new condition. indices_previously_matched = np.logical_or.reduce( - [mask_case3b, mask_case3a, mask_case2b, mask_case2a, mask_case1] + [ + mask_case3b, + mask_case3a, + mask_case2b, + mask_case2a, + mask_case1, + ] ) # mask_case4 = (abs(p_vn) < 0.1) & famask_bool & (not indices_previously_matched) we insert also the error indices mask_case4 = np.logical_and.reduce( - [famask_bool, np.logical_not(indices_previously_matched)] + [ + famask_bool, + np.logical_not(indices_previously_matched), + ] ) # Case 4 - patch 0 - no change # Case 4 - patch 1 @@ -1470,7 +1455,7 @@ def reference( dreg_patch2_4_lat_vmask=dreg_patch2_4_lat_vmask, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid) -> dict: famask_int = data_alloc.random_mask(grid, dims.EdgeDim, dims.KDim, dtype=gtx.int32) p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_for_cubic_reconstruction.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_for_cubic_reconstruction.py index efe12e6b23..633103de42 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_for_cubic_reconstruction.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_for_cubic_reconstruction.py @@ -20,244 +20,214 @@ from icon4py.model.testing import stencil_tests -class TestPrepareNumericalQuadratureForCubicReconstruction(stencil_tests.StencilTest): - PROGRAM = prepare_numerical_quadrature_for_cubic_reconstruction - OUTPUTS = ( - "p_quad_vector_sum_1", - "p_quad_vector_sum_2", - "p_quad_vector_sum_3", - "p_quad_vector_sum_4", - "p_quad_vector_sum_5", - "p_quad_vector_sum_6", - "p_quad_vector_sum_7", - "p_quad_vector_sum_8", - "p_quad_vector_sum_9", - "p_quad_vector_sum_10", - "p_dreg_area_out", - ) +# -- Reference helpers -- - @staticmethod - def _compute_wgt_t_detjac( - wgt_zeta_1, - wgt_zeta_2, - wgt_eta_1, - wgt_eta_2, - dbl_eps, - p_coords_dreg_v_1_x, - p_coords_dreg_v_2_x, - p_coords_dreg_v_3_x, - p_coords_dreg_v_4_x, - p_coords_dreg_v_1_y, - p_coords_dreg_v_2_y, - p_coords_dreg_v_3_y, - p_coords_dreg_v_4_y, - zeta_1, - zeta_2, - zeta_3, - zeta_4, - eta_1, - eta_2, - eta_3, - eta_4, - ): - # Compute z_wgt - z_wgt_1 = 0.0625 * wgt_zeta_1 * wgt_eta_1 - z_wgt_2 = 0.0625 * wgt_zeta_1 * wgt_eta_2 - z_wgt_3 = 0.0625 * wgt_zeta_2 * wgt_eta_1 - z_wgt_4 = 0.0625 * wgt_zeta_2 * wgt_eta_2 - # Compute z_eta - z_eta_1_1, z_eta_2_1, z_eta_3_1, z_eta_4_1 = ( - 1.0 - eta_1, - 1.0 - eta_2, - 1.0 - eta_3, - 1.0 - eta_4, - ) - z_eta_1_2, z_eta_2_2, z_eta_3_2, z_eta_4_2 = ( - 1.0 + eta_1, - 1.0 + eta_2, - 1.0 + eta_3, - 1.0 + eta_4, +def _compute_wgt_t_detjac( + wgt_zeta_1, + wgt_zeta_2, + wgt_eta_1, + wgt_eta_2, + dbl_eps, + p_coords_dreg_v_1_x, + p_coords_dreg_v_2_x, + p_coords_dreg_v_3_x, + p_coords_dreg_v_4_x, + p_coords_dreg_v_1_y, + p_coords_dreg_v_2_y, + p_coords_dreg_v_3_y, + p_coords_dreg_v_4_y, + zeta_1, + zeta_2, + zeta_3, + zeta_4, + eta_1, + eta_2, + eta_3, + eta_4, +): + # Compute z_wgt + z_wgt_1 = 0.0625 * wgt_zeta_1 * wgt_eta_1 + z_wgt_2 = 0.0625 * wgt_zeta_1 * wgt_eta_2 + z_wgt_3 = 0.0625 * wgt_zeta_2 * wgt_eta_1 + z_wgt_4 = 0.0625 * wgt_zeta_2 * wgt_eta_2 + + # Compute z_eta + z_eta_1_1, z_eta_2_1, z_eta_3_1, z_eta_4_1 = ( + 1.0 - eta_1, + 1.0 - eta_2, + 1.0 - eta_3, + 1.0 - eta_4, + ) + z_eta_1_2, z_eta_2_2, z_eta_3_2, z_eta_4_2 = ( + 1.0 + eta_1, + 1.0 + eta_2, + 1.0 + eta_3, + 1.0 + eta_4, + ) + z_eta_1_3, z_eta_2_3, z_eta_3_3, z_eta_4_3 = ( + 1.0 - zeta_1, + 1.0 - zeta_2, + 1.0 - zeta_3, + 1.0 - zeta_4, + ) + z_eta_1_4, z_eta_2_4, z_eta_3_4, z_eta_4_4 = ( + 1.0 + zeta_1, + 1.0 + zeta_2, + 1.0 + zeta_3, + 1.0 + zeta_4, + ) + + wgt_t_detjac_1 = dbl_eps + z_wgt_1 * ( + ( + z_eta_1_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_1_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) ) - z_eta_1_3, z_eta_2_3, z_eta_3_3, z_eta_4_3 = ( - 1.0 - zeta_1, - 1.0 - zeta_2, - 1.0 - zeta_3, - 1.0 - zeta_4, + * ( + z_eta_1_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_1_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) ) - z_eta_1_4, z_eta_2_4, z_eta_3_4, z_eta_4_4 = ( - 1.0 + zeta_1, - 1.0 + zeta_2, - 1.0 + zeta_3, - 1.0 + zeta_4, + - ( + z_eta_1_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_1_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) ) - - wgt_t_detjac_1 = dbl_eps + z_wgt_1 * ( - ( - z_eta_1_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_1_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_1_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_1_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_1_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_1_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_1_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_1_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) + * ( + z_eta_1_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_1_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) ) - wgt_t_detjac_2 = dbl_eps + z_wgt_2 * ( - ( - z_eta_2_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_2_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_2_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_2_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_2_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_2_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_2_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_2_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) + ) + wgt_t_detjac_2 = dbl_eps + z_wgt_2 * ( + ( + z_eta_2_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_2_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) ) - wgt_t_detjac_3 = dbl_eps + z_wgt_3 * ( - ( - z_eta_3_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_3_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_3_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_3_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_3_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_3_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_3_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_3_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) + * ( + z_eta_2_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_2_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) ) - wgt_t_detjac_4 = dbl_eps + z_wgt_4 * ( - ( - z_eta_4_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_4_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_4_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_4_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_4_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_4_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_4_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_4_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) + - ( + z_eta_2_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_2_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) ) - return wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 - - @staticmethod - def _compute_z_gauss_points( - p_coords_dreg_v_1_x, - p_coords_dreg_v_2_x, - p_coords_dreg_v_3_x, - p_coords_dreg_v_4_x, - p_coords_dreg_v_1_y, - p_coords_dreg_v_2_y, - p_coords_dreg_v_3_y, - p_coords_dreg_v_4_y, - shape_func_1_1, - shape_func_2_1, - shape_func_3_1, - shape_func_4_1, - shape_func_1_2, - shape_func_2_2, - shape_func_3_2, - shape_func_4_2, - shape_func_1_3, - shape_func_2_3, - shape_func_3_3, - shape_func_4_3, - shape_func_1_4, - shape_func_2_4, - shape_func_3_4, - shape_func_4_4, - ): - z_gauss_pts_1_x = ( - shape_func_1_1 * p_coords_dreg_v_1_x - + shape_func_2_1 * p_coords_dreg_v_2_x - + shape_func_3_1 * p_coords_dreg_v_3_x - + shape_func_4_1 * p_coords_dreg_v_4_x + * ( + z_eta_2_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_2_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) ) - z_gauss_pts_1_y = ( - shape_func_1_1 * p_coords_dreg_v_1_y - + shape_func_2_1 * p_coords_dreg_v_2_y - + shape_func_3_1 * p_coords_dreg_v_3_y - + shape_func_4_1 * p_coords_dreg_v_4_y + ) + wgt_t_detjac_3 = dbl_eps + z_wgt_3 * ( + ( + z_eta_3_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_3_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) ) - z_gauss_pts_2_x = ( - shape_func_1_2 * p_coords_dreg_v_1_x - + shape_func_2_2 * p_coords_dreg_v_2_x - + shape_func_3_2 * p_coords_dreg_v_3_x - + shape_func_4_2 * p_coords_dreg_v_4_x + * ( + z_eta_3_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_3_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) ) - z_gauss_pts_2_y = ( - shape_func_1_2 * p_coords_dreg_v_1_y - + shape_func_2_2 * p_coords_dreg_v_2_y - + shape_func_3_2 * p_coords_dreg_v_3_y - + shape_func_4_2 * p_coords_dreg_v_4_y + - ( + z_eta_3_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_3_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) ) - z_gauss_pts_3_x = ( - shape_func_1_3 * p_coords_dreg_v_1_x - + shape_func_2_3 * p_coords_dreg_v_2_x - + shape_func_3_3 * p_coords_dreg_v_3_x - + shape_func_4_3 * p_coords_dreg_v_4_x + * ( + z_eta_3_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_3_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) ) - z_gauss_pts_3_y = ( - shape_func_1_3 * p_coords_dreg_v_1_y - + shape_func_2_3 * p_coords_dreg_v_2_y - + shape_func_3_3 * p_coords_dreg_v_3_y - + shape_func_4_3 * p_coords_dreg_v_4_y + ) + wgt_t_detjac_4 = dbl_eps + z_wgt_4 * ( + ( + z_eta_4_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_4_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) ) - z_gauss_pts_4_x = ( - shape_func_1_4 * p_coords_dreg_v_1_x - + shape_func_2_4 * p_coords_dreg_v_2_x - + shape_func_3_4 * p_coords_dreg_v_3_x - + shape_func_4_4 * p_coords_dreg_v_4_x + * ( + z_eta_4_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_4_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) ) - z_gauss_pts_4_y = ( - shape_func_1_4 * p_coords_dreg_v_1_y - + shape_func_2_4 * p_coords_dreg_v_2_y - + shape_func_3_4 * p_coords_dreg_v_3_y - + shape_func_4_4 * p_coords_dreg_v_4_y + - ( + z_eta_4_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_4_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) ) - return ( - z_gauss_pts_1_x, - z_gauss_pts_1_y, - z_gauss_pts_2_x, - z_gauss_pts_2_y, - z_gauss_pts_3_x, - z_gauss_pts_3_y, - z_gauss_pts_4_x, - z_gauss_pts_4_y, + * ( + z_eta_4_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_4_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) ) + ) + return wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 + - @staticmethod - def _compute_vector_sums( - wgt_t_detjac_1, - wgt_t_detjac_2, - wgt_t_detjac_3, - wgt_t_detjac_4, +def _compute_z_gauss_points( + p_coords_dreg_v_1_x, + p_coords_dreg_v_2_x, + p_coords_dreg_v_3_x, + p_coords_dreg_v_4_x, + p_coords_dreg_v_1_y, + p_coords_dreg_v_2_y, + p_coords_dreg_v_3_y, + p_coords_dreg_v_4_y, + shape_func_1_1, + shape_func_2_1, + shape_func_3_1, + shape_func_4_1, + shape_func_1_2, + shape_func_2_2, + shape_func_3_2, + shape_func_4_2, + shape_func_1_3, + shape_func_2_3, + shape_func_3_3, + shape_func_4_3, + shape_func_1_4, + shape_func_2_4, + shape_func_3_4, + shape_func_4_4, +): + z_gauss_pts_1_x = ( + shape_func_1_1 * p_coords_dreg_v_1_x + + shape_func_2_1 * p_coords_dreg_v_2_x + + shape_func_3_1 * p_coords_dreg_v_3_x + + shape_func_4_1 * p_coords_dreg_v_4_x + ) + z_gauss_pts_1_y = ( + shape_func_1_1 * p_coords_dreg_v_1_y + + shape_func_2_1 * p_coords_dreg_v_2_y + + shape_func_3_1 * p_coords_dreg_v_3_y + + shape_func_4_1 * p_coords_dreg_v_4_y + ) + z_gauss_pts_2_x = ( + shape_func_1_2 * p_coords_dreg_v_1_x + + shape_func_2_2 * p_coords_dreg_v_2_x + + shape_func_3_2 * p_coords_dreg_v_3_x + + shape_func_4_2 * p_coords_dreg_v_4_x + ) + z_gauss_pts_2_y = ( + shape_func_1_2 * p_coords_dreg_v_1_y + + shape_func_2_2 * p_coords_dreg_v_2_y + + shape_func_3_2 * p_coords_dreg_v_3_y + + shape_func_4_2 * p_coords_dreg_v_4_y + ) + z_gauss_pts_3_x = ( + shape_func_1_3 * p_coords_dreg_v_1_x + + shape_func_2_3 * p_coords_dreg_v_2_x + + shape_func_3_3 * p_coords_dreg_v_3_x + + shape_func_4_3 * p_coords_dreg_v_4_x + ) + z_gauss_pts_3_y = ( + shape_func_1_3 * p_coords_dreg_v_1_y + + shape_func_2_3 * p_coords_dreg_v_2_y + + shape_func_3_3 * p_coords_dreg_v_3_y + + shape_func_4_3 * p_coords_dreg_v_4_y + ) + z_gauss_pts_4_x = ( + shape_func_1_4 * p_coords_dreg_v_1_x + + shape_func_2_4 * p_coords_dreg_v_2_x + + shape_func_3_4 * p_coords_dreg_v_3_x + + shape_func_4_4 * p_coords_dreg_v_4_x + ) + z_gauss_pts_4_y = ( + shape_func_1_4 * p_coords_dreg_v_1_y + + shape_func_2_4 * p_coords_dreg_v_2_y + + shape_func_3_4 * p_coords_dreg_v_3_y + + shape_func_4_4 * p_coords_dreg_v_4_y + ) + return ( z_gauss_pts_1_x, z_gauss_pts_1_y, z_gauss_pts_2_x, @@ -266,78 +236,110 @@ def _compute_vector_sums( z_gauss_pts_3_y, z_gauss_pts_4_x, z_gauss_pts_4_y, - ): - p_quad_vector_sum_1 = wgt_t_detjac_1 + wgt_t_detjac_2 + wgt_t_detjac_3 + wgt_t_detjac_4 - p_quad_vector_sum_2 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x - ) - p_quad_vector_sum_3 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y - ) - p_quad_vector_sum_4 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x - ) - p_quad_vector_sum_5 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - p_quad_vector_sum_6 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y - ) - p_quad_vector_sum_7 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_x - ) - p_quad_vector_sum_8 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - p_quad_vector_sum_9 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_y - ) - p_quad_vector_sum_10 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - return ( - p_quad_vector_sum_1, - p_quad_vector_sum_2, - p_quad_vector_sum_3, - p_quad_vector_sum_4, - p_quad_vector_sum_5, - p_quad_vector_sum_6, - p_quad_vector_sum_7, - p_quad_vector_sum_8, - p_quad_vector_sum_9, - p_quad_vector_sum_10, - ) + ) + + +def _compute_vector_sums( + wgt_t_detjac_1, + wgt_t_detjac_2, + wgt_t_detjac_3, + wgt_t_detjac_4, + z_gauss_pts_1_x, + z_gauss_pts_1_y, + z_gauss_pts_2_x, + z_gauss_pts_2_y, + z_gauss_pts_3_x, + z_gauss_pts_3_y, + z_gauss_pts_4_x, + z_gauss_pts_4_y, +): + p_quad_vector_sum_1 = wgt_t_detjac_1 + wgt_t_detjac_2 + wgt_t_detjac_3 + wgt_t_detjac_4 + p_quad_vector_sum_2 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x + ) + p_quad_vector_sum_3 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y + ) + p_quad_vector_sum_4 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x + ) + p_quad_vector_sum_5 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + p_quad_vector_sum_6 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y + ) + p_quad_vector_sum_7 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_x + ) + p_quad_vector_sum_8 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + p_quad_vector_sum_9 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_y + ) + p_quad_vector_sum_10 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + return ( + p_quad_vector_sum_1, + p_quad_vector_sum_2, + p_quad_vector_sum_3, + p_quad_vector_sum_4, + p_quad_vector_sum_5, + p_quad_vector_sum_6, + p_quad_vector_sum_7, + p_quad_vector_sum_8, + p_quad_vector_sum_9, + p_quad_vector_sum_10, + ) + + +class TestPrepareNumericalQuadratureForCubicReconstruction(stencil_tests.StencilTest): + PROGRAM = prepare_numerical_quadrature_for_cubic_reconstruction + OUTPUTS = ( + "p_quad_vector_sum_1", + "p_quad_vector_sum_2", + "p_quad_vector_sum_3", + "p_quad_vector_sum_4", + "p_quad_vector_sum_5", + "p_quad_vector_sum_6", + "p_quad_vector_sum_7", + "p_quad_vector_sum_8", + "p_quad_vector_sum_9", + "p_quad_vector_sum_10", + "p_dreg_area_out", + ) - @classmethod + @stencil_tests.static_reference def reference( - cls, connectivities: dict[gtx.Dimension, np.ndarray], p_coords_dreg_v_1_x: np.ndarray, p_coords_dreg_v_2_x: np.ndarray, @@ -379,7 +381,7 @@ def reference( eps: float, **kwargs: Any, ) -> dict: - wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 = cls._compute_wgt_t_detjac( + wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 = _compute_wgt_t_detjac( wgt_zeta_1, wgt_zeta_2, wgt_eta_1, @@ -412,7 +414,7 @@ def reference( z_gauss_pts_3_y, z_gauss_pts_4_x, z_gauss_pts_4_y, - ) = cls._compute_z_gauss_points( + ) = _compute_z_gauss_points( p_coords_dreg_v_1_x, p_coords_dreg_v_2_x, p_coords_dreg_v_3_x, @@ -450,7 +452,7 @@ def reference( p_quad_vector_sum_8, p_quad_vector_sum_9, p_quad_vector_sum_10, - ) = cls._compute_vector_sums( + ) = _compute_vector_sums( wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, @@ -485,7 +487,7 @@ def reference( p_dreg_area_out=p_dreg_area_out, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_coords_dreg_v_1_x = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) p_coords_dreg_v_2_x = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_list_for_cubic_reconstruction.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_list_for_cubic_reconstruction.py index 66b376c37a..416fdccf2f 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_list_for_cubic_reconstruction.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_prepare_numerical_quadrature_list_for_cubic_reconstruction.py @@ -20,281 +20,251 @@ from icon4py.model.testing import stencil_tests -class TestPrepareNumericalQuadratureListForCubicReconstruction(stencil_tests.StencilTest): - PROGRAM = prepare_numerical_quadrature_list_for_cubic_reconstruction - OUTPUTS = ( - "p_quad_vector_sum_1", - "p_quad_vector_sum_2", - "p_quad_vector_sum_3", - "p_quad_vector_sum_4", - "p_quad_vector_sum_5", - "p_quad_vector_sum_6", - "p_quad_vector_sum_7", - "p_quad_vector_sum_8", - "p_quad_vector_sum_9", - "p_quad_vector_sum_10", - "p_dreg_area", - ) +# -- Reference helpers -- - @staticmethod - def _compute_wgt_t_detjac( - p_coords_dreg_v_1_x, - p_coords_dreg_v_2_x, - p_coords_dreg_v_3_x, - p_coords_dreg_v_4_x, - p_coords_dreg_v_1_y, - p_coords_dreg_v_2_y, - p_coords_dreg_v_3_y, - p_coords_dreg_v_4_y, - wgt_zeta_1, - wgt_eta_1, - wgt_zeta_2, - wgt_eta_2, - eta_1, - eta_2, - eta_3, - eta_4, - zeta_1, - zeta_2, - zeta_3, - zeta_4, - famask_int, - dbl_eps, - ): - z_wgt_1 = 0.0625 * wgt_zeta_1 * wgt_eta_1 - z_wgt_2 = 0.0625 * wgt_zeta_1 * wgt_eta_2 - z_wgt_3 = 0.0625 * wgt_zeta_2 * wgt_eta_1 - z_wgt_4 = 0.0625 * wgt_zeta_2 * wgt_eta_2 - z_eta_1_1, z_eta_2_1, z_eta_3_1, z_eta_4_1 = ( - 1.0 - eta_1, - 1.0 - eta_2, - 1.0 - eta_3, - 1.0 - eta_4, - ) - z_eta_1_2, z_eta_2_2, z_eta_3_2, z_eta_4_2 = ( - 1.0 + eta_1, - 1.0 + eta_2, - 1.0 + eta_3, - 1.0 + eta_4, - ) - z_eta_1_3, z_eta_2_3, z_eta_3_3, z_eta_4_3 = ( - 1.0 - zeta_1, - 1.0 - zeta_2, - 1.0 - zeta_3, - 1.0 - zeta_4, - ) - z_eta_1_4, z_eta_2_4, z_eta_3_4, z_eta_4_4 = ( - 1.0 + zeta_1, - 1.0 + zeta_2, - 1.0 + zeta_3, - 1.0 + zeta_4, - ) +def _compute_wgt_t_detjac( + p_coords_dreg_v_1_x, + p_coords_dreg_v_2_x, + p_coords_dreg_v_3_x, + p_coords_dreg_v_4_x, + p_coords_dreg_v_1_y, + p_coords_dreg_v_2_y, + p_coords_dreg_v_3_y, + p_coords_dreg_v_4_y, + wgt_zeta_1, + wgt_eta_1, + wgt_zeta_2, + wgt_eta_2, + eta_1, + eta_2, + eta_3, + eta_4, + zeta_1, + zeta_2, + zeta_3, + zeta_4, + famask_int, + dbl_eps, +): + z_wgt_1 = 0.0625 * wgt_zeta_1 * wgt_eta_1 + z_wgt_2 = 0.0625 * wgt_zeta_1 * wgt_eta_2 + z_wgt_3 = 0.0625 * wgt_zeta_2 * wgt_eta_1 + z_wgt_4 = 0.0625 * wgt_zeta_2 * wgt_eta_2 + + z_eta_1_1, z_eta_2_1, z_eta_3_1, z_eta_4_1 = ( + 1.0 - eta_1, + 1.0 - eta_2, + 1.0 - eta_3, + 1.0 - eta_4, + ) + z_eta_1_2, z_eta_2_2, z_eta_3_2, z_eta_4_2 = ( + 1.0 + eta_1, + 1.0 + eta_2, + 1.0 + eta_3, + 1.0 + eta_4, + ) + z_eta_1_3, z_eta_2_3, z_eta_3_3, z_eta_4_3 = ( + 1.0 - zeta_1, + 1.0 - zeta_2, + 1.0 - zeta_3, + 1.0 - zeta_4, + ) + z_eta_1_4, z_eta_2_4, z_eta_3_4, z_eta_4_4 = ( + 1.0 + zeta_1, + 1.0 + zeta_2, + 1.0 + zeta_3, + 1.0 + zeta_4, + ) - famask_bool = np.where(famask_int == 1, True, False) + famask_bool = np.where(famask_int == 1, True, False) - p_coords_dreg_v_1_x = np.where(famask_bool, p_coords_dreg_v_1_x, 0.0) - p_coords_dreg_v_2_x = np.where(famask_bool, p_coords_dreg_v_2_x, 0.0) - p_coords_dreg_v_3_x = np.where(famask_bool, p_coords_dreg_v_3_x, 0.0) - p_coords_dreg_v_4_x = np.where(famask_bool, p_coords_dreg_v_4_x, 0.0) - p_coords_dreg_v_1_y = np.where(famask_bool, p_coords_dreg_v_1_y, 0.0) - p_coords_dreg_v_2_y = np.where(famask_bool, p_coords_dreg_v_2_y, 0.0) - p_coords_dreg_v_3_y = np.where(famask_bool, p_coords_dreg_v_3_y, 0.0) - p_coords_dreg_v_4_y = np.where(famask_bool, p_coords_dreg_v_4_y, 0.0) + p_coords_dreg_v_1_x = np.where(famask_bool, p_coords_dreg_v_1_x, 0.0) + p_coords_dreg_v_2_x = np.where(famask_bool, p_coords_dreg_v_2_x, 0.0) + p_coords_dreg_v_3_x = np.where(famask_bool, p_coords_dreg_v_3_x, 0.0) + p_coords_dreg_v_4_x = np.where(famask_bool, p_coords_dreg_v_4_x, 0.0) + p_coords_dreg_v_1_y = np.where(famask_bool, p_coords_dreg_v_1_y, 0.0) + p_coords_dreg_v_2_y = np.where(famask_bool, p_coords_dreg_v_2_y, 0.0) + p_coords_dreg_v_3_y = np.where(famask_bool, p_coords_dreg_v_3_y, 0.0) + p_coords_dreg_v_4_y = np.where(famask_bool, p_coords_dreg_v_4_y, 0.0) - wgt_t_detjac_1 = np.where( - famask_bool, - dbl_eps - + z_wgt_1 + wgt_t_detjac_1 = np.where( + famask_bool, + dbl_eps + + z_wgt_1 + * ( + ( + z_eta_1_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_1_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) + ) * ( - ( - z_eta_1_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_1_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_1_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_1_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_1_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_1_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_1_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_1_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) - ), - 0.0, - ) + z_eta_1_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_1_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) + ) + - ( + z_eta_1_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_1_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) + ) + * ( + z_eta_1_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_1_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) + ) + ), + 0.0, + ) - wgt_t_detjac_2 = np.where( - famask_bool, - dbl_eps - + z_wgt_2 + wgt_t_detjac_2 = np.where( + famask_bool, + dbl_eps + + z_wgt_2 + * ( + ( + z_eta_2_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_2_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) + ) * ( - ( - z_eta_2_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_2_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_2_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_2_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_2_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_2_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_2_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_2_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) - ), - 0.0, - ) + z_eta_2_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_2_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) + ) + - ( + z_eta_2_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_2_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) + ) + * ( + z_eta_2_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_2_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) + ) + ), + 0.0, + ) - wgt_t_detjac_3 = np.where( - famask_bool, - dbl_eps - + z_wgt_3 + wgt_t_detjac_3 = np.where( + famask_bool, + dbl_eps + + z_wgt_3 + * ( + ( + z_eta_3_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_3_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) + ) * ( - ( - z_eta_3_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_3_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_3_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_3_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_3_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_3_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_3_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_3_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) - ), - 0.0, - ) - wgt_t_detjac_4 = np.where( - famask_bool, - dbl_eps - + z_wgt_4 + z_eta_3_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_3_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) + ) + - ( + z_eta_3_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_3_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) + ) * ( - ( - z_eta_4_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) - + z_eta_4_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) - ) - * ( - z_eta_4_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) - - z_eta_4_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) - ) - - ( - z_eta_4_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) - + z_eta_4_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) - ) - * ( - z_eta_4_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) - - z_eta_4_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) - ) - ), - 0.0, - ) + z_eta_3_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_3_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) + ) + ), + 0.0, + ) + wgt_t_detjac_4 = np.where( + famask_bool, + dbl_eps + + z_wgt_4 + * ( + ( + z_eta_4_1 * (p_coords_dreg_v_2_x - p_coords_dreg_v_1_x) + + z_eta_4_2 * (p_coords_dreg_v_3_x - p_coords_dreg_v_4_x) + ) + * ( + z_eta_4_3 * (p_coords_dreg_v_4_y - p_coords_dreg_v_1_y) + - z_eta_4_4 * (p_coords_dreg_v_2_y - p_coords_dreg_v_3_y) + ) + - ( + z_eta_4_1 * (p_coords_dreg_v_2_y - p_coords_dreg_v_1_y) + + z_eta_4_2 * (p_coords_dreg_v_3_y - p_coords_dreg_v_4_y) + ) + * ( + z_eta_4_3 * (p_coords_dreg_v_4_x - p_coords_dreg_v_1_x) + - z_eta_4_4 * (p_coords_dreg_v_2_x - p_coords_dreg_v_3_x) + ) + ), + 0.0, + ) - return wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 + return wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 - @staticmethod - def _compute_z_gauss_points( - p_coords_dreg_v_1_x, - p_coords_dreg_v_2_x, - p_coords_dreg_v_3_x, - p_coords_dreg_v_4_x, - p_coords_dreg_v_1_y, - p_coords_dreg_v_2_y, - p_coords_dreg_v_3_y, - p_coords_dreg_v_4_y, - shape_func_1_1, - shape_func_2_1, - shape_func_3_1, - shape_func_4_1, - shape_func_1_2, - shape_func_2_2, - shape_func_3_2, - shape_func_4_2, - shape_func_1_3, - shape_func_2_3, - shape_func_3_3, - shape_func_4_3, - shape_func_1_4, - shape_func_2_4, - shape_func_3_4, - shape_func_4_4, - ): - z_gauss_pts_1_x = ( - shape_func_1_1 * p_coords_dreg_v_1_x - + shape_func_2_1 * p_coords_dreg_v_2_x - + shape_func_3_1 * p_coords_dreg_v_3_x - + shape_func_4_1 * p_coords_dreg_v_4_x - ) - z_gauss_pts_1_y = ( - shape_func_1_1 * p_coords_dreg_v_1_y - + shape_func_2_1 * p_coords_dreg_v_2_y - + shape_func_3_1 * p_coords_dreg_v_3_y - + shape_func_4_1 * p_coords_dreg_v_4_y - ) - z_gauss_pts_2_x = ( - shape_func_1_2 * p_coords_dreg_v_1_x - + shape_func_2_2 * p_coords_dreg_v_2_x - + shape_func_3_2 * p_coords_dreg_v_3_x - + shape_func_4_2 * p_coords_dreg_v_4_x - ) - z_gauss_pts_2_y = ( - shape_func_1_2 * p_coords_dreg_v_1_y - + shape_func_2_2 * p_coords_dreg_v_2_y - + shape_func_3_2 * p_coords_dreg_v_3_y - + shape_func_4_2 * p_coords_dreg_v_4_y - ) - z_gauss_pts_3_x = ( - shape_func_1_3 * p_coords_dreg_v_1_x - + shape_func_2_3 * p_coords_dreg_v_2_x - + shape_func_3_3 * p_coords_dreg_v_3_x - + shape_func_4_3 * p_coords_dreg_v_4_x - ) - z_gauss_pts_3_y = ( - shape_func_1_3 * p_coords_dreg_v_1_y - + shape_func_2_3 * p_coords_dreg_v_2_y - + shape_func_3_3 * p_coords_dreg_v_3_y - + shape_func_4_3 * p_coords_dreg_v_4_y - ) - z_gauss_pts_4_x = ( - shape_func_1_4 * p_coords_dreg_v_1_x - + shape_func_2_4 * p_coords_dreg_v_2_x - + shape_func_3_4 * p_coords_dreg_v_3_x - + shape_func_4_4 * p_coords_dreg_v_4_x - ) - z_gauss_pts_4_y = ( - shape_func_1_4 * p_coords_dreg_v_1_y - + shape_func_2_4 * p_coords_dreg_v_2_y - + shape_func_3_4 * p_coords_dreg_v_3_y - + shape_func_4_4 * p_coords_dreg_v_4_y - ) - return ( - z_gauss_pts_1_x, - z_gauss_pts_1_y, - z_gauss_pts_2_x, - z_gauss_pts_2_y, - z_gauss_pts_3_x, - z_gauss_pts_3_y, - z_gauss_pts_4_x, - z_gauss_pts_4_y, - ) - @staticmethod - def _compute_vector_sums( - wgt_t_detjac_1, - wgt_t_detjac_2, - wgt_t_detjac_3, - wgt_t_detjac_4, +def _compute_z_gauss_points( + p_coords_dreg_v_1_x, + p_coords_dreg_v_2_x, + p_coords_dreg_v_3_x, + p_coords_dreg_v_4_x, + p_coords_dreg_v_1_y, + p_coords_dreg_v_2_y, + p_coords_dreg_v_3_y, + p_coords_dreg_v_4_y, + shape_func_1_1, + shape_func_2_1, + shape_func_3_1, + shape_func_4_1, + shape_func_1_2, + shape_func_2_2, + shape_func_3_2, + shape_func_4_2, + shape_func_1_3, + shape_func_2_3, + shape_func_3_3, + shape_func_4_3, + shape_func_1_4, + shape_func_2_4, + shape_func_3_4, + shape_func_4_4, +): + z_gauss_pts_1_x = ( + shape_func_1_1 * p_coords_dreg_v_1_x + + shape_func_2_1 * p_coords_dreg_v_2_x + + shape_func_3_1 * p_coords_dreg_v_3_x + + shape_func_4_1 * p_coords_dreg_v_4_x + ) + z_gauss_pts_1_y = ( + shape_func_1_1 * p_coords_dreg_v_1_y + + shape_func_2_1 * p_coords_dreg_v_2_y + + shape_func_3_1 * p_coords_dreg_v_3_y + + shape_func_4_1 * p_coords_dreg_v_4_y + ) + z_gauss_pts_2_x = ( + shape_func_1_2 * p_coords_dreg_v_1_x + + shape_func_2_2 * p_coords_dreg_v_2_x + + shape_func_3_2 * p_coords_dreg_v_3_x + + shape_func_4_2 * p_coords_dreg_v_4_x + ) + z_gauss_pts_2_y = ( + shape_func_1_2 * p_coords_dreg_v_1_y + + shape_func_2_2 * p_coords_dreg_v_2_y + + shape_func_3_2 * p_coords_dreg_v_3_y + + shape_func_4_2 * p_coords_dreg_v_4_y + ) + z_gauss_pts_3_x = ( + shape_func_1_3 * p_coords_dreg_v_1_x + + shape_func_2_3 * p_coords_dreg_v_2_x + + shape_func_3_3 * p_coords_dreg_v_3_x + + shape_func_4_3 * p_coords_dreg_v_4_x + ) + z_gauss_pts_3_y = ( + shape_func_1_3 * p_coords_dreg_v_1_y + + shape_func_2_3 * p_coords_dreg_v_2_y + + shape_func_3_3 * p_coords_dreg_v_3_y + + shape_func_4_3 * p_coords_dreg_v_4_y + ) + z_gauss_pts_4_x = ( + shape_func_1_4 * p_coords_dreg_v_1_x + + shape_func_2_4 * p_coords_dreg_v_2_x + + shape_func_3_4 * p_coords_dreg_v_3_x + + shape_func_4_4 * p_coords_dreg_v_4_x + ) + z_gauss_pts_4_y = ( + shape_func_1_4 * p_coords_dreg_v_1_y + + shape_func_2_4 * p_coords_dreg_v_2_y + + shape_func_3_4 * p_coords_dreg_v_3_y + + shape_func_4_4 * p_coords_dreg_v_4_y + ) + return ( z_gauss_pts_1_x, z_gauss_pts_1_y, z_gauss_pts_2_x, @@ -303,78 +273,110 @@ def _compute_vector_sums( z_gauss_pts_3_y, z_gauss_pts_4_x, z_gauss_pts_4_y, - ): - p_quad_vector_sum_1 = wgt_t_detjac_1 + wgt_t_detjac_2 + wgt_t_detjac_3 + wgt_t_detjac_4 - p_quad_vector_sum_2 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x - ) - p_quad_vector_sum_3 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y - ) - p_quad_vector_sum_4 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x - ) - p_quad_vector_sum_5 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - p_quad_vector_sum_6 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y - ) - p_quad_vector_sum_7 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_x - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_x - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_x - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_x - ) - p_quad_vector_sum_8 = ( - wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - p_quad_vector_sum_9 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_y - ) - p_quad_vector_sum_10 = ( - wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y * z_gauss_pts_1_y - + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y * z_gauss_pts_2_y - + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y * z_gauss_pts_3_y - + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y * z_gauss_pts_4_y - ) - return ( - p_quad_vector_sum_1, - p_quad_vector_sum_2, - p_quad_vector_sum_3, - p_quad_vector_sum_4, - p_quad_vector_sum_5, - p_quad_vector_sum_6, - p_quad_vector_sum_7, - p_quad_vector_sum_8, - p_quad_vector_sum_9, - p_quad_vector_sum_10, - ) + ) + + +def _compute_vector_sums( + wgt_t_detjac_1, + wgt_t_detjac_2, + wgt_t_detjac_3, + wgt_t_detjac_4, + z_gauss_pts_1_x, + z_gauss_pts_1_y, + z_gauss_pts_2_x, + z_gauss_pts_2_y, + z_gauss_pts_3_x, + z_gauss_pts_3_y, + z_gauss_pts_4_x, + z_gauss_pts_4_y, +): + p_quad_vector_sum_1 = wgt_t_detjac_1 + wgt_t_detjac_2 + wgt_t_detjac_3 + wgt_t_detjac_4 + p_quad_vector_sum_2 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x + ) + p_quad_vector_sum_3 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y + ) + p_quad_vector_sum_4 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x + ) + p_quad_vector_sum_5 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + p_quad_vector_sum_6 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y + ) + p_quad_vector_sum_7 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_x + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_x + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_x + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_x + ) + p_quad_vector_sum_8 = ( + wgt_t_detjac_1 * z_gauss_pts_1_y * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_y * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_y * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_y * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + p_quad_vector_sum_9 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_x * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_x * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_x * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_x * z_gauss_pts_4_y + ) + p_quad_vector_sum_10 = ( + wgt_t_detjac_1 * z_gauss_pts_1_x * z_gauss_pts_1_y * z_gauss_pts_1_y + + wgt_t_detjac_2 * z_gauss_pts_2_x * z_gauss_pts_2_y * z_gauss_pts_2_y + + wgt_t_detjac_3 * z_gauss_pts_3_x * z_gauss_pts_3_y * z_gauss_pts_3_y + + wgt_t_detjac_4 * z_gauss_pts_4_x * z_gauss_pts_4_y * z_gauss_pts_4_y + ) + return ( + p_quad_vector_sum_1, + p_quad_vector_sum_2, + p_quad_vector_sum_3, + p_quad_vector_sum_4, + p_quad_vector_sum_5, + p_quad_vector_sum_6, + p_quad_vector_sum_7, + p_quad_vector_sum_8, + p_quad_vector_sum_9, + p_quad_vector_sum_10, + ) + + +class TestPrepareNumericalQuadratureListForCubicReconstruction(stencil_tests.StencilTest): + PROGRAM = prepare_numerical_quadrature_list_for_cubic_reconstruction + OUTPUTS = ( + "p_quad_vector_sum_1", + "p_quad_vector_sum_2", + "p_quad_vector_sum_3", + "p_quad_vector_sum_4", + "p_quad_vector_sum_5", + "p_quad_vector_sum_6", + "p_quad_vector_sum_7", + "p_quad_vector_sum_8", + "p_quad_vector_sum_9", + "p_quad_vector_sum_10", + "p_dreg_area", + ) - @classmethod + @stencil_tests.static_reference def reference( - cls, connectivities: dict[gtx.Dimension, np.ndarray], famask_int: np.ndarray, p_coords_dreg_v_1_x: np.ndarray, @@ -417,7 +419,7 @@ def reference( dbl_eps: float, **kwargs: Any, ) -> dict: - wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 = cls._compute_wgt_t_detjac( + wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, wgt_t_detjac_4 = _compute_wgt_t_detjac( p_coords_dreg_v_1_x, p_coords_dreg_v_2_x, p_coords_dreg_v_3_x, @@ -451,7 +453,7 @@ def reference( z_gauss_pts_3_y, z_gauss_pts_4_x, z_gauss_pts_4_y, - ) = cls._compute_z_gauss_points( + ) = _compute_z_gauss_points( p_coords_dreg_v_1_x, p_coords_dreg_v_2_x, p_coords_dreg_v_3_x, @@ -489,7 +491,7 @@ def reference( p_quad_vector_sum_8, p_quad_vector_sum_9, p_quad_vector_sum_10, - ) = cls._compute_vector_sums( + ) = _compute_vector_sums( wgt_t_detjac_1, wgt_t_detjac_2, wgt_t_detjac_3, @@ -519,7 +521,7 @@ def reference( p_dreg_area=p_dreg_area, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: famask_int = data_alloc.constant_field(grid, 1, dims.EdgeDim, dims.KDim, dtype=gtx.int32) p_coords_dreg_v_1_x = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/advection/tests/advection/stencil_tests/test_reconstruct_cubic_coefficients_svd.py b/model/atmosphere/advection/tests/advection/stencil_tests/test_reconstruct_cubic_coefficients_svd.py index ed85115d46..53be0ebf2c 100644 --- a/model/atmosphere/advection/tests/advection/stencil_tests/test_reconstruct_cubic_coefficients_svd.py +++ b/model/atmosphere/advection/tests/advection/stencil_tests/test_reconstruct_cubic_coefficients_svd.py @@ -36,7 +36,7 @@ class TestReconstructCubicCoefficientsSvd(stencil_tests.StencilTest): "p_coeff_10_dsl", ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cc: np.ndarray, @@ -304,7 +304,7 @@ def reference( p_coeff_10_dsl=p_coeff_10_dsl, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_cc = data_alloc.random_field(grid, dims.CellDim, dims.KDim) lsq_pseudoinv_1_field = data_alloc.random_field(grid, dims.CellDim, dims.C2E2C2E2CDim) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_theta_and_exner.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_theta_and_exner.py index 883fabb34f..8d86dfbd96 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_theta_and_exner.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_theta_and_exner.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base, horizontal as h_grid from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference from .test_calculate_nabla2_for_z import calculate_nabla2_for_z_numpy from .test_calculate_nabla2_of_theta import calculate_nabla2_of_theta_numpy @@ -35,7 +35,7 @@ class TestApplyDiffusionToThetaAndExner(StencilTest): PROGRAM = apply_diffusion_to_theta_and_exner OUTPUTS = ("theta_v", "exner") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], kh_smag_e: np.ndarray, @@ -81,7 +81,7 @@ def reference( return dict(theta_v=theta_v, exner=exner) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid): kh_smag_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) inv_dual_edge_length = data_alloc.random_field(grid, dims.EdgeDim) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_vn.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_vn.py index debdae974f..9062d94661 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_vn.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_vn.py @@ -15,7 +15,12 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.grid import base, horizontal as h_grid from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) from .test_apply_nabla2_and_nabla4_global_to_vn import apply_nabla2_and_nabla4_global_to_vn_numpy from .test_apply_nabla2_and_nabla4_to_vn import apply_nabla2_and_nabla4_to_vn_numpy @@ -47,7 +52,7 @@ class TestApplyDiffusionToVn(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], u_vert: np.ndarray, @@ -115,7 +120,7 @@ def reference( return dict(vn=vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: u_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim) v_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.py index 4e9652ac76..b876e502fa 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.py @@ -17,7 +17,12 @@ from icon4py.model.common.grid import base, horizontal as h_grid from icon4py.model.common.utils.data_allocation import random_field, zero_field from icon4py.model.testing import definitions -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) from .test_apply_nabla2_to_w import apply_nabla2_to_w_numpy from .test_apply_nabla2_to_w_in_upper_damping_layer import ( @@ -54,7 +59,7 @@ class TestApplyDiffusionToWAndComputeHorizontalGradientsForTurbulence(StencilTes ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], area, @@ -118,7 +123,7 @@ def reference( out_dwdy[subset] = dwdy[subset] return dict(w=out_w, dwdx=out_dwdx, dwdy=out_dwdy) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: nrdmax = 13 cell_domain = h_grid.domain(dims.CellDim) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_global_to_vn.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_global_to_vn.py index c2ef62b392..bc49934383 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_global_to_vn.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_global_to_vn.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_nabla2_and_nabla4_global_to_vn_numpy( @@ -34,7 +34,7 @@ class TestApplyNabla2AndNabla4GlobalToVn(StencilTest): PROGRAM = apply_nabla2_and_nabla4_global_to_vn OUTPUTS = ("vn",) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid): area_edge = random_field(grid, dims.EdgeDim, dtype=wpfloat) kh_smag_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) @@ -56,7 +56,7 @@ def input_data(self, grid: base.Grid): vertical_end=gtx.int32(grid.num_levels), ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], area_edge: np.ndarray, diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_to_vn.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_to_vn.py index 3b60be5291..0449e385d3 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_to_vn.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_and_nabla4_to_vn.py @@ -15,7 +15,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_nabla2_and_nabla4_to_vn_numpy( @@ -42,7 +42,7 @@ class TestApplyNabla2AndNabla4ToVn(StencilTest): PROGRAM = apply_nabla2_and_nabla4_to_vn OUTPUTS = ("vn",) - @pytest.fixture + @input_data_fixture def input_data(self, grid): area_edge = random_field(grid, dims.EdgeDim, dtype=wpfloat) kh_smag_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) @@ -68,7 +68,7 @@ def input_data(self, grid): vertical_end=gtx.int32(grid.num_levels), ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], area_edge: np.ndarray, diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_vn_in_lateral_boundary.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_vn_in_lateral_boundary.py index 0de1666efd..6ce940af9b 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_vn_in_lateral_boundary.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_vn_in_lateral_boundary.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_nabla2_to_vn_in_lateral_boundary_numpy( @@ -33,7 +33,7 @@ class TestApplyNabla2ToVnInLateralBoundary(StencilTest): PROGRAM = apply_nabla2_to_vn_in_lateral_boundary OUTPUTS = ("vn",) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid): fac_bdydiff_v = wpfloat("5.0") z_nabla2_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) @@ -50,7 +50,7 @@ def input_data(self, grid: base.Grid): vertical_end=gtx.int32(grid.num_levels), ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_nabla2_e: np.ndarray, diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w.py index cf505ee6ca..0d4e587073 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w.py @@ -13,7 +13,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_nabla2_to_w_numpy( @@ -38,7 +38,7 @@ class TestMoApplyNabla2ToW(StencilTest): PROGRAM = apply_nabla2_to_w OUTPUTS = ("w",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], area: np.ndarray, @@ -51,7 +51,7 @@ def reference( w = apply_nabla2_to_w_numpy(connectivities, area, z_nabla2_c, geofac_n2s, w, diff_multfac_w) return dict(w=w) - @pytest.fixture + @input_data_fixture def input_data(self, grid): area = random_field(grid, dims.CellDim, dtype=wpfloat) z_nabla2_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w_in_upper_damping_layer.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w_in_upper_damping_layer.py index 74d532867b..13e0d0c0e6 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w_in_upper_damping_layer.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_apply_nabla2_to_w_in_upper_damping_layer.py @@ -16,7 +16,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_nabla2_to_w_in_upper_damping_layer_numpy( @@ -34,7 +34,7 @@ class TestApplyNabla2ToWInUpperDampingLayer(StencilTest): PROGRAM = apply_nabla2_to_w_in_upper_damping_layer OUTPUTS = ("w",) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid): w = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff_multfac_n2w = random_field(grid, dims.KDim, dtype=wpfloat) @@ -52,7 +52,7 @@ def input_data(self, grid: base.Grid): vertical_end=gtx.int32(grid.num_levels), ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w: np.ndarray, diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_diagnostics_for_turbulence.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_diagnostics_for_turbulence.py index 142ee4d36a..557510fadb 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_diagnostics_for_turbulence.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_diagnostics_for_turbulence.py @@ -16,7 +16,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def calculate_diagnostics_for_turbulence_numpy( @@ -33,7 +33,7 @@ class TestCalculateDiagnosticsForTurbulence(StencilTest): PROGRAM = calculate_diagnostics_for_turbulence OUTPUTS = ("div_ic", "hdef_ic") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_c: np.ndarray, @@ -47,7 +47,7 @@ def reference( ) return dict(div_ic=div_ic, hdef_ic=hdef_ic) - @pytest.fixture + @input_data_fixture def input_data(self, grid): wgtfac_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) div = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_horizontal_gradients_for_turbulence.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_horizontal_gradients_for_turbulence.py index fa6659390b..614bf6920e 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_horizontal_gradients_for_turbulence.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_horizontal_gradients_for_turbulence.py @@ -15,7 +15,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def calculate_horizontal_gradients_for_turbulence_numpy( @@ -38,7 +38,7 @@ class TestCalculateHorizontalGradientsForTurbulence(StencilTest): PROGRAM = calculate_horizontal_gradients_for_turbulence OUTPUTS = ("dwdx", "dwdy") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w: np.ndarray, @@ -51,7 +51,7 @@ def reference( ) return dict(dwdx=dwdx, dwdy=dwdy) - @pytest.fixture + @input_data_fixture def input_data(self, grid): w = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) geofac_grg_x = data_alloc.random_field(grid, dims.CellDim, dims.C2E2CODim, dtype=wpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_and_smag_coefficients_for_vn.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_and_smag_coefficients_for_vn.py index e9cd84bde4..4f798895ab 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_and_smag_coefficients_for_vn.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_and_smag_coefficients_for_vn.py @@ -16,7 +16,7 @@ from icon4py.model.common import dimension as dims, type_alias as ta from icon4py.model.common.grid import base, horizontal as h_grid from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing import definitions, stencil_tests +from icon4py.model.testing import stencil_tests @pytest.mark.continuous_benchmarking @@ -37,7 +37,7 @@ class TestCalculateNabla2AndSmagCoefficientsForVn(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], diff_multfac_smag: np.ndarray, @@ -173,7 +173,7 @@ def reference( return dict(kh_smag_e=kh_smag_e_out, kh_smag_ec=kh_smag_ec_out, z_nabla2_e=z_nabla2_e_out) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: u_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=ta.vpfloat) v_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_w.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_w.py index eb405afab2..892c64021a 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_w.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_w.py @@ -15,7 +15,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.grid import base from icon4py.model.common.utils.data_allocation import constant_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def calculate_nabla2_for_w_numpy( @@ -34,7 +34,7 @@ class TestCalculateNabla2ForW(StencilTest): PROGRAM = calculate_nabla2_for_w OUTPUTS = ("z_nabla2_c",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w: np.ndarray, @@ -44,7 +44,7 @@ def reference( z_nabla2_c = calculate_nabla2_for_w_numpy(connectivities, w, geofac_n2s) return dict(z_nabla2_c=z_nabla2_c) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: w = constant_field(grid, 1.0, dims.CellDim, dims.KDim) geofac_n2s = constant_field(grid, 2.0, dims.CellDim, dims.C2E2CODim) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_z.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_z.py index 8a4d9fb58e..a4550c0bd9 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_z.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_for_z.py @@ -16,7 +16,7 @@ from icon4py.model.common.grid import horizontal as h_grid from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def calculate_nabla2_for_z_numpy( @@ -41,7 +41,7 @@ class TestCalculateNabla2ForZ(StencilTest): PROGRAM = calculate_nabla2_for_z OUTPUTS = ("z_nabla2_e",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], kh_smag_e: np.ndarray, @@ -55,7 +55,7 @@ def reference( ) return dict(z_nabla2_e=z_nabla2_e) - @pytest.fixture + @input_data_fixture def input_data(self, grid): kh_smag_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_of_theta.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_of_theta.py index 5355ee6371..ee98a0ea74 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_of_theta.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla2_of_theta.py @@ -31,7 +31,7 @@ class TestCalculateNabla2OfTheta(stencil_tests.StencilTest): PROGRAM = calculate_nabla2_of_theta OUTPUTS = ("z_temp",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_nabla2_e: np.ndarray, @@ -41,7 +41,7 @@ def reference( z_temp = calculate_nabla2_of_theta_numpy(connectivities, z_nabla2_e, geofac_div) return dict(z_temp=z_temp) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_nabla2_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla4.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla4.py index dc8f9ac4ba..53e2beacae 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla4.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_calculate_nabla4.py @@ -12,7 +12,12 @@ import icon4py.model.common.utils.data_allocation as data_alloc from icon4py.model.atmosphere.diffusion.stencils.calculate_nabla4 import calculate_nabla4 from icon4py.model.common import dimension as dims, type_alias as ta -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) def calculate_nabla4_numpy( @@ -73,7 +78,7 @@ class TestCalculateNabla4(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], u_vert: np.ndarray, @@ -97,7 +102,7 @@ def reference( ) return dict(z_nabla4_e2=z_nabla4_e2) - @pytest.fixture + @input_data_fixture def input_data(self, grid) -> dict: u_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=ta.vpfloat) v_vert = data_alloc.random_field(grid, dims.VertexDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_enhance_diffusion_coefficient_for_grid_point_cold_pools.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_enhance_diffusion_coefficient_for_grid_point_cold_pools.py index 50524d92d4..f388d606d1 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_enhance_diffusion_coefficient_for_grid_point_cold_pools.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_enhance_diffusion_coefficient_for_grid_point_cold_pools.py @@ -18,14 +18,14 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestEnhanceDiffusionCoefficientForGridPointColdPools(StencilTest): PROGRAM = enhance_diffusion_coefficient_for_grid_point_cold_pools OUTPUTS = ("kh_smag_e",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], kh_smag_e: np.ndarray, @@ -42,7 +42,7 @@ def reference( ) return dict(kh_smag_e=kh_smag_e) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: kh_smag_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) enh_diffu_3d = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_field_for_grid_point_cold_pools_enhancement.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_field_for_grid_point_cold_pools_enhancement.py index fd0b4563a9..0d0355a5cf 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_field_for_grid_point_cold_pools_enhancement.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_field_for_grid_point_cold_pools_enhancement.py @@ -16,7 +16,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference @pytest.mark.embedded_remap_error @@ -24,7 +24,7 @@ class TestTemporaryFieldForGridPointColdPoolsEnhancement(StencilTest): PROGRAM = temporary_field_for_grid_point_cold_pools_enhancement OUTPUTS = ("enh_diffu_3d",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], theta_v: np.ndarray, @@ -52,7 +52,7 @@ def reference( return dict(enh_diffu_3d=enh_diffu_3d) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: theta_v = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) theta_ref_mc = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_fields_for_turbulence_diagnostics.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_fields_for_turbulence_diagnostics.py index 0352652ad2..28b54b211a 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_fields_for_turbulence_diagnostics.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_temporary_fields_for_turbulence_diagnostics.py @@ -22,7 +22,7 @@ class TestTemporaryFieldsForTurbulenceDiagnostics(stencil_tests.StencilTest): PROGRAM = temporary_fields_for_turbulence_diagnostics OUTPUTS = ("div", "kh_c") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], kh_smag_ec: np.ndarray, @@ -46,7 +46,7 @@ def reference( return dict(div=div, kh_c=kh_c) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid): vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py index 37797d3b6a..e9eb2c0c0f 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py @@ -15,7 +15,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def truly_horizontal_diffusion_nabla_of_theta_over_steep_points_numpy( @@ -61,7 +61,7 @@ class TestTrulyHorizontalDiffusionNablaOfThetaOverSteepPoints(StencilTest): PROGRAM = truly_horizontal_diffusion_nabla_of_theta_over_steep_points OUTPUTS = ("z_temp",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], zd_vertoffset: np.ndarray, @@ -85,7 +85,7 @@ def reference( ) return dict(z_temp=z_temp) - @pytest.fixture + @input_data_fixture def input_data(self, grid): zd_vertoffset = zero_field(grid, dims.CellDim, dims.C2E2CDim, dims.KDim, dtype=gtx.int32) rng = np.random.default_rng() diff --git a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_update_theta_and_exner.py b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_update_theta_and_exner.py index d7bce46e8a..7f0bd10773 100644 --- a/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_update_theta_and_exner.py +++ b/model/atmosphere/diffusion/tests/diffusion/stencil_tests/test_update_theta_and_exner.py @@ -16,7 +16,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def update_theta_and_exner_numpy( @@ -37,7 +37,7 @@ class TestUpdateThetaAndExner(StencilTest): PROGRAM = update_theta_and_exner OUTPUTS = ("theta_v", "exner") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_temp: np.ndarray, @@ -50,7 +50,7 @@ def reference( theta_v, exner = update_theta_and_exner_numpy(z_temp, area, theta_v, exner, rd_o_cvd) return dict(theta_v=theta_v, exner=exner) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: z_temp = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) area = random_field(grid, dims.CellDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_accumulate_prep_adv_fields.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_accumulate_prep_adv_fields.py index c58454e15d..a6f451e799 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_accumulate_prep_adv_fields.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_accumulate_prep_adv_fields.py @@ -20,7 +20,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def accumulate_prep_adv_fields_numpy( @@ -40,7 +40,7 @@ class TestAccumulatePrepAdvFields(StencilTest): PROGRAM = accumulate_prep_adv_fields OUTPUTS = ("vn_traj", "mass_flx_me") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_vn_avg: np.ndarray, @@ -60,7 +60,7 @@ def reference( return dict(vn_traj=vn_traj, mass_flx_me=mass_flx_me) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: mass_fl_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) mass_flx_me = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_from_data_assimilation.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_from_data_assimilation.py index 5bf6bf9525..5d4ec95b60 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_from_data_assimilation.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_from_data_assimilation.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def add_analysis_increments_from_data_assimilation_numpy( @@ -38,7 +38,7 @@ class TestAddAnalysisIncrementsFromDataAssimilation(StencilTest): PROGRAM = add_analysis_increments_from_data_assimilation OUTPUTS = ("z_rho_expl", "z_exner_expl") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_rho_expl: np.ndarray, @@ -58,7 +58,7 @@ def reference( ) return dict(z_rho_expl=z_rho_expl, z_exner_expl=z_exner_expl) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_exner_expl = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) exner_incr = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_to_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_to_vn.py index 8f67332647..479ce85f5f 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_to_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_analysis_increments_to_vn.py @@ -20,7 +20,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def add_analysis_increments_to_vn_numpy( @@ -34,7 +34,7 @@ class TestAddAnalysisIncrementsToVn(StencilTest): PROGRAM = add_analysis_increments_to_vn OUTPUTS = ("vn",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn_incr: np.ndarray, @@ -45,7 +45,7 @@ def reference( vn = add_analysis_increments_to_vn_numpy(vn_incr, vn, iau_wgt_dyn) return dict(vn=vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn_incr = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_normal_wind_tendency_approaching_cfl.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_normal_wind_tendency_approaching_cfl.py index 6c69b6b94e..b5b54171c1 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_normal_wind_tendency_approaching_cfl.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_normal_wind_tendency_approaching_cfl.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def add_extra_diffusion_for_normal_wind_tendency_approaching_cfl_numpy( @@ -102,7 +102,7 @@ class TestAddExtraDiffusionForNormalWindTendencyApproachingCfl(StencilTest): PROGRAM = add_extra_diffusion_for_normal_wind_tendency_approaching_cfl OUTPUTS = ("ddt_vn_apc",) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: levelmask = data_alloc.random_mask(grid, dims.KDim, extend={dims.KDim: 1}) c_lin_e = data_alloc.random_field(grid, dims.EdgeDim, dims.E2CDim, dtype=ta.wpfloat) @@ -141,7 +141,7 @@ def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.Scala vertical_end=gtx.int32(grid.num_levels), ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], levelmask: np.ndarray, diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py index 1e855f11ac..72ab102a61 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_extra_diffusion_for_w_con_approaching_cfl.py @@ -20,7 +20,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, random_mask -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def add_extra_diffusion_for_w_con_approaching_cfl_numpy( @@ -75,7 +75,7 @@ class TestAddExtraDiffusionForWConApproachingCfl(StencilTest): PROGRAM = add_extra_diffusion_for_w_con_approaching_cfl OUTPUTS = ("ddt_w_adv",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], cfl_clipping: np.ndarray, @@ -107,7 +107,7 @@ def reference( ) return dict(ddt_w_adv=ddt_w_adv) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: cfl_clipping = random_mask(grid, dims.CellDim, dims.KDim) owner_mask = random_mask(grid, dims.CellDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_interpolated_horizontal_advection_of_w.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_interpolated_horizontal_advection_of_w.py index e27f6d9ee7..2a2556b6a8 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_interpolated_horizontal_advection_of_w.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_interpolated_horizontal_advection_of_w.py @@ -42,7 +42,7 @@ class TestAddInterpolatedHorizontalAdvectionOfW(stencil_tests.StencilTest): PROGRAM = add_interpolated_horizontal_advection_of_w OUTPUTS = ("ddt_w_adv",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], e_bln_c_s: np.ndarray, @@ -55,7 +55,7 @@ def reference( ) return dict(ddt_w_adv=ddt_w_adv) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_v_grad_w = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) e_bln_c_s = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn.py index 861d66d4ba..3200d275c8 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference dycore_consts: Final = constants.PhysicsConstants() @@ -43,7 +43,7 @@ class TestAddTemporalTendenciesToVn(StencilTest): PROGRAM = add_temporal_tendencies_to_vn OUTPUTS = ("vn_nnew",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn_nnow: np.ndarray, @@ -59,7 +59,7 @@ def reference( ) return dict(vn_nnew=vn_nnew) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: dtime = wpfloat("10.0") vn_nnow = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn_by_interpolating_between_time_levels.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn_by_interpolating_between_time_levels.py index b84b1bbc74..453b82863c 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn_by_interpolating_between_time_levels.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_temporal_tendencies_to_vn_by_interpolating_between_time_levels.py @@ -19,7 +19,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def add_temporal_tendencies_to_vn_by_interpolating_between_time_levels_numpy( @@ -47,7 +47,7 @@ class TestAddTemporalTendenciesToVnByInterpolatingBetweenTimeLevels(StencilTest) PROGRAM = add_temporal_tendencies_to_vn_by_interpolating_between_time_levels OUTPUTS = ("vn_nnew",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn_nnow: np.ndarray, @@ -76,7 +76,7 @@ def reference( ) return dict(vn_nnew=vn_nnew) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn_nnow = random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) ddt_vn_apc_ntl1 = random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_vertical_wind_derivative_to_divergence_damping.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_vertical_wind_derivative_to_divergence_damping.py index 723e7952e6..10266a40be 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_vertical_wind_derivative_to_divergence_damping.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_add_vertical_wind_derivative_to_divergence_damping.py @@ -48,7 +48,7 @@ class TestAddVerticalWindDerivativeToDivergenceDamping(stencil_tests.StencilTest PROGRAM = add_vertical_wind_derivative_to_divergence_damping OUTPUTS = ("z_graddiv_vn",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], hmask_dd3d: np.ndarray, @@ -68,7 +68,7 @@ def reference( ) return dict(z_graddiv_vn=z_graddiv_vn) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: hmask_dd3d = data_alloc.random_field(grid, dims.EdgeDim, dtype=ta.wpfloat) scalfac_dd3d = data_alloc.random_field(grid, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_2nd_order_divergence_damping.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_2nd_order_divergence_damping.py index 08bd2c8d73..aad112d6bb 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_2nd_order_divergence_damping.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_2nd_order_divergence_damping.py @@ -20,7 +20,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_2nd_order_divergence_damping_numpy( @@ -34,7 +34,7 @@ class TestApply2ndOrderDivergenceDamping(StencilTest): PROGRAM = apply_2nd_order_divergence_damping OUTPUTS = ("vn",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_graddiv_vn: np.ndarray, @@ -45,7 +45,7 @@ def reference( vn = apply_2nd_order_divergence_damping_numpy(z_graddiv_vn, vn, scal_divdamp_o2) return dict(vn=vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_graddiv_vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_4th_order_divergence_damping.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_4th_order_divergence_damping.py index b4ca1f1d56..b529a1ffa7 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_4th_order_divergence_damping.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_4th_order_divergence_damping.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference from . import test_dycore_utils @@ -38,7 +38,7 @@ class TestApply4thOrderDivergenceDamping(StencilTest): PROGRAM = apply_4th_order_divergence_damping OUTPUTS = ("vn",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], interpolated_fourth_order_divdamp_factor: np.ndarray, @@ -58,7 +58,7 @@ def reference( vn = apply_4th_order_divergence_damping_numpy(scal_divdamp, z_graddiv2_vn, vn) return dict(vn=vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: interpolated_fourth_order_divdamp_factor = data_alloc.random_field(grid, dims.KDim) z_graddiv2_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_divergence_damping_and_update_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_divergence_damping_and_update_vn.py index 0ddbe7cf4e..ec4a915ca3 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_divergence_damping_and_update_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_divergence_damping_and_update_vn.py @@ -11,7 +11,6 @@ import pytest import icon4py.model.common.type_alias as ta -import icon4py.model.testing.stencil_tests as test_helpers from icon4py.model.atmosphere.dycore.dycore_states import DivergenceDampingOrder from icon4py.model.atmosphere.dycore.stencils.compute_edge_diagnostics_for_dycore_and_update_vn import ( apply_divergence_damping_and_update_vn, @@ -19,6 +18,7 @@ from icon4py.model.common import constants, dimension as dims from icon4py.model.common.grid import base, horizontal as h_grid from icon4py.model.common.utils import data_allocation as data_alloc +from icon4py.model.testing import stencil_tests from . import test_dycore_utils @@ -28,12 +28,12 @@ @pytest.mark.embedded_remap_error @pytest.mark.continuous_benchmarking -class TestApplyDivergenceDampingAndUpdateVn(test_helpers.StencilTest): +class TestApplyDivergenceDampingAndUpdateVn(stencil_tests.StencilTest): PROGRAM = apply_divergence_damping_and_update_vn OUTPUTS = ("next_vn",) STATIC_PARAMS = { - test_helpers.StandardStaticVariants.NONE: (), - test_helpers.StandardStaticVariants.COMPILE_TIME_DOMAIN: ( + stencil_tests.StandardStaticVariants.NONE: (), + stencil_tests.StandardStaticVariants.COMPILE_TIME_DOMAIN: ( "horizontal_start", "horizontal_end", "vertical_start", @@ -41,7 +41,7 @@ class TestApplyDivergenceDampingAndUpdateVn(test_helpers.StencilTest): "is_iau_active", "limited_area", ), - test_helpers.StandardStaticVariants.COMPILE_TIME_VERTICAL: ( + stencil_tests.StandardStaticVariants.COMPILE_TIME_VERTICAL: ( "vertical_start", "vertical_end", "is_iau_active", @@ -49,7 +49,7 @@ class TestApplyDivergenceDampingAndUpdateVn(test_helpers.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], horizontal_gradient_of_normal_wind_divergence: np.ndarray, @@ -186,7 +186,7 @@ def reference( return dict(next_vn=next_vn) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"divdamp_order": do, "is_iau_active": ia, "second_order_divdamp_factor": sodf} for do, ia, sodf in [ @@ -206,7 +206,7 @@ def reference( f"divdamp_order[{param['divdamp_order']}]__is_iau_active[{param['is_iau_active']}]__second_order_divdamp_factor[{param['second_order_divdamp_factor']}]" ), ) - def input_data(self, request: pytest.FixtureRequest, grid: base.Grid) -> dict: + def input_data(self, grid: base.Grid, request: pytest.FixtureRequest) -> dict: current_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) horizontal_mask_for_3d_divdamp = data_alloc.random_field(grid, dims.EdgeDim) scaling_factor_for_3d_divdamp = data_alloc.random_field(grid, dims.KDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_rayleigh_damping_mechanism.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_rayleigh_damping_mechanism.py index 4d2018f463..59c7494f10 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_rayleigh_damping_mechanism.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_rayleigh_damping_mechanism.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def apply_rayleigh_damping_mechanism_numpy( @@ -36,7 +36,7 @@ class TestApplyRayleighDampingMechanism(StencilTest): PROGRAM = apply_rayleigh_damping_mechanism OUTPUTS = ("w",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_raylfac: np.ndarray, @@ -46,7 +46,7 @@ def reference( w = apply_rayleigh_damping_mechanism_numpy(connectivities, z_raylfac, w) return dict(w=w) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_raylfac = random_field(grid, dims.KDim, dtype=wpfloat) w = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_weighted_2nd_and_4th_order_divergence_damping.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_weighted_2nd_and_4th_order_divergence_damping.py index 33505b461b..2b3487ae08 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_weighted_2nd_and_4th_order_divergence_damping.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_apply_weighted_2nd_and_4th_order_divergence_damping.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference from . import test_dycore_utils @@ -40,7 +40,7 @@ class TestApplyWeighted2ndAnd4thOrderDivergenceDamping(StencilTest): PROGRAM = apply_weighted_2nd_and_4th_order_divergence_damping OUTPUTS = ("vn",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], interpolated_fourth_order_divdamp_factor: np.ndarray, @@ -74,7 +74,7 @@ def reference( ) return dict(vn=vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: interpolated_fourth_order_divdamp_factor = data_alloc.random_field(grid, dims.KDim) nudgecoeff_e = data_alloc.random_field(grid, dims.EdgeDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_horizontal_momentum_equation.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_horizontal_momentum_equation.py index 8ee6995109..d99c9a1ac0 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_horizontal_momentum_equation.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_horizontal_momentum_equation.py @@ -157,7 +157,7 @@ class TestFusedVelocityAdvectionStencilsHMomentum(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], normal_wind_advective_tendency: np.ndarray, @@ -245,14 +245,14 @@ def reference( return dict(normal_wind_advective_tendency=normal_wind_advective_tendency) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"apply_extra_diffusion_on_vn": value} for value in [True, False] ], # True for testing, False for benchmarking ids=lambda param: f"apply_extra_diffusion_on_vn[{param['apply_extra_diffusion_on_vn']}]", ) def input_data( - self, request: pytest.FixtureRequest, grid: base.Grid + self, grid: base.Grid, request: pytest.FixtureRequest ) -> dict[str, gtx.Field | state_utils.ScalarType]: normal_wind_advective_tendency = data_alloc.zero_field(grid, dims.EdgeDim, dims.KDim) vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_vertical_momentum_equation.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_vertical_momentum_equation.py index 3c32009b11..5dfa901432 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_vertical_momentum_equation.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advection_in_vertical_momentum_equation.py @@ -293,7 +293,7 @@ class TestFusedVelocityAdvectionStencilVMomentum(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vertical_wind_advective_tendency: np.ndarray, @@ -409,7 +409,7 @@ def reference( vertical_cfl=vertical_cfl_ret, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: contravariant_corrected_w_at_cells_on_model_levels = data_alloc.zero_field( grid, dims.CellDim, dims.KDim @@ -497,7 +497,7 @@ class TestFusedVelocityAdvectionStencilVMomentumAndContravariant(stencil_tests.S stencil_tests.StandardStaticVariants.NONE: (), # For now compile time variants triger error in gt4py } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], contravariant_correction_at_cells_on_half_levels: np.ndarray, @@ -622,7 +622,7 @@ def reference( vertical_cfl=vertical_cfl_ret, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"skip_compute_predictor_vertical_advection": value} for value in [True, False] ], # True for benchmarking, False for testing diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advective_vertical_wind_tendency.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advective_vertical_wind_tendency.py index 21fdb8c7ef..8a5951e957 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advective_vertical_wind_tendency.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_advective_vertical_wind_tendency.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_advective_vertical_wind_tendency_numpy( @@ -42,7 +42,7 @@ class TestComputeAdvectiveVerticalWindTendency(StencilTest): PROGRAM = compute_advective_vertical_wind_tendency OUTPUTS = ("ddt_w_adv",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_w_con_c: np.ndarray, @@ -56,7 +56,7 @@ def reference( ) return dict(ddt_w_adv=ddt_w_adv) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_w_con_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) w = random_field(grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_airmass.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_airmass.py index 61445dcf1e..b9f1fdc35e 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_airmass.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_airmass.py @@ -17,14 +17,14 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestComputeAirmass(StencilTest): PROGRAM = compute_airmass OUTPUTS = ("airmass_out",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_in: np.ndarray, @@ -35,7 +35,7 @@ def reference( airmass_out = rho_in * ddqz_z_full_in * deepatmo_t1mc_in return dict(airmass_out=airmass_out) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: rho_in = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) ddqz_z_full_in = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_approx_of_2nd_vertical_derivative_of_exner.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_approx_of_2nd_vertical_derivative_of_exner.py index d842690914..e0c780ab91 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_approx_of_2nd_vertical_derivative_of_exner.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_approx_of_2nd_vertical_derivative_of_exner.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_approx_of_2nd_vertical_derivative_of_exner_numpy( @@ -40,7 +40,7 @@ class TestComputeApproxOf2ndVerticalDerivativeOfExner(StencilTest): PROGRAM = compute_approx_of_2nd_vertical_derivative_of_exner OUTPUTS = ("z_dexner_dz_c_2",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_theta_v_pr_ic: np.ndarray, @@ -57,7 +57,7 @@ def reference( ) return dict(z_dexner_dz_c_2=z_dexner_dz_c_2) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_theta_v_pr_ic = random_field( grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}, dtype=vpfloat diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_averaged_vn_and_fluxes_and_prepare_tracer_advection.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_averaged_vn_and_fluxes_and_prepare_tracer_advection.py index cf503c38ca..ab26be430b 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_averaged_vn_and_fluxes_and_prepare_tracer_advection.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_averaged_vn_and_fluxes_and_prepare_tracer_advection.py @@ -56,7 +56,7 @@ class TestComputeAveragedVnAndFluxesAndPrepareTracerAdvection(stencil_tests.Sten ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], spatially_averaged_vn: np.ndarray, @@ -154,7 +154,7 @@ def reference( substep_averaged_mass_flux=substep_averaged_mass_flux, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"prepare_advection": pa, "at_first_substep": afs} for pa, afs in [ @@ -167,7 +167,7 @@ def reference( ), ) def input_data( - self, request: pytest.FixtureRequest, grid: base.Grid + self, grid: base.Grid, request: pytest.FixtureRequest ) -> dict[str, gtx.Field | state_utils.ScalarType]: spatially_averaged_vn = data_alloc.zero_field(grid, dims.EdgeDim, dims.KDim) mass_fl_e = data_alloc.zero_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_avg_vn_and_graddiv_vn_and_vt.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_avg_vn_and_graddiv_vn_and_vt.py index 5cf3efa33b..3c7a5b4b27 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_avg_vn_and_graddiv_vn_and_vt.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_avg_vn_and_graddiv_vn_and_vt.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_avg_vn_and_graddiv_vn_and_vt_numpy( @@ -47,7 +47,7 @@ class TestComputeAvgVnAndGraddivVnAndVt(StencilTest): PROGRAM = compute_avg_vn_and_graddiv_vn_and_vt OUTPUTS = ("z_vn_avg", "z_graddiv_vn", "vt") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], e_flx_avg: np.ndarray, @@ -65,7 +65,7 @@ def reference( ) return dict(z_vn_avg=z_vn_avg, z_graddiv_vn=z_graddiv_vn, vt=vt) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: e_flx_avg = random_field(grid, dims.EdgeDim, dims.E2C2EODim, dtype=wpfloat) geofac_grdiv = random_field(grid, dims.EdgeDim, dims.E2C2EODim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction.py index e557ec551d..0cf4a98d56 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_contravariant_correction_numpy( @@ -33,7 +33,7 @@ class TestComputeContravariantCorrection(StencilTest): PROGRAM = compute_contravariant_correction OUTPUTS = ("z_w_concorr_me",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn: np.ndarray, @@ -45,7 +45,7 @@ def reference( z_w_concorr_me = compute_contravariant_correction_numpy(vn, ddxn_z_full, ddxt_z_full, vt) return dict(z_w_concorr_me=z_w_concorr_me) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) ddxn_z_full = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w.py index 6a7d916250..f463516fb1 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_contravariant_correction_of_w_numpy( @@ -43,7 +43,7 @@ class TestComputeContravariantCorrectionOfW(StencilTest): PROGRAM = compute_contravariant_correction_of_w OUTPUTS = ("w_concorr_c",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], e_bln_c_s: np.ndarray, @@ -56,7 +56,7 @@ def reference( ) return dict(w_concorr_c=w_concorr_c) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: e_bln_c_s = random_field(grid, dims.CellDim, dims.C2EDim, dtype=wpfloat) z_w_concorr_me = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w_for_lower_boundary.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w_for_lower_boundary.py index 1723d907a5..968d276aa6 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w_for_lower_boundary.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_contravariant_correction_of_w_for_lower_boundary.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_contravariant_correction_of_w_for_lower_boundary_numpy( @@ -52,7 +52,7 @@ class TestComputeContravariantCorrectionOfWForLowerBoundary(StencilTest): PROGRAM = compute_contravariant_correction_of_w_for_lower_boundary OUTPUTS = ("w_concorr_c",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], e_bln_c_s: np.ndarray, @@ -65,7 +65,7 @@ def reference( ) return dict(w_concorr_c=w_concorr_c) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: e_bln_c_s = random_field(grid, dims.CellDim, dims.C2EDim, dtype=wpfloat) z_w_concorr_me = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_diagnostics_from_normal_wind.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_diagnostics_from_normal_wind.py index c47e4e5332..e10d645635 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_diagnostics_from_normal_wind.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_diagnostics_from_normal_wind.py @@ -178,9 +178,8 @@ class TestComputeDerivedHorizontalWindsAndKEAndHorizontalAdvectionofWAndContrava ), } - @classmethod + @stencil_tests.static_reference def reference( - cls, connectivities: dict[gtx.Dimension, np.ndarray], tangential_wind: np.ndarray, tangential_wind_on_half_levels: np.ndarray, @@ -290,7 +289,7 @@ def reference( horizontal_advection_of_w_at_edges_on_half_levels=horizontal_advection_of_w_at_edges_on_half_levels, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"skip_compute_predictor_vertical_advection": value} for value in [True, False] ], # True for benchmarking, False for testing diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_divergence_of_fluxes_of_rho_and_theta.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_divergence_of_fluxes_of_rho_and_theta.py index d009a74d8d..c25d1e58f3 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_divergence_of_fluxes_of_rho_and_theta.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_divergence_of_fluxes_of_rho_and_theta.py @@ -41,7 +41,7 @@ class TestComputeDivergenceConnectivityOfFluxesOfRhoAndTheta(stencil_tests.Stenc PROGRAM = compute_divergence_of_fluxes_of_rho_and_theta OUTPUTS = ("z_flxdiv_mass", "z_flxdiv_theta") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], geofac_div: np.ndarray, @@ -57,7 +57,7 @@ def reference( ) return dict(z_flxdiv_mass=z_flxdiv_mass, z_flxdiv_theta=z_flxdiv_theta) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim, dtype=ta.wpfloat) z_theta_v_fl_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_dwdz_for_divergence_damping.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_dwdz_for_divergence_damping.py index a14d93aca1..08357ca52e 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_dwdz_for_divergence_damping.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_dwdz_for_divergence_damping.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_dwdz_for_divergence_damping_numpy( @@ -37,7 +37,7 @@ class TestComputeDwdzForDivergenceDamping(StencilTest): PROGRAM = _compute_dwdz_for_divergence_damping OUTPUTS = ("out",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], inv_ddqz_z_full: np.ndarray, @@ -50,7 +50,7 @@ def reference( ) return dict(out=z_dwdz_dd) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, Any]: inv_ddqz_z_full = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) w = random_field(grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_exner_from_rhotheta.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_exner_from_rhotheta.py index 582a4ef0d3..2531d9541f 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_exner_from_rhotheta.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_exner_from_rhotheta.py @@ -18,14 +18,14 @@ from icon4py.model.common.grid import base from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestComputeExnerFromRhotheta(StencilTest): PROGRAM = _compute_exner_from_rhotheta OUTPUTS = ("out",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho: np.ndarray, @@ -38,7 +38,7 @@ def reference( exner = np.exp(rd_o_cvd * np.log(rd_o_p0ref * rho * theta_v)) return dict(out=(theta_v, exner)) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, Any]: rd_o_cvd = wpfloat("10.0") rd_o_p0ref = wpfloat("20.0") diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_part_for_rho_and_exner.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_part_for_rho_and_exner.py index 347299fd46..cb7ad148c5 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_part_for_rho_and_exner.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_part_for_rho_and_exner.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_explicit_part_for_rho_and_exner_numpy( @@ -55,7 +55,7 @@ class TestComputeExplicitPartForRhoAndExner(StencilTest): PROGRAM = compute_explicit_part_for_rho_and_exner OUTPUTS = ("z_rho_expl", "z_exner_expl") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_nnow: np.ndarray, @@ -85,7 +85,7 @@ def reference( ) return dict(z_rho_expl=z_rho_expl, z_exner_expl=z_exner_expl) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: dtime = ta.wpfloat("1.0") rho_nnow = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_from_advection_and_vertical_wind_density.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_from_advection_and_vertical_wind_density.py index efd3ba9a10..a46c0d5f94 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_from_advection_and_vertical_wind_density.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_from_advection_and_vertical_wind_density.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_explicit_vertical_wind_from_advection_and_vertical_wind_density_numpy( @@ -47,7 +47,7 @@ class TestComputeExplicitVerticalWindFromAdvectionAndVerticalWindDensity(Stencil PROGRAM = compute_explicit_vertical_wind_from_advection_and_vertical_wind_density OUTPUTS = ("z_w_expl", "z_contr_w_fl_l") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w_nnow: np.ndarray, @@ -82,7 +82,7 @@ def reference( ) return dict(z_w_expl=z_w_expl, z_contr_w_fl_l=z_contr_w_fl_l) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: w_nnow = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) ddt_w_adv_ntl1 = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_speed_and_vertical_wind_times_density.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_speed_and_vertical_wind_times_density.py index bdaf78fbc3..2d1d2d2c85 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_speed_and_vertical_wind_times_density.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_explicit_vertical_wind_speed_and_vertical_wind_times_density.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_explicit_vertical_wind_speed_and_vertical_wind_times_density_numpy( @@ -43,7 +43,7 @@ class TestComputeExplicitVerticalWindSpeedAndVerticalWindTimesDensity(StencilTes PROGRAM = compute_explicit_vertical_wind_speed_and_vertical_wind_times_density OUTPUTS = ("z_w_expl", "z_contr_w_fl_l") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w_nnow: np.ndarray, @@ -72,7 +72,7 @@ def reference( ) return dict(z_w_expl=z_w_expl, z_contr_w_fl_l=z_contr_w_fl_l) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: w_nnow = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) ddt_w_adv_ntl1 = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_graddiv2_of_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_graddiv2_of_vn.py index 3f9eca2afc..19b1d57eea 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_graddiv2_of_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_graddiv2_of_vn.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_graddiv2_of_vn_numpy( @@ -39,7 +39,7 @@ class TestComputeGraddiv2OfVn(StencilTest): PROGRAM = compute_graddiv2_of_vn OUTPUTS = ("z_graddiv2_vn",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], geofac_grdiv: np.ndarray, @@ -49,7 +49,7 @@ def reference( z_graddiv2_vn = compute_graddiv2_of_vn_numpy(connectivities, geofac_grdiv, z_graddiv_vn) return dict(z_graddiv2_vn=z_graddiv2_vn) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_graddiv_vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) geofac_grdiv = random_field(grid, dims.EdgeDim, dims.E2C2EODim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_of_rho_and_theta.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_of_rho_and_theta.py index ad61d07c8a..97d5cd82ad 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_of_rho_and_theta.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_of_rho_and_theta.py @@ -211,7 +211,7 @@ class TestComputeHorizontalAvectionOfRhoAndTheta(stencil_tests.StencilTest): PROGRAM = _compute_horizontal_advection_of_rho_and_theta OUTPUTS = ("out",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_vn: np.ndarray, @@ -251,7 +251,7 @@ def reference( ) return dict(out=(z_rho_e, z_theta_v_e)) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: p_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) p_vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py index 0c47cf433c..75f7f8767f 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_advection_term_for_vertical_velocity.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_horizontal_advection_term_for_vertical_velocity_numpy( @@ -53,7 +53,7 @@ class TestComputeHorizontalAdvectionTermForVerticalVelocity(StencilTest): PROGRAM = compute_horizontal_advection_term_for_vertical_velocity OUTPUTS = ("z_v_grad_w",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn_ie: np.ndarray, @@ -82,7 +82,7 @@ def reference( )[horizontal_start:horizontal_end, :] return dict(z_v_grad_w=z_v_grad_w) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn_ie = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates.py index 09ade5f64b..85ded43055 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates_numpy( @@ -41,7 +41,7 @@ class TestComputeHorizontalGradientOfExnerPressureForFlatCoordinates(StencilTest PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_flat_coordinates OUTPUTS = ("z_gradh_exner",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], inv_dual_edge_length: np.ndarray, @@ -53,7 +53,7 @@ def reference( ) return dict(z_gradh_exner=z_gradh_exner) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat) z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py index 53555a19e6..96047f7b92 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_multiple_levels.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_horizontal_gradient_of_exner_pressure_for_multiple_levels_numpy( @@ -69,7 +69,7 @@ class TestComputeHorizontalGradientOfExnerPressureForMultipleLevels(StencilTest) PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_multiple_levels OUTPUTS = ("z_gradh_exner",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], inv_dual_edge_length: np.ndarray, @@ -91,7 +91,7 @@ def reference( ) return dict(z_gradh_exner=z_gradh_exner) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=ta.wpfloat) z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates.py index 0369fc2b9c..334563ebb5 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates_numpy( @@ -48,7 +48,7 @@ class TestComputeHorizontalGradientOfExnerPressureForNonflatCoordinates(StencilT PROGRAM = compute_horizontal_gradient_of_exner_pressure_for_nonflat_coordinates OUTPUTS = ("z_gradh_exner",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], inv_dual_edge_length: np.ndarray, @@ -68,7 +68,7 @@ def reference( ) return dict(z_gradh_exner=z_gradh_exner) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: inv_dual_edge_length = random_field(grid, dims.EdgeDim, dtype=wpfloat) z_exner_ex_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_kinetic_energy.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_kinetic_energy.py index a81376ec23..9204798241 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_kinetic_energy.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_kinetic_energy.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_horizontal_kinetic_energy_numpy(vn: np.ndarray, vt: np.ndarray) -> tuple: @@ -33,7 +33,7 @@ class TestComputeHorizontalKineticEnergy(StencilTest): PROGRAM = compute_horizontal_kinetic_energy OUTPUTS = ("vn_ie", "z_vt_ie", "z_kin_hor_e") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn: np.ndarray, @@ -43,7 +43,7 @@ def reference( vn_ie, z_vt_ie, z_kin_hor_e = compute_horizontal_kinetic_energy_numpy(vn, vt) return dict(vn_ie=vn_ie, z_vt_ie=z_vt_ie, z_kin_hor_e=z_kin_hor_e) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) vt = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_velocity_quantities_and_fluxes.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_velocity_quantities_and_fluxes.py index ed59ee339d..905e3f7b9f 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_velocity_quantities_and_fluxes.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_horizontal_velocity_quantities_and_fluxes.py @@ -113,7 +113,7 @@ class TestComputeHorizontalVelocityQuantitiesAndFluxes(stencil_tests.StencilTest ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], spatially_averaged_vn: np.ndarray, @@ -273,7 +273,7 @@ def reference( contravariant_correction_at_edges_on_model_levels=contravariant_correction_at_edges_on_model_levels, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: spatially_averaged_vn = data_alloc.zero_field(grid, dims.EdgeDim, dims.KDim) horizontal_gradient_of_normal_wind_divergence = data_alloc.zero_field( diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_hydrostatic_correction_term.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_hydrostatic_correction_term.py index 7eed5b8929..b22b00c1c5 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_hydrostatic_correction_term.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_hydrostatic_correction_term.py @@ -18,7 +18,12 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) def compute_hydrostatic_correction_term_numpy( @@ -106,7 +111,7 @@ class TestComputeHydrostaticCorrectionTerm(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], theta_v: np.ndarray, @@ -130,7 +135,7 @@ def reference( ) return dict(z_hydro_corr=z_hydro_corr) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: ikoffset = data_alloc.zero_field( grid, dims.EdgeDim, dims.E2CDim, dims.KDim, dtype=gtx.int32 diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_mass_flux.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_mass_flux.py index 330d0410a0..883904155e 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_mass_flux.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_mass_flux.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_mass_flux_numpy( @@ -36,7 +36,7 @@ class TestComputeMassFlux(StencilTest): PROGRAM = compute_mass_flux OUTPUTS = ("mass_fl_e", "z_theta_v_fl_e") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_rho_e: np.ndarray, @@ -54,7 +54,7 @@ def reference( return dict(mass_fl_e=mass_fl_e, z_theta_v_fl_e=z_theta_v_fl_e) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_rho_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) z_vn_avg = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py index 2cd2a83c8f..ca38682279 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_maximum_cfl_and_clip_contravariant_vertical_velocity.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils.data_allocation import random_field, random_mask, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_maximum_cfl_and_clip_contravariant_vertical_velocity_numpy( @@ -47,7 +47,7 @@ class TestComputeMaximumCflAndClipContravariantVerticalVelocity(StencilTest): PROGRAM = compute_maximum_cfl_and_clip_contravariant_vertical_velocity OUTPUTS = ("cfl_clipping", "vcfl", "z_w_con_c") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], ddqz_z_half: np.ndarray, @@ -70,7 +70,7 @@ def reference( z_w_con_c=z_w_con_c, ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: ddqz_z_half = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) z_w_con_c = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta.py index 79d910c5b9..1dc20f3bec 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_perturbation_of_rho_and_theta_numpy( @@ -37,7 +37,7 @@ class TestComputePerturbationOfRhoAndTheta(StencilTest): PROGRAM = compute_perturbation_of_rho_and_theta OUTPUTS = ("z_rth_pr_1", "z_rth_pr_2") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho: np.ndarray, @@ -51,7 +51,7 @@ def reference( ) return dict(z_rth_pr_1=z_rth_pr_1, z_rth_pr_2=z_rth_pr_2) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: rho = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) rho_ref_mc = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers.py index e224318650..e5b0b45929 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers_numpy( @@ -43,7 +43,7 @@ class TestComputePerturbationOfRhoAndThetaAndRhoInterfaceCellCenters(StencilTest PROGRAM = compute_perturbation_of_rho_and_theta_and_rho_interface_cell_centers OUTPUTS = ("rho_ic", "z_rth_pr_1", "z_rth_pr_2") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_c: np.ndarray, @@ -66,7 +66,7 @@ def reference( ) return dict(rho_ic=rho_ic, z_rth_pr_1=z_rth_pr_1, z_rth_pr_2=z_rth_pr_2) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfac_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) rho = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbed_quantities_and_interpolation.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbed_quantities_and_interpolation.py index 9611d9bdc1..0f2f0e27b0 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbed_quantities_and_interpolation.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_perturbed_quantities_and_interpolation.py @@ -104,7 +104,7 @@ class TestComputePerturbedQuantitiesAndInterpolation(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], current_rho: np.ndarray, @@ -347,7 +347,7 @@ def reference( d2dz2_of_temporal_extrapolation_of_perturbed_exner_on_model_levels=d2dz2_of_temporal_extrapolation_of_perturbed_exner_on_model_levels, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: reference_rho_at_cells_on_model_levels = data_alloc.random_field( grid, dims.CellDim, dims.KDim diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_results_for_thermodynamic_variables.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_results_for_thermodynamic_variables.py index 2efbdbddd9..de3caae45b 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_results_for_thermodynamic_variables.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_results_for_thermodynamic_variables.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference dycore_consts: Final = constants.PhysicsConstants() @@ -66,7 +66,7 @@ class TestComputeResultsForThermodynamicVariables(StencilTest): PROGRAM = compute_results_for_thermodynamic_variables OUTPUTS = ("rho_new", "exner_new", "theta_v_new") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_rho_expl: np.ndarray, @@ -102,7 +102,7 @@ def reference( ) return dict(rho_new=rho_new, exner_new=exner_new, theta_v_new=theta_v_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_rho_expl = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) vwind_impl_wgt = data_alloc.random_field(grid, dims.CellDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_rho_virtual_potential_temperatures_and_pressure_gradient.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_rho_virtual_potential_temperatures_and_pressure_gradient.py index 6f71a1f98a..e7c2a66767 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_rho_virtual_potential_temperatures_and_pressure_gradient.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_rho_virtual_potential_temperatures_and_pressure_gradient.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_rho_virtual_potential_temperatures_and_pressure_gradient_numpy( @@ -79,7 +79,7 @@ class TestComputeRhoVirtualPotentialTemperaturesAndPressureGradient(StencilTest) PROGRAM = compute_rho_virtual_potential_temperatures_and_pressure_gradient OUTPUTS = ("rho_ic", "z_theta_v_pr_ic", "theta_v_ic", "z_th_ddz_exner_c") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w: np.ndarray, @@ -128,7 +128,7 @@ def reference( z_th_ddz_exner_c=z_th_ddz_exner_c, ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: dtime = ta.wpfloat("1.0") wgt_nnow_rth = ta.wpfloat("2.0") diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_solver_coefficients_matrix.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_solver_coefficients_matrix.py index da06853a0a..69ddf0178c 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_solver_coefficients_matrix.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_solver_coefficients_matrix.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_solver_coefficients_matrix_numpy( @@ -44,7 +44,7 @@ class TestComputeSolverCoefficientsMatrix(StencilTest): PROGRAM = compute_solver_coefficients_matrix OUTPUTS = ("z_beta", "z_alpha") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], exner_nnow: np.ndarray, @@ -74,7 +74,7 @@ def reference( ) return dict(z_beta=z_beta, z_alpha=z_alpha) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: exner_nnow = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) rho_nnow = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_tangential_wind.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_tangential_wind.py index fbcc397990..f7c6de4573 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_tangential_wind.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_tangential_wind.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_tangential_wind_numpy( @@ -34,7 +34,7 @@ class TestComputeTangentialWind(StencilTest): PROGRAM = compute_tangential_wind OUTPUTS = ("vt",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vn: np.ndarray, @@ -44,7 +44,7 @@ def reference( vt = compute_tangential_wind_numpy(connectivities, vn, rbf_vec_coeff_e) return dict(vt=vt) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) rbf_vec_coeff_e = random_field(grid, dims.EdgeDim, dims.E2C2EDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py index ec566da678..d47771424d 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_theta_rho_face_values_and_pressure_gradient_and_update_vn.py @@ -160,7 +160,7 @@ class TestComputeThetaRhoPressureGradientAndUpdateVn(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_at_edges_on_model_levels: np.ndarray, @@ -431,14 +431,14 @@ def at_neighbor(i: int) -> np.ndarray: next_vn=next_vn, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"is_iau_active": value} for value in [True, False] ], # True for testing, False for benchmarking ids=lambda param: f"is_iau_active[{param['is_iau_active']}]", scope="class", ) - def input_data(self, request: pytest.FixtureRequest, grid: base.Grid) -> dict: + def input_data(self, grid: base.Grid, request: pytest.FixtureRequest) -> dict: geofac_grg_x = data_alloc.random_field(grid, dims.CellDim, dims.C2E2CODim) geofac_grg_y = data_alloc.random_field(grid, dims.CellDim, dims.C2E2CODim) current_vn = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_virtual_potential_temperatures_and_pressure_gradient.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_virtual_potential_temperatures_and_pressure_gradient.py index 4ef0d53930..08b262f548 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_virtual_potential_temperatures_and_pressure_gradient.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_virtual_potential_temperatures_and_pressure_gradient.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_virtual_potential_temperatures_and_pressure_gradient_numpy( @@ -59,7 +59,7 @@ class TestComputeVirtualPotentialTemperaturesAndPressureGradient(StencilTest): PROGRAM = compute_virtual_potential_temperatures_and_pressure_gradient OUTPUTS = ("z_theta_v_pr_ic", "theta_v_ic", "z_th_ddz_exner_c") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_c: np.ndarray, @@ -92,7 +92,7 @@ def reference( z_th_ddz_exner_c=z_th_ddz_exner_c, ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfac_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) z_rth_pr_2 = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_vn_on_lateral_boundary.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_vn_on_lateral_boundary.py index 50aec37834..893c4d6a0e 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_vn_on_lateral_boundary.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_compute_vn_on_lateral_boundary.py @@ -18,14 +18,14 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestComputeVnOnLateralBoundary(StencilTest): PROGRAM = compute_vn_on_lateral_boundary OUTPUTS = ("vn_new",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], grf_tend_vn: np.ndarray, @@ -36,7 +36,7 @@ def reference( vn_new = vn_now + dtime * grf_tend_vn return dict(vn_new=vn_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: grf_tend_vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) vn_now = random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_copy_cell_kdim_field_to_vp.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_copy_cell_kdim_field_to_vp.py index e1408308a9..a1b9ecd865 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_copy_cell_kdim_field_to_vp.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_copy_cell_kdim_field_to_vp.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def copy_cell_kdim_field_to_vp_numpy(field: np.ndarray) -> np.ndarray: @@ -31,14 +31,14 @@ class TestCopyCellKdimFieldToVp(StencilTest): PROGRAM = copy_cell_kdim_field_to_vp OUTPUTS = ("field_copy",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], field: np.ndarray, **kwargs: Any ) -> dict: field_copy = copy_cell_kdim_field_to_vp_numpy(field) return dict(field_copy=field_copy) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: field = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) field_copy = zero_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_at_top.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_at_top.py index 74c9b6845d..8a8fdc7dd3 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_at_top.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_at_top.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def extrapolate_at_top_numpy(wgtfacq_e: np.ndarray, vn: np.ndarray) -> np.ndarray: @@ -41,7 +41,7 @@ class TestExtrapolateAtTop(StencilTest): PROGRAM = extrapolate_at_top OUTPUTS = ("vn_ie",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfacq_e: np.ndarray, @@ -51,7 +51,7 @@ def reference( vn_ie = extrapolate_at_top_numpy(wgtfacq_e, vn) return dict(vn_ie=vn_ie) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfacq_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_temporally_exner_pressure.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_temporally_exner_pressure.py index a87d532ff4..ce49e1008c 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_temporally_exner_pressure.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_extrapolate_temporally_exner_pressure.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def extrapolate_temporally_exner_pressure_numpy( @@ -38,7 +38,7 @@ class TestExtrapolateTemporallyExnerPressure(StencilTest): PROGRAM = extrapolate_temporally_exner_pressure OUTPUTS = ("z_exner_ex_pr", "exner_pr") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], exner: np.ndarray, @@ -57,7 +57,7 @@ def reference( return dict(z_exner_ex_pr=z_exner_ex_pr, exner_pr=exner_pr) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: exner = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) exner_ref_mc = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_cell_kdim_field_with_zero_wp.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_cell_kdim_field_with_zero_wp.py index a0c2e0f902..74bb52efcd 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_cell_kdim_field_with_zero_wp.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_cell_kdim_field_with_zero_wp.py @@ -19,7 +19,12 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import zero_field -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) @pytest.mark.continuous_benchmarking @@ -40,7 +45,7 @@ class TestInitCellKdimFieldWithZeroWp(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], field_with_zero_wp: np.ndarray, @@ -49,7 +54,7 @@ def reference( field_with_zero_wp = np.zeros_like(field_with_zero_wp) return dict(field_with_zero_wp=field_with_zero_wp) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: field_with_zero_wp = zero_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_two_edge_kdim_fields_with_zero_wp.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_two_edge_kdim_fields_with_zero_wp.py index 77c5de7055..2289aa8428 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_two_edge_kdim_fields_with_zero_wp.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_init_two_edge_kdim_fields_with_zero_wp.py @@ -19,14 +19,14 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestInitTwoEdgeKdimFieldsWithZeroWp(StencilTest): PROGRAM = init_two_edge_kdim_fields_with_zero_wp OUTPUTS = ("edge_kdim_field_with_zero_wp_1", "edge_kdim_field_with_zero_wp_2") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], edge_kdim_field_with_zero_wp_1: np.ndarray, @@ -40,7 +40,7 @@ def reference( edge_kdim_field_with_zero_wp_2=edge_kdim_field_with_zero_wp_2, ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: edge_kdim_field_with_zero_wp_1 = zero_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) edge_kdim_field_with_zero_wp_2 = zero_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_cell_field_to_half_levels_vp.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_cell_field_to_half_levels_vp.py index 4cc48fd101..6079f83b79 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_cell_field_to_half_levels_vp.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_cell_field_to_half_levels_vp.py @@ -38,7 +38,7 @@ class TestInterpolateToHalfLevelsVp(stencil_tests.StencilTest): PROGRAM = interpolate_cell_field_to_half_levels_vp OUTPUTS = ("interpolation_to_half_levels_vp",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_c: np.ndarray, @@ -50,7 +50,7 @@ def reference( ) return dict(interpolation_to_half_levels_vp=interpolation_to_half_levels_vp) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: interpolant = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) wgtfac_c = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_contravariant_vertical_velocity_to_full_levels.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_contravariant_vertical_velocity_to_full_levels.py index 12f5fd8506..cb9aa416ec 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_contravariant_vertical_velocity_to_full_levels.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_contravariant_vertical_velocity_to_full_levels.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def interpolate_contravariant_vertical_velocity_to_full_levels_numpy( @@ -33,14 +33,14 @@ class TestInterpolateContravariantVerticalVelocityToFullLevels(StencilTest): PROGRAM = interpolate_contravariant_vertical_velocity_to_full_levels OUTPUTS = ("z_w_con_c_full",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_w_con_c: np.ndarray, **kwargs: Any ) -> dict: z_w_con_c_full = interpolate_contravariant_vertical_velocity_to_full_levels_numpy(z_w_con_c) return dict(z_w_con_c_full=z_w_con_c_full) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_w_con_c = random_field( grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}, dtype=vpfloat diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_rho_theta_v_to_half_levels_and_compute_temperature_vertical_gradient.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_rho_theta_v_to_half_levels_and_compute_temperature_vertical_gradient.py index c36fa68bfa..fe0da91e2a 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_rho_theta_v_to_half_levels_and_compute_temperature_vertical_gradient.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_rho_theta_v_to_half_levels_and_compute_temperature_vertical_gradient.py @@ -59,7 +59,7 @@ class TestInterpolateRhoThetaVToHalfLevelsAndComputePressureBuoyancyAcceleration ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_at_cells_on_half_levels: np.ndarray, @@ -182,7 +182,7 @@ def reference( nonhydro_buoy_at_cells_on_half_levels=nonhydro_buoy_at_cells_on_half_levels, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: w = data_alloc.random_field(grid, dims.CellDim, dims.KDim) contravariant_correction_at_cells_on_half_levels = data_alloc.random_field( diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_cell_center.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_cell_center.py index 8f018db9ca..ad46e61da3 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_cell_center.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_cell_center.py @@ -41,7 +41,7 @@ class TestInterpolateToCellCenter(stencil_tests.StencilTest): PROGRAM = interpolate_to_cell_center OUTPUTS = ("interpolation",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], interpolant: np.ndarray, @@ -51,7 +51,7 @@ def reference( interpolation = interpolate_to_cell_center_numpy(connectivities, interpolant, e_bln_c_s) return dict(interpolation=interpolation) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: interpolant = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) e_bln_c_s = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_surface.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_surface.py index 2dc775909d..178be984ff 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_surface.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_to_surface.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def interpolate_to_surface_numpy( @@ -36,7 +36,7 @@ class TestInterpolateToSurface(StencilTest): PROGRAM = interpolate_to_surface OUTPUTS = ("interpolation_to_surface",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], interpolant: np.ndarray, @@ -51,7 +51,7 @@ def reference( ) return dict(interpolation_to_surface=interpolation_to_surface) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: interpolant = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) wgtfacq_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_and_vt_to_ie_and_compute_ekin_on_edges.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_and_vt_to_ie_and_compute_ekin_on_edges.py index b998025020..7aa0f319e1 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_and_vt_to_ie_and_compute_ekin_on_edges.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_and_vt_to_ie_and_compute_ekin_on_edges.py @@ -19,14 +19,14 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestInterpolateVnAndVtToIeAndComputeEkinOnEdges(StencilTest): PROGRAM = interpolate_vn_and_vt_to_ie_and_compute_ekin_on_edges OUTPUTS = ("vn_ie", "z_vt_ie", "z_kin_hor_e") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_e: np.ndarray, @@ -45,7 +45,7 @@ def reference( z_kin_hor_e[:, 0] = 0 return dict(vn_ie=vn_ie, z_vt_ie=z_vt_ie, z_kin_hor_e=z_kin_hor_e) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfac_e = zero_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_to_half_levels_and_compute_kinetic_energy_on_edges.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_to_half_levels_and_compute_kinetic_energy_on_edges.py index b2a19e3566..5b3585739f 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_to_half_levels_and_compute_kinetic_energy_on_edges.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vn_to_half_levels_and_compute_kinetic_energy_on_edges.py @@ -57,7 +57,7 @@ class TestInterpolateVnToHalfLevelsAndComputeKineticEnergyOnEdges(stencil_tests. PROGRAM = interpolate_vn_to_half_levels_and_compute_kinetic_energy_on_edges OUTPUTS = ("vn_ie", "z_kin_hor_e") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_e: np.ndarray, @@ -84,7 +84,7 @@ def reference( z_kin_hor_e=z_kin_hor_e, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfac_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) vn = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vt_to_interface_edges.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vt_to_interface_edges.py index 4fc1660fb6..504c65c300 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vt_to_interface_edges.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_interpolate_vt_to_interface_edges.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def interpolate_vt_to_interface_edges_numpy( @@ -34,7 +34,7 @@ class TestInterpolateVtToInterfaceEdges(StencilTest): PROGRAM = interpolate_vt_to_interface_edges OUTPUTS = ("z_vt_ie",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfac_e: np.ndarray, @@ -50,7 +50,7 @@ def reference( z_vt_ie[subset] = interpolate_vt_to_interface_edges_numpy(wgtfac_e, vt)[subset] return dict(z_vt_ie=z_vt_ie) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfac_e = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) vt = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl.py index 3ca6d13109..5b6b53c3c2 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl_numpy( @@ -35,7 +35,7 @@ class TestMoIconInterpolationScalarCells2vertsScalarRiDsl(StencilTest): PROGRAM = mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl OUTPUTS = ("p_vert_out",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_cell_in: np.ndarray, @@ -49,7 +49,7 @@ def reference( p_vert_out=p_vert_out, ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: p_cell_in = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) c_intp = random_field(grid, dims.VertexDim, dims.V2CDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_math_divrot_rot_vertex_ri_dsl.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_math_divrot_rot_vertex_ri_dsl.py index b819687c83..e860f3c7f6 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_math_divrot_rot_vertex_ri_dsl.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_mo_math_divrot_rot_vertex_ri_dsl.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def mo_math_divrot_rot_vertex_ri_dsl_numpy( @@ -35,7 +35,7 @@ class TestMoMathDivrotRotVertexRiDsl(StencilTest): PROGRAM = mo_math_divrot_rot_vertex_ri_dsl OUTPUTS = ("rot_vec",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vec_e: np.ndarray, @@ -45,7 +45,7 @@ def reference( rot_vec = mo_math_divrot_rot_vertex_ri_dsl_numpy(connectivities, vec_e, geofac_rot) return dict(rot_vec=rot_vec) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vec_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) geofac_rot = random_field(grid, dims.VertexDim, dims.V2EDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_lower_boundary_condition_for_w_and_contravariant_correction.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_lower_boundary_condition_for_w_and_contravariant_correction.py index af727d761e..e53f6d5a31 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_lower_boundary_condition_for_w_and_contravariant_correction.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_lower_boundary_condition_for_w_and_contravariant_correction.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def set_lower_boundary_condition_for_w_and_contravariant_correction_numpy( @@ -36,7 +36,7 @@ class TestInitLowerBoundaryConditionForWAndContravariantCorrection(StencilTest): PROGRAM = set_lower_boundary_condition_for_w_and_contravariant_correction OUTPUTS = ("w_nnew", "z_contr_w_fl_l") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w_concorr_c: np.ndarray, @@ -51,7 +51,7 @@ def reference( ) return dict(w_nnew=w_nnew, z_contr_w_fl_l=z_contr_w_fl_l) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: w_concorr_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) z_contr_w_fl_l = zero_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_theta_v_prime_ic_at_lower_boundary.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_theta_v_prime_ic_at_lower_boundary.py index 122f1913ef..a6bd5c5ad6 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_theta_v_prime_ic_at_lower_boundary.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_set_theta_v_prime_ic_at_lower_boundary.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference from .test_interpolate_to_surface import interpolate_to_surface_numpy @@ -44,7 +44,7 @@ class TestInitThetaVPrimeIcAtLowerBoundary(StencilTest): PROGRAM = set_theta_v_prime_ic_at_lower_boundary OUTPUTS = ("z_theta_v_pr_ic", "theta_v_ic") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], wgtfacq_c: np.ndarray, @@ -63,7 +63,7 @@ def reference( ) return dict(z_theta_v_pr_ic=z_theta_v_pr_ic, theta_v_ic=theta_v_ic) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: wgtfacq_c = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) z_rth_pr = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_back_substitution.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_back_substitution.py index 076e84b767..fc5164b972 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_back_substitution.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_back_substitution.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def solve_tridiagonal_matrix_for_w_back_substitution_numpy( @@ -42,7 +42,7 @@ class TestSolveTridiagonalMatrixForWBackSubstitution(StencilTest): PROGRAM = solve_tridiagonal_matrix_for_w_back_substitution OUTPUTS = ("w",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_q: np.ndarray, @@ -52,7 +52,7 @@ def reference( w_new = solve_tridiagonal_matrix_for_w_back_substitution_numpy(connectivities, z_q=z_q, w=w) return dict(w=w_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_q = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) w = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_forward_sweep.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_forward_sweep.py index 7bd38f9619..6348d5fe9d 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_forward_sweep.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_solve_tridiagonal_matrix_for_w_forward_sweep.py @@ -18,7 +18,7 @@ from icon4py.model.common.grid import base as base_grid from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def solve_tridiagonal_matrix_for_w_forward_sweep_numpy( @@ -61,7 +61,7 @@ class TestSolveTridiagonalMatrixForWForwardSweep(StencilTest): PROGRAM = solve_tridiagonal_matrix_for_w_forward_sweep OUTPUTS = ("w", "z_q") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], vwind_impl_wgt: np.ndarray, @@ -92,7 +92,7 @@ def reference( ) return dict(z_q=z_q_ref, w=w_ref) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base_grid.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: vwind_impl_wgt = data_alloc.random_field(grid, dims.CellDim, dtype=ta.wpfloat) theta_v_ic = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_spatially_average_flux_or_velocity.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_spatially_average_flux_or_velocity.py index d9d8ae062c..2446395ae7 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_spatially_average_flux_or_velocity.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_spatially_average_flux_or_velocity.py @@ -20,7 +20,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def spatially_average_flux_or_velocity_numpy( @@ -40,7 +40,7 @@ class TestSpatiallyAverageFluxOrVelocity(StencilTest): PROGRAM = spatially_average_flux_or_velocity OUTPUTS = ("spatially_averaged_flux_or_velocity",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], e_flx_avg: np.ndarray, @@ -53,7 +53,7 @@ def reference( return dict(spatially_averaged_flux_or_velocity=spatially_averaged_flux_or_velocity) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: e_flx_avg = random_field(grid, dims.EdgeDim, dims.E2C2EODim, dtype=wpfloat) flux_or_velocity = random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_density_exner_wind.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_density_exner_wind.py index 612a940991..804fb5a06e 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_density_exner_wind.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_density_exner_wind.py @@ -18,14 +18,14 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestUpdateDensityExnerWind(StencilTest): PROGRAM = update_density_exner_wind OUTPUTS = ("rho_new", "exner_new", "w_new") - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_now: np.ndarray, @@ -42,7 +42,7 @@ def reference( w_new = w_now + dtime * grf_tend_w return dict(rho_new=rho_new, exner_new=exner_new, w_new=w_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: rho_now = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) grf_tend_rho = random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_dynamical_exner_time_increment.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_dynamical_exner_time_increment.py index ffcb582b55..85da099115 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_dynamical_exner_time_increment.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_dynamical_exner_time_increment.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def update_dynamical_exner_time_increment_numpy( @@ -38,7 +38,7 @@ class TestUpdateDynamicalExnerTimeIncrement(StencilTest): PROGRAM = update_dynamical_exner_time_increment OUTPUTS = ("exner_dyn_incr",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], exner: np.ndarray, @@ -58,7 +58,7 @@ def reference( ) return dict(exner_dyn_incr=exner_dyn_incr) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: ndyn_substeps_var, dtime = wpfloat("10.0"), wpfloat("12.0") exner = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_flux_weighted.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_flux_weighted.py index 5a0e5422da..d44d7a60fe 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_flux_weighted.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_flux_weighted.py @@ -19,7 +19,12 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) @pytest.mark.continuous_benchmarking @@ -40,7 +45,7 @@ class TestUpdateMassFluxWeighted(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], rho_ic: np.ndarray, @@ -60,7 +65,7 @@ def reference( ) return dict(mass_flx_ic=mass_flx_ic) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: r_nsubsteps = wpfloat("10.0") rho_ic = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_volume_flux.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_volume_flux.py index 64cd7fab4f..c637f7ec04 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_volume_flux.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_mass_volume_flux.py @@ -16,7 +16,7 @@ from icon4py.model.common.grid import base from icon4py.model.common.states import utils as state_utils from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def update_mass_volume_flux_numpy( @@ -43,7 +43,7 @@ class TestUpdateMassVolumeFlux(StencilTest): "vol_flx_ic", ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], z_contr_w_fl_l: np.ndarray, @@ -67,7 +67,7 @@ def reference( ) return dict(mass_flx_ic=mass_flx_ic, vol_flx_ic=vol_flx_ic) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: z_contr_w_fl_l = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) rho_ic = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_theta_and_exner_in_halo.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_theta_and_exner_in_halo.py index 8f01a98f00..4605f52cd1 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_theta_and_exner_in_halo.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_theta_and_exner_in_halo.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference dycore_consts: Final = constants.PhysicsConstants() @@ -32,7 +32,7 @@ class TestUpdateThetaV(StencilTest): "exner_new", ) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], mask_prog_halo_c: np.ndarray, @@ -63,7 +63,7 @@ def reference( ) return dict(theta_v_new=theta_v_new, exner_new=exner_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: mask_prog_halo_c = data_alloc.random_mask(grid, dims.CellDim) rho_now = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_wind.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_wind.py index 32f31fe859..c22e0dffd3 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_wind.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_update_wind.py @@ -17,14 +17,14 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestUpdateWind(StencilTest): PROGRAM = update_wind OUTPUTS = ("w_new",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], w_now: np.ndarray, @@ -35,7 +35,7 @@ def reference( w_new = w_now + dtime * grf_tend_w return dict(w_new=w_new) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: dtime = wpfloat("10.0") w_now = random_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_corrector_step.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_corrector_step.py index 4d871fcfbf..adc54262c6 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_corrector_step.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_corrector_step.py @@ -91,7 +91,7 @@ class TestVerticallyImplicitSolverAtCorrectorStep(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], next_w: np.ndarray, @@ -396,7 +396,7 @@ def reference( exner_dynamical_increment=exner_dynamical_increment, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"at_first_substep": afs, "at_last_substep": als, "lprep_adv": la, "is_iau_active": ia} for afs, als, la, ia in [ @@ -414,7 +414,7 @@ def reference( ), ) def input_data( - self, request: pytest.FixtureRequest, grid: base.Grid + self, grid: base.Grid, request: pytest.FixtureRequest ) -> dict[str, gtx.Field | state_utils.ScalarType]: geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim) mass_flux_at_edges_on_model_levels = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_predictor_step.py b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_predictor_step.py index cc48d17c80..b34a284ede 100644 --- a/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_predictor_step.py +++ b/model/atmosphere/dycore/tests/dycore/stencil_tests/test_vertically_implicit_dycore_solver_at_predictor_step.py @@ -95,7 +95,7 @@ class TestVerticallyImplicitSolverAtPredictorStep(stencil_tests.StencilTest): ), } - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], contravariant_correction_at_cells_on_half_levels: np.ndarray, @@ -394,7 +394,7 @@ def reference( exner_dynamical_increment=exner_dynamical_increment, ) - @pytest.fixture( + @stencil_tests.input_data_fixture( params=[ {"at_first_substep": afs, "is_iau_active": ia, "divdamp_type": dvdmpt} for afs, ia, dvdmpt in [ @@ -408,7 +408,7 @@ def reference( ), ) def input_data( - self, request: pytest.FixtureRequest, grid: base.Grid + self, grid: base.Grid, request: pytest.FixtureRequest ) -> dict[str, gtx.Field | state_utils.ScalarType]: geofac_div = data_alloc.random_field(grid, dims.CellDim, dims.C2EDim) mass_flux_at_edges_on_model_levels = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim) diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_T_from_internal_energy.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_T_from_internal_energy.py index 1dddcb000c..a3553efe45 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_T_from_internal_energy.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_T_from_internal_energy.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestTFromInternalEnergy(StencilTest): PROGRAM = T_from_internal_energy OUTPUTS = ("temperature",) - @staticmethod + @static_reference def reference( grid, u: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(temperature=np.full(u.shape, 255.75599999999997)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( u=data_alloc.constant_field( diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel.py index c362dd7ece..eaeade9ace 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToGraupel(StencilTest): PROGRAM = cloud_to_graupel OUTPUTS = ("riming_graupel_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, rho: np.ndarray, qc: np.ndarray, qg: np.ndarray, **kwargs ) -> dict: return dict(riming_graupel_rate=np.full(t.shape, 2.7054723496793982e-10)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 256.983, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel_default.py index 9000f55ab3..4489df647a 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_graupel_default.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToGraupelDefault(StencilTest): PROGRAM = cloud_to_graupel OUTPUTS = ("riming_graupel_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, rho: np.ndarray, qc: np.ndarray, qg: np.ndarray, **kwargs ) -> dict: return dict(riming_graupel_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain.py index 4a6b064888..7bb11c2f95 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToRain(StencilTest): PROGRAM = cloud_to_rain OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, qc: np.ndarray, qr: np.ndarray, nc: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0045484481075162512)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 267.25, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain_default.py index 820355c8c2..155092c040 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_rain_default.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToRainDefault(StencilTest): PROGRAM = cloud_to_rain OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, qc: np.ndarray, qr: np.ndarray, nc: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow.py index 90a9f18d34..a8693b0ab9 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToSnow(StencilTest): PROGRAM = cloud_to_snow OUTPUTS = ("riming_snow_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(riming_snow_rate=np.full(t.shape, 9.5431874564438999e-10)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 256.571, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow_default.py index 701a03e949..1af88b77f5 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_to_snow_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudToSnowDefault(StencilTest): PROGRAM = cloud_to_snow OUTPUTS = ("riming_snow_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(riming_snow_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice.py index ae897cab44..636a202430 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudXIce(StencilTest): PROGRAM = cloud_x_ice OUTPUTS = ("freezing_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, qc: np.ndarray, qi: np.ndarray, dt: wpfloat, **kwargs ) -> dict: return dict(freezing_rate=np.full(t.shape, -1.5008166666666666e-08)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field( diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice_default.py index 2a09f91f90..cb0ddc9d8a 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_cloud_x_ice_default.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestCloudXIceDefault(StencilTest): PROGRAM = cloud_x_ice OUTPUTS = ("freezing_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, qc: np.ndarray, qi: np.ndarray, dt: wpfloat, **kwargs ) -> dict: return dict(freezing_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 256.835, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion.py index 377c940ed3..ee1d48a1b8 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion.py @@ -15,18 +15,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestDepositionAutoConversion(StencilTest): PROGRAM = deposition_auto_conversion OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference(grid, qi: np.ndarray, m_ice: np.ndarray, ice_dep: np.ndarray, **kwargs) -> dict: return dict(conversion_rate=np.full(qi.shape, 6.6430804299795412e-08)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field( diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion_default.py index 971bc9c76b..9ea4caef6c 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_auto_conversion_default.py @@ -14,18 +14,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestDepositionAutoConversionDefault(StencilTest): PROGRAM = deposition_auto_conversion OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference(grid, qi: np.ndarray, m_ice: np.ndarray, ice_dep: np.ndarray, **kwargs) -> dict: return dict(conversion_rate=np.full(qi.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 2.02422e-23, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_factor.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_factor.py index d89b8452a9..2ab0694a2f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_factor.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_deposition_factor.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestDepositionFactor(StencilTest): PROGRAM = deposition_factor OUTPUTS = ("deposition_rate",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, qvsi: np.ndarray, **kwargs) -> dict: return dict(deposition_rate=np.full(t.shape, 1.3234329478493952e-05)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 272.731, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_dqsatdT_rho.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_dqsatdT_rho.py index 65522326e2..a23eaa249f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_dqsatdT_rho.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_dqsatdT_rho.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestQsatRho(StencilTest): PROGRAM = dqsatdT_rho OUTPUTS = ("derivative",) - @staticmethod + @static_reference def reference(grid, qs: np.ndarray, t: np.ndarray, **kwargs) -> dict: return dict(derivative=np.full(t.shape, 0.00030825070286492049)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qs=data_alloc.constant_field(grid, 0.00448941, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_fall_speed.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_fall_speed.py index 162ad4c301..41a28d9f3f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_fall_speed.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_fall_speed.py @@ -13,20 +13,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestFallSpeed(StencilTest): PROGRAM = fall_speed OUTPUTS = ("speed",) - @staticmethod + @static_reference def reference( grid, density: np.ndarray, prefactor: wpfloat, offset: wpfloat, exponent: wpfloat, **kwargs ) -> dict: return dict(speed=np.full(density.shape, 0.67882452435647411)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( density=data_alloc.zero_field(grid, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain.py index 6f52329dc9..4c7c7d5f2e 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestGraupelToRain(StencilTest): PROGRAM = graupel_to_rain OUTPUTS = ("rain_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(rain_rate=np.full(t.shape, 5.9748142538569357e-13)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 280.156, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain_default.py index bd8b18b74e..00c2617e06 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_graupel_to_rain_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestGraupelToRainDefault(StencilTest): PROGRAM = graupel_to_rain OUTPUTS = ("rain_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(rain_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 280.156, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation.py index 374b5c738e..a9d4e9b7aa 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation.py @@ -14,14 +14,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceDepositionNucleation(StencilTest): PROGRAM = ice_deposition_nucleation OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -34,7 +34,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(t.shape, 1.6836299999999999e-13)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 160.9, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation_default.py index b18697e349..bf6f8219eb 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_deposition_nucleation_default.py @@ -14,14 +14,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceDepositionNucleationDefault(StencilTest): PROGRAM = ice_deposition_nucleation OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -34,7 +34,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 272.731, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_mass.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_mass.py index bb9bdf1a45..293c6e5f62 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_mass.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_mass.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceNumber(StencilTest): PROGRAM = ice_mass OUTPUTS = ("mass",) - @staticmethod + @static_reference def reference(grid, qi: np.ndarray, ni: np.ndarray, **kwargs) -> dict: return dict(mass=np.full(qi.shape, 1.0e-12)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 2.02422e-23, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_number.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_number.py index 05b5fa336c..8432f7f3a6 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_number.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_number.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceNumber(StencilTest): PROGRAM = ice_number OUTPUTS = ("number",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, rho: np.ndarray, **kwargs) -> dict: return dict(number=np.full(t.shape, 5.0507995893464388)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 272.731, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_sticking.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_sticking.py index 52532333b9..a5d702016c 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_sticking.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_sticking.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceSticking(StencilTest): PROGRAM = ice_sticking OUTPUTS = ("sticking_factor",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, **kwargs) -> dict: return dict(sticking_factor=np.full(t.shape, 0.8697930232044021)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 271.6, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel.py index 4f2bff9e32..bec143389f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceToGraupel(StencilTest): PROGRAM = ice_to_graupel OUTPUTS = ("aggregation",) - @staticmethod + @static_reference def reference( grid, rho: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(aggregation=np.full(rho.shape, 7.1049436957697864e-19)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( rho=data_alloc.constant_field(grid, 1.04848, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel_default.py index 4f2bff9e32..bec143389f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_graupel_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceToGraupel(StencilTest): PROGRAM = ice_to_graupel OUTPUTS = ("aggregation",) - @staticmethod + @static_reference def reference( grid, rho: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(aggregation=np.full(rho.shape, 7.1049436957697864e-19)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( rho=data_alloc.constant_field(grid, 1.04848, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow.py index 7072fc1c8c..b6f8990d3c 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceToSnow(StencilTest): PROGRAM = ice_to_snow OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, qi: np.ndarray, ns: np.ndarray, lam: np.ndarray, sticking_eff: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(qi.shape, 3.3262745200740486e-11)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 6.43223e-08, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow_default.py index bf6ad46db8..b7cab42343 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_ice_to_snow_default.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestIceToSnowDefault(StencilTest): PROGRAM = ice_to_snow OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, qi: np.ndarray, ns: np.ndarray, lam: np.ndarray, sticking_eff: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(qi.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 7.95122e-25, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_internal_energy.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_internal_energy.py index 3da5d59413..da3046747a 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_internal_energy.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_internal_energy.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestInternalEnergy(StencilTest): PROGRAM = internal_energy OUTPUTS = ("energy",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(energy=np.full(t.shape, 38265357.270336017)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 255.756, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_ice_rho.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_ice_rho.py index e29dc9911a..f692d865da 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_ice_rho.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_ice_rho.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestQsatIceRho(StencilTest): PROGRAM = qsat_ice_rho OUTPUTS = ("pressure",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, rho: np.ndarray, **kwargs) -> dict: return dict(pressure=np.full(t.shape, 0.0074981245870634101)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho.py index 8e29622ff0..2ba1a88af9 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestQsatRho(StencilTest): PROGRAM = qsat_rho OUTPUTS = ("pressure",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, rho: np.ndarray, **kwargs) -> dict: return dict(pressure=np.full(t.shape, 0.0069027592942577506)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho_tmelt.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho_tmelt.py index 6e13021be7..af5a6fe834 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho_tmelt.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_qsat_rho_tmelt.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestQsatRho(StencilTest): PROGRAM = qsat_rho_tmelt OUTPUTS = ("pressure",) - @staticmethod + @static_reference def reference(grid, rho: np.ndarray, **kwargs) -> dict: return dict(pressure=np.full(rho.shape, 0.0038828182695875113)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( rho=data_alloc.constant_field(grid, 1.24783, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_1.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_1.py index bc1c75ce0d..b67bd27d3f 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_1.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_1.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToGraupel1(StencilTest): PROGRAM = rain_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -35,7 +35,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 5.1570340525841922e-17)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 258.542, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_2.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_2.py index 1a26ea9b2e..95e4545a23 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_2.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_2.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToGraupel1(StencilTest): PROGRAM = rain_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -35,7 +35,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 1.0044914238516472e-12)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 230.542, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_3.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_3.py index 0d6a3dc0a5..4d2596be66 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_3.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_3.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToGraupel3(StencilTest): PROGRAM = rain_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -35,7 +35,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 5.1423851647153399e-17)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 258.542, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_default.py index 00ece8df68..4c83b8df09 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_graupel_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToGraupelDefault(StencilTest): PROGRAM = rain_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -35,7 +35,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 272.731, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor.py index c5528bc37a..0e11ffb96b 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToVapor(StencilTest): PROGRAM = rain_to_vapor OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 2.8556697055499901e-19)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 258.542, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor_default.py index fb681877af..c84b0f3656 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_rain_to_vapor_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestRainToVaporDefault(StencilTest): PROGRAM = rain_to_vapor OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 258.542, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_ice.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_ice.py index d56e9a0a01..eea8f21ab2 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_ice.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_ice.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSatPresIce(StencilTest): PROGRAM = sat_pres_ice OUTPUTS = ("pressure",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, **kwargs) -> dict: return dict(pressure=np.full(t.shape, 1216.7746246067475)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_water.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_water.py index 6bde29be18..847a00a927 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_water.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_sat_pres_water.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSatPresWater(StencilTest): PROGRAM = sat_pres_water OUTPUTS = ("pressure",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, **kwargs) -> dict: return dict(pressure=np.full(t.shape, 1120.1604149806028)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_saturation_adjustment.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_saturation_adjustment.py index 69c06c9e0b..b3e1edb5a8 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_saturation_adjustment.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_saturation_adjustment.py @@ -19,7 +19,7 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference if TYPE_CHECKING: @@ -30,7 +30,7 @@ class TestSaturationAdjustment(StencilTest): PROGRAM = saturation_adjustment OUTPUTS = ("te_out", "qve_out", "qce_out") - @staticmethod + @static_reference def reference( grid: base_grid.Grid, te: np.ndarray, @@ -42,7 +42,7 @@ def reference( qce_out=np.full(te.shape, 9.5724552280369163e-007), ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base_grid.Grid) -> dict: return dict( te=data_alloc.constant_field( diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_lambda.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_lambda.py index 3c30334f90..37f3a13ea0 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_lambda.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_lambda.py @@ -13,18 +13,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowLambda(StencilTest): PROGRAM = snow_lambda OUTPUTS = ("riming_snow_rate",) - @staticmethod + @static_reference def reference(grid, rho: np.ndarray, qs: np.ndarray, ns: np.ndarray, **kwargs) -> dict: return dict(riming_snow_rate=np.full(rho.shape, 1.0e10)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( rho=data_alloc.constant_field(grid, 1.12204, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number.py index 0887fae8c9..e0a600984d 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowNumber(StencilTest): PROGRAM = snow_number OUTPUTS = ("number",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, rho: np.ndarray, qs: np.ndarray, **kwargs) -> dict: return dict(number=np.full(t.shape, 3813750.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 276.302, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number_default.py index 86c5a7aacd..a97f7cb7c1 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_number_default.py @@ -12,18 +12,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowNumberDefault(StencilTest): PROGRAM = snow_number OUTPUTS = ("number",) - @staticmethod + @static_reference def reference(grid, t: np.ndarray, rho: np.ndarray, qs: np.ndarray, **kwargs) -> dict: return dict(number=np.full(t.shape, 8.00e5)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 276.302, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel.py index e69fc05ae6..347b3afb47 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowToGraupel(StencilTest): PROGRAM = snow_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, rho: np.ndarray, qc: np.ndarray, qs: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(t.shape, 6.2696154545048011e-10)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 265.85, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel_default.py index 1614d1aa14..921b5fdeec 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_graupel_default.py @@ -12,20 +12,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowToGraupelDefault(StencilTest): PROGRAM = snow_to_graupel OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, rho: np.ndarray, qc: np.ndarray, qs: np.ndarray, **kwargs ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 281.157, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain.py index 4b25992492..f1996fde9b 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowToRainDefault(StencilTest): PROGRAM = snow_to_rain OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 3.7268547760462804e-07)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 275.83, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain_default.py index b3a6b6ff6c..5f0f242df5 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_snow_to_rain_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestSnowToRainDefault(StencilTest): PROGRAM = snow_to_rain OUTPUTS = ("conversion_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -31,7 +31,7 @@ def reference( ) -> dict: return dict(conversion_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 265.83, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel.py index 318c53c90e..6a1251e02a 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXGraupel(StencilTest): PROGRAM = vapor_x_graupel OUTPUTS = ("exchange_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -34,7 +34,7 @@ def reference( ) -> dict: return dict(exchange_rate=np.full(t.shape, -6.8498666666666675e-13)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 278.026, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel_default.py index 8420bd7063..e6eafcbd55 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_graupel_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXGraupelDefault(StencilTest): PROGRAM = vapor_x_graupel OUTPUTS = ("exchange_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -34,7 +34,7 @@ def reference( ) -> dict: return dict(exchange_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 278.026, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice.py index e76dc730df..7b0b084e82 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXIceDefault(StencilTest): PROGRAM = vapor_x_ice OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, qi: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(qi.shape, 2.2106162342610385e-09)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 9.53048e-07, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice_default.py index e45648728a..934d34ebb4 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_ice_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXIceDefault(StencilTest): PROGRAM = vapor_x_ice OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, qi: np.ndarray, @@ -32,7 +32,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(qi.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( qi=data_alloc.constant_field(grid, 2.02422e-23, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow.py index bb074808aa..0ad32ff19d 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXSnow(StencilTest): PROGRAM = vapor_x_snow OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -38,7 +38,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(t.shape, -8.6584296264775935e-13)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 278.748, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow_default.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow_default.py index 26b02e3dee..e0841111ff 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow_default.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vapor_x_snow_default.py @@ -12,14 +12,14 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVaporXSnowDefault(StencilTest): PROGRAM = vapor_x_snow OUTPUTS = ("vapor_deposition_rate",) - @staticmethod + @static_reference def reference( grid, t: np.ndarray, @@ -38,7 +38,7 @@ def reference( ) -> dict: return dict(vapor_deposition_rate=np.full(t.shape, 0.0)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( t=data_alloc.constant_field(grid, 278.748, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_ice.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_ice.py index 8b9f9795e8..174b9f70cc 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_ice.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_ice.py @@ -14,18 +14,18 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVelScaleFactorIce(StencilTest): PROGRAM = vel_scale_factor_ice OUTPUTS = ("scale_factor",) - @staticmethod + @static_reference def reference(grid, xrho: np.ndarray, **kwargs) -> dict: return dict(scale_factor=np.full(xrho.shape, 1.1158596098981044)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( xrho=data_alloc.constant_field(grid, 1.17873, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_snow.py b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_snow.py index 18e7048ab7..6013c88cc7 100644 --- a/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_snow.py +++ b/model/atmosphere/subgrid_scale_physics/muphys/tests/muphys/stencil_tests/test_vel_scale_factor_snow.py @@ -14,20 +14,20 @@ from icon4py.model.common import dimension as dims from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference class TestVelScaleFactorSnow(StencilTest): PROGRAM = vel_scale_factor_snow OUTPUTS = ("scale_factor",) - @staticmethod + @static_reference def reference( grid, xrho: np.ndarray, rho: np.ndarray, t: np.ndarray, qs: np.ndarray, **kwargs ) -> dict: return dict(scale_factor=np.full(xrho.shape, 0.06633230453931642)) - @pytest.fixture + @input_data_fixture def input_data(self, grid): return dict( xrho=data_alloc.constant_field(grid, 1.17787, dims.CellDim, dims.KDim, dtype=wpfloat), diff --git a/model/common/tests/common/interpolation/stencil_tests/test_cell_2_edge_interpolation.py b/model/common/tests/common/interpolation/stencil_tests/test_cell_2_edge_interpolation.py index eb8ad994c6..19826fb1f5 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_cell_2_edge_interpolation.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_cell_2_edge_interpolation.py @@ -25,7 +25,7 @@ class TestCell2EdgeInterpolation(stencil_tests.StencilTest): PROGRAM = cell_2_edge_interpolation OUTPUTS = ("out_field",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], in_field: np.ndarray, @@ -40,7 +40,7 @@ def reference( out_field=out_field, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: in_field = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=ta.wpfloat) coeff = data_alloc.random_field(grid, dims.EdgeDim, dims.E2CDim, dtype=ta.wpfloat) diff --git a/model/common/tests/common/interpolation/stencil_tests/test_compute_cell_2_vertex_interpolation.py b/model/common/tests/common/interpolation/stencil_tests/test_compute_cell_2_vertex_interpolation.py index b68124bbda..1e145e8d8e 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_compute_cell_2_vertex_interpolation.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_compute_cell_2_vertex_interpolation.py @@ -26,7 +26,7 @@ class TestComputeCells2VertsInterpolation(stencil_tests.StencilTest): PROGRAM = compute_cell_2_vertex_interpolation OUTPUTS = ("vert_out",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], cell_in: np.ndarray, @@ -41,7 +41,7 @@ def reference( vert_out=out_field, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: cell_in = data_alloc.random_field(grid, dims.CellDim, dims.KDim, dtype=types.wpfloat) c_int = data_alloc.random_field(grid, dims.VertexDim, dims.V2CDim, dtype=types.wpfloat) diff --git a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_pressure.py b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_pressure.py index 2f0471e4fe..8ff7054297 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_pressure.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_pressure.py @@ -24,7 +24,7 @@ class TestDiagnosePressure(stencil_tests.StencilTest): PROGRAM = diagnose_pressure OUTPUTS = ("pressure", "pressure_ifc") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], surface_pressure: np.ndarray, @@ -52,7 +52,7 @@ def reference( pressure_ifc=pressure_ifc, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: ddqz_z_full = data_alloc.random_field( grid, dims.CellDim, dims.KDim, low=1.0, dtype=ta.wpfloat diff --git a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_surface_pressure.py b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_surface_pressure.py index 55e0967f6a..2d878d0a9c 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_surface_pressure.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_surface_pressure.py @@ -24,7 +24,7 @@ class TestDiagnoseSurfacePressure(stencil_tests.StencilTest): PROGRAM = diagnose_surface_pressure OUTPUTS = ("surface_pressure",) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], exner: np.ndarray, @@ -47,7 +47,7 @@ def reference( surface_pressure=surface_pressure, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: low = 1.0e-2 exner = data_alloc.random_field(grid, dims.CellDim, dims.KDim, low=1.0e-6, dtype=ta.wpfloat) diff --git a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_temperature.py b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_temperature.py index 1e03d6b648..0bec0823eb 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_diagnose_temperature.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_diagnose_temperature.py @@ -24,7 +24,7 @@ class TestDiagnoseTemperature(stencil_tests.StencilTest): PROGRAM = diagnose_virtual_temperature_and_temperature OUTPUTS = ("virtual_temperature", "temperature") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], qv: np.ndarray, @@ -45,7 +45,7 @@ def reference( temperature=temperature, ) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: theta_v = data_alloc.random_field( grid, dims.CellDim, dims.KDim, low=1.0e-4, high=1.0, dtype=ta.wpfloat diff --git a/model/common/tests/common/interpolation/stencil_tests/test_edge_2_cell_vector_rbf_interpolation.py b/model/common/tests/common/interpolation/stencil_tests/test_edge_2_cell_vector_rbf_interpolation.py index a4dea61823..3e3639c594 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_edge_2_cell_vector_rbf_interpolation.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_edge_2_cell_vector_rbf_interpolation.py @@ -25,7 +25,7 @@ class TestEdge2CellVectorRBFInterpolation(stencil_tests.StencilTest): PROGRAM = edge_2_cell_vector_rbf_interpolation OUTPUTS = ("p_u_out", "p_v_out") - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_e_in: np.ndarray, @@ -41,7 +41,7 @@ def reference( return dict(p_v_out=p_v_out, p_u_out=p_u_out) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_e_in = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=ta.wpfloat) ptr_coeff_1 = data_alloc.random_field(grid, dims.CellDim, dims.C2E2C2EDim, dtype=ta.wpfloat) diff --git a/model/common/tests/common/interpolation/stencil_tests/test_interpolate_edge_field_to_half_levels_vp.py b/model/common/tests/common/interpolation/stencil_tests/test_interpolate_edge_field_to_half_levels_vp.py index 027b0ab492..9095de3a6a 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_interpolate_edge_field_to_half_levels_vp.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_interpolate_edge_field_to_half_levels_vp.py @@ -11,7 +11,6 @@ import numpy as np import pytest -import icon4py.model.testing.stencil_tests as test_helpers from icon4py.model.common import dimension as dims from icon4py.model.common.grid import base as base_grid from icon4py.model.common.interpolation.stencils.interpolate_edge_field_to_half_levels_vp import ( @@ -19,6 +18,7 @@ ) from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field +from icon4py.model.testing import stencil_tests def interpolate_edge_field_to_half_levels_vp_numpy( @@ -33,11 +33,11 @@ def interpolate_edge_field_to_half_levels_vp_numpy( return interpolation_to_half_levels_vp -class TestInterpolateToHalfLevelsVp(test_helpers.StencilTest): +class TestInterpolateToHalfLevelsVp(stencil_tests.StencilTest): PROGRAM = interpolate_edge_field_to_half_levels_vp OUTPUTS = ("interpolation_to_half_levels_vp",) - @staticmethod + @stencil_tests.static_reference def reference( grid: base_grid.Grid, wgtfac_e: np.ndarray, interpolant: np.ndarray, **kwargs: Any ) -> dict: @@ -46,7 +46,7 @@ def reference( ) return dict(interpolation_to_half_levels_vp=interpolation_to_half_levels_vp) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base_grid.Grid) -> dict: interpolant = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) wgtfac_e = random_field(grid, dims.EdgeDim, dims.KDim, dtype=vpfloat) diff --git a/model/common/tests/common/interpolation/stencil_tests/test_mo_intp_rbf_rbf_vec_interpol_vertex.py b/model/common/tests/common/interpolation/stencil_tests/test_mo_intp_rbf_rbf_vec_interpol_vertex.py index 07104cbd89..046eaeaf91 100644 --- a/model/common/tests/common/interpolation/stencil_tests/test_mo_intp_rbf_rbf_vec_interpol_vertex.py +++ b/model/common/tests/common/interpolation/stencil_tests/test_mo_intp_rbf_rbf_vec_interpol_vertex.py @@ -18,7 +18,12 @@ ) from icon4py.model.common.type_alias import wpfloat from icon4py.model.common.utils import data_allocation as data_alloc -from icon4py.model.testing.stencil_tests import StandardStaticVariants, StencilTest +from icon4py.model.testing.stencil_tests import ( + StandardStaticVariants, + StencilTest, + input_data_fixture, + static_reference, +) @pytest.mark.continuous_benchmarking @@ -39,7 +44,7 @@ class TestMoIntpRbfRbfVecInterpolVertex(StencilTest): ), } - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], p_e_in: np.ndarray, @@ -70,7 +75,7 @@ def reference( return dict(p_v_out=p_v_final_out, p_u_out=p_u_final_out) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: p_e_in = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, dtype=wpfloat) ptr_coeff_1 = data_alloc.random_field(grid, dims.VertexDim, dims.V2EDim, dtype=wpfloat) diff --git a/model/common/tests/common/math/stencil_tests/test_cell_horizontal_gradients_by_green_gauss_method.py b/model/common/tests/common/math/stencil_tests/test_cell_horizontal_gradients_by_green_gauss_method.py index bf5d44ebd2..1e3dcf27c8 100644 --- a/model/common/tests/common/math/stencil_tests/test_cell_horizontal_gradients_by_green_gauss_method.py +++ b/model/common/tests/common/math/stencil_tests/test_cell_horizontal_gradients_by_green_gauss_method.py @@ -19,7 +19,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat, wpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def cell_horizontal_gradients_by_green_gauss_method_numpy( @@ -48,7 +48,7 @@ class TestMoMathGradientsGradGreenGaussCellDsl(StencilTest): PROGRAM = cell_horizontal_gradients_by_green_gauss_method OUTPUTS = ("out",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], scalar_field: np.ndarray, @@ -66,7 +66,7 @@ def reference( out=(p_grad_1_u, p_grad_1_v), ) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: scalar_field = random_field(grid, dims.CellDim, dims.KDim, dtype=vpfloat) geofac_grg_x = random_field(grid, dims.CellDim, dims.C2E2CODim, dtype=wpfloat) diff --git a/model/common/tests/common/math/stencil_tests/test_compute_first_vertical_derivative.py b/model/common/tests/common/math/stencil_tests/test_compute_first_vertical_derivative.py index 5cd46b15ff..b25d93f014 100644 --- a/model/common/tests/common/math/stencil_tests/test_compute_first_vertical_derivative.py +++ b/model/common/tests/common/math/stencil_tests/test_compute_first_vertical_derivative.py @@ -17,7 +17,7 @@ from icon4py.model.common.states import utils as state_utils from icon4py.model.common.type_alias import vpfloat from icon4py.model.common.utils.data_allocation import random_field, zero_field -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference def compute_first_vertical_derivative_numpy( @@ -31,7 +31,7 @@ class TestComputeFirstVerticalDerivative(StencilTest): PROGRAM = compute_first_vertical_derivative_at_cells OUTPUTS = ("first_vertical_derivative",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], cell_kdim_field: np.ndarray, @@ -43,7 +43,7 @@ def reference( ) return dict(first_vertical_derivative=first_vertical_derivative) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict[str, gtx.Field | state_utils.ScalarType]: cell_kdim_field = random_field( grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}, dtype=vpfloat diff --git a/model/common/tests/common/math/unit_tests/test_helpers.py b/model/common/tests/common/math/unit_tests/test_helpers.py index e1de50194d..8533dd4f0f 100644 --- a/model/common/tests/common/math/unit_tests/test_helpers.py +++ b/model/common/tests/common/math/unit_tests/test_helpers.py @@ -56,7 +56,7 @@ class TestAverageTwoVerticalLevelsDownwardsOnEdges(stencil_tests.StencilTest): ), ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], input_field: np.ndarray, @@ -66,7 +66,7 @@ def reference( average = 0.5 * (input_field + offset) return dict(average=average) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: input_field = data_alloc.zero_field(grid, dims.EdgeDim, dims.KDim, extend={dims.KDim: 1}) result = data_alloc.random_field(grid, dims.EdgeDim, dims.KDim, extend={dims.KDim: 1}) @@ -90,7 +90,7 @@ class TestAverageTwoVerticalLevelsDownwardsOnCells(stencil_tests.StencilTest): ), ) - @staticmethod + @stencil_tests.static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], input_field: np.ndarray, @@ -100,7 +100,7 @@ def reference( res = 0.5 * (input_field + np.roll(input_field, shift=-1, axis=1))[:, : shp[1] - 1] return dict(average=res) - @pytest.fixture + @stencil_tests.input_data_fixture def input_data(self, grid: base.Grid) -> dict: input_field = data_alloc.random_field(grid, dims.CellDim, dims.KDim, extend={dims.KDim: 1}) result = data_alloc.zero_field(grid, dims.CellDim, dims.KDim) diff --git a/model/common/tests/common/math/unit_tests/test_operators.py b/model/common/tests/common/math/unit_tests/test_operators.py index b487d1a50b..f4491049ab 100644 --- a/model/common/tests/common/math/unit_tests/test_operators.py +++ b/model/common/tests/common/math/unit_tests/test_operators.py @@ -19,7 +19,7 @@ from icon4py.model.testing import reference_funcs from icon4py.model.testing.fixtures.datatest import backend_like from icon4py.model.testing.fixtures.stencil_tests import grid, grid_manager -from icon4py.model.testing.stencil_tests import StencilTest +from icon4py.model.testing.stencil_tests import StencilTest, input_data_fixture, static_reference @pytest.mark.embedded_remap_error @@ -27,7 +27,7 @@ class TestNabla2OnCell(StencilTest): PROGRAM = compute_nabla2_on_cell OUTPUTS = ("nabla2_psi_c",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], psi_c: np.ndarray, @@ -37,7 +37,7 @@ def reference( nabla2_psi_c_np = reference_funcs.nabla2_on_cell_numpy(connectivities, psi_c, geofac_n2s) return dict(nabla2_psi_c=nabla2_psi_c_np) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base_grid.Grid) -> dict: psi_c = constant_field(grid, 1.0, dims.CellDim) geofac_n2s = constant_field(grid, 2.0, dims.CellDim, dims.C2E2CODim) @@ -56,7 +56,7 @@ class TestNabla2OnCellK(StencilTest): PROGRAM = compute_nabla2_on_cell_k OUTPUTS = ("nabla2_psi_c",) - @staticmethod + @static_reference def reference( connectivities: dict[gtx.Dimension, np.ndarray], psi_c: np.ndarray, @@ -66,7 +66,7 @@ def reference( nabla2_psi_c_np = reference_funcs.nabla2_on_cell_k_numpy(connectivities, psi_c, geofac_n2s) return dict(nabla2_psi_c=nabla2_psi_c_np) - @pytest.fixture + @input_data_fixture def input_data(self, grid: base.Grid) -> dict: psi_c = constant_field(grid, 1.0, dims.CellDim, dims.KDim) geofac_n2s = constant_field(grid, 2.0, dims.CellDim, dims.C2E2CODim) diff --git a/model/testing/src/icon4py/model/testing/stencil_tests.py b/model/testing/src/icon4py/model/testing/stencil_tests.py index d19a11ebdf..01c95ddb7c 100644 --- a/model/testing/src/icon4py/model/testing/stencil_tests.py +++ b/model/testing/src/icon4py/model/testing/stencil_tests.py @@ -10,9 +10,12 @@ import contextlib import dataclasses +import functools +import inspect import os +import types from collections.abc import Callable, Generator, Mapping, Sequence -from typing import Any, ClassVar, Final +from typing import TYPE_CHECKING, Any, ClassVar, Final, TypeAlias import gt4py.next as gtx import numpy as np @@ -33,6 +36,68 @@ from icon4py.model.common.utils import device_utils +_STENCIL_REFERENCE_MARKER: Final = "__stencil_test_reference__" +_INPUT_DATA_FIXTURE_MARKER: Final = "__stencil_test_input_fixture__" + + +def _static_reference(func: types.FunctionType | staticmethod) -> staticmethod: + """Decorator to mark the `reference` method of a `StencilTest` suite.""" + if not isinstance(func, (types.FunctionType, staticmethod)): + raise TypeError( + f"The 'reference' function must be a regular function or staticmethod but got {type(func)}." + ) + if func.__name__ != "reference": + raise ValueError( + f"The 'reference' method must be named 'reference' but got '{func.__name__}'." + ) + if not isinstance(func, staticmethod): + func = staticmethod(func) + + setattr(func, _STENCIL_REFERENCE_MARKER, True) + + return func + + +def _input_data_fixture( + func: types.FunctionType | None = None, **kwargs: Any +) -> pytest.fixtures.FixtureFunctionMarker: + """ + Decorator to mark the `input_data` method of a `StencilTest` suite as a pytest fixture. + + Perform some checks on the decorated function and forward all the keyword + arguments to `pytest.fixture` for parametrization and scoping (default: "class"). + """ + if func is None: + return functools.partial(input_data_fixture, **kwargs) + + if not isinstance(func, types.FunctionType): + raise TypeError(f"The 'input_data' method must be a regular function but got {type(func)}.") + if func.__name__ != "input_data": + raise ValueError( + f"The 'input_data' method must be named 'input_data' but got '{func.__name__}'." + ) + func_params = tuple(inspect.signature(func).parameters.keys()) + if func_params[:2] != ("self", "grid"): + raise ValueError( + f"The 'input_data' method signature must be 'input_data(self, grid, ...)' but got" + f" '{func.__name__}{func_params}'." + ) + + kwargs.setdefault("scope", "class") + fixt = pytest.fixture(**kwargs)(func) + setattr(fixt, _INPUT_DATA_FIXTURE_MARKER, True) + + return fixt + + +if TYPE_CHECKING: + static_reference: TypeAlias = staticmethod + input_data_fixture: Final = pytest.fixture +else: + static_reference = _static_reference + input_data_fixture = _input_data_fixture + + def allocate_data( allocator: gtx_typing.Allocator | None, input_data: dict[ @@ -42,13 +107,14 @@ def allocate_data( def _allocate_field(f: gtx.Field) -> gtx.Field: return constructors.as_field(domain=f.domain, data=f.ndarray, allocator=allocator) - input_data = { + device_input_data = { k: gtx_named_collections.tree_map_named_collection(_allocate_field)(v) if not gtx.is_scalar_type(v) and k != "domain" else v for k, v in input_data.items() } - return input_data + + return device_input_data @dataclasses.dataclass(frozen=True) @@ -84,8 +150,8 @@ def test_and_benchmark( self: StencilTest, benchmark: Any, # should be `pytest_benchmark.fixture.BenchmarkFixture` but pytest_benchmark is not typed grid: base.Grid, - _properly_allocated_input_data: dict[str, gtx.Field | tuple[gtx.Field, ...]], - _configured_program: Callable[..., None], + device_input_data: dict[str, gtx.Field | tuple[gtx.Field, ...]], + configured_program: Callable[..., None], request: pytest.FixtureRequest, ) -> None: skip_stenciltest_verification = request.config.getoption( @@ -100,14 +166,12 @@ def test_and_benchmark( ), **{ k: v.asnumpy() if isinstance(v, gtx.Field) else v - for k, v in _properly_allocated_input_data.items() + for k, v in device_input_data.items() }, ) - _configured_program(**_properly_allocated_input_data, offset_provider=grid.connectivities) - self._verify_stencil_test( - input_data=_properly_allocated_input_data, reference_outputs=reference_outputs - ) + configured_program(**device_input_data, offset_provider=grid.connectivities) + self._verify_stencil_test(input_data=device_input_data, reference_outputs=reference_outputs) if not skip_stenciltest_benchmark: warmup_rounds = int(os.getenv("ICON4PY_STENCIL_TEST_WARMUP_ROUNDS", "1")) @@ -115,9 +179,9 @@ def test_and_benchmark( # Use of `pedantic` to explicitly control warmup rounds and iterations benchmark.pedantic( - _configured_program, + configured_program, args=(), - kwargs=dict(**_properly_allocated_input_data, offset_provider=grid.connectivities), + kwargs=dict(**device_input_data, offset_provider=grid.connectivities), rounds=int( os.getenv("ICON4PY_STENCIL_TEST_BENCHMARK_ROUNDS", "3") ), # 30 iterations in total should be stable enough @@ -147,18 +211,18 @@ def _get_metrics_id_program_callback( gtx_hooks.program_call_context.register( _get_metrics_id_program_callback, name=METRICS_KEY_EXTRACTOR ) - _configured_program( - **_properly_allocated_input_data, offset_provider=grid.connectivities - ) + configured_program(**device_input_data, offset_provider=grid.connectivities) gtx_hooks.program_call_context.remove(METRICS_KEY_EXTRACTOR) - assert metrics_key is not None, "Metrics key could not be recovered during run." - assert metrics_key.startswith( - _configured_program.__name__ - ), f"Metrics key ({metrics_key}) does not start with the program name ({_configured_program.__name__})" - - assert ( - len(_configured_program._compiled_programs.compiled_programs) == 1 - ), "Multiple compiled programs found, cannot extract metrics." + + if metrics_key is None: + raise RuntimeError("Metrics key could not be recovered during run.") + if not metrics_key.startswith(configured_program.__name__): + raise RuntimeError( + f"Metrics key ({metrics_key}) does not start with the program name ({configured_program.__name__})" + ) + if len(configured_program._compiled_programs.compiled_programs) != 1: + raise RuntimeError("Multiple compiled programs found, cannot extract metrics.") + metrics_data = gtx_metrics.sources compute_samples = metrics_data[metrics_key].metrics["compute"].samples # exclude: @@ -169,9 +233,10 @@ def _get_metrics_id_program_callback( initial_program_iterations_to_skip = warmup_rounds * iterations + ( 2 if skip_stenciltest_verification else 3 ) - assert ( - len(compute_samples) > initial_program_iterations_to_skip - ), "Not enough samples collected to compute metrics." + + if len(compute_samples) <= initial_program_iterations_to_skip: + raise RuntimeError("Not enough samples collected to compute metrics.") + benchmark.extra_info["gtx_metrics"] = compute_samples[ initial_program_iterations_to_skip: ] @@ -204,7 +269,7 @@ class StencilTest: reference: ClassVar[Callable[..., Mapping[str, np.ndarray | tuple[np.ndarray, ...]]]] @pytest.fixture - def _configured_program( + def configured_program( self, backend_like: model_backends.BackendLike, static_variant: Sequence[str], @@ -235,16 +300,22 @@ def _configured_program( return test_func @pytest.fixture - def _properly_allocated_input_data( + def device_input_data( self, input_data: dict[str, gtx.Field | tuple[gtx.Field, ...]], backend_like: model_backends.BackendLike, - ) -> dict[str, Any]: - # TODO(havogt): this is a workaround, - # because in the `input_data` fixture provided by the user - # it does not allocate for the correct device. + ) -> Generator[dict[str, gtx.Field | tuple[gtx.Field, ...]]]: + # This is partially a workaround, because in the `input_data` fixture, + # provided by the user it does not allocate for the correct device, + # but it is also convenient for the verification step, where we need + # the data on the host as numpy arrays. allocator = model_backends.get_allocator(backend_like) - return allocate_data(allocator=allocator, input_data=input_data) + device_data = allocate_data(allocator=allocator, input_data=input_data) + try: + yield device_data + finally: + # explicitly clear data dict after test to prevent potential memory leaks + device_data.clear() def _verify_stencil_test( self, @@ -295,12 +366,30 @@ def static_variant(request: pytest.FixtureRequest) -> Sequence[str]: _, variant = request.param return () if variant is None else variant - def __init_subclass__(cls, **kwargs: Any) -> None: - super().__init_subclass__(**kwargs) + def __init_subclass__(cls, *args: Any, **kwargs: Any) -> None: + super().__init_subclass__(*args, **kwargs) + + # Check the conventions for `reference` and `input_data` methods + if not hasattr(cls, "reference"): + raise TypeError( + f"{cls.__name__} StencilTest subclass does not implement a 'reference' method." + ) + if not getattr(cls.__dict__["reference"], _STENCIL_REFERENCE_MARKER, False): + raise RuntimeError( + f"The 'reference' method of {cls.__name__} must be decorated with '@static_reference'." + ) + if not hasattr(cls, "input_data"): + raise TypeError( + f"{cls.__name__} StencilTest subclass does not implement an 'input_data' method." + ) + if not getattr(cls.__dict__["input_data"], _INPUT_DATA_FIXTURE_MARKER, False): + raise RuntimeError( + f"The 'input_data' method of {cls.__name__} must be decorated with '@input_data_fixture'." + ) setattr(cls, f"test_{cls.__name__}", test_and_benchmark) - # decorate `static_variant` with parametrized fixtures, since the + # Decorate `static_variant` with parametrized fixtures, since the # parametrization is only available in the concrete subclass definition if cls.STATIC_PARAMS is None: # not parametrized, return an empty tuple