From c1c266ec4f661558087c4ad1df4b50ee9925a762 Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Tue, 3 Mar 2026 09:56:41 +0100 Subject: [PATCH 1/2] tests: minor cleanup in tests - add `__init__.py` files where missing - `List` -> `list` and `Tuple` -> `tuple` - NDSL has no `Namelist` anymore - cleanup unused import and code in `test_init_from_geos.py` --- tests/main/__init__.py | 0 tests/main/driver/test_driver.py | 4 ++-- tests/main/driver/test_example_configs.py | 13 ++++++------- tests/main/fv3core/__init__.py | 0 tests/main/fv3core/test_dycore_call.py | 3 +-- tests/main/fv3core/test_init_from_geos.py | 6 ------ tests/main/physics/__init__.py | 0 tests/mpi/__init__.py | 0 tests/mpi/ext_grid/__init__.py | 0 tests/mpi/restart/__init__.py | 0 tests/savepoint/__init__.py | 0 tests/savepoint/test_checkpoints.py | 7 +++---- tests/savepoint/translate/translate_driver.py | 4 +++- 13 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 tests/main/__init__.py create mode 100644 tests/main/fv3core/__init__.py create mode 100644 tests/main/physics/__init__.py create mode 100644 tests/mpi/__init__.py create mode 100644 tests/mpi/ext_grid/__init__.py create mode 100644 tests/mpi/restart/__init__.py create mode 100644 tests/savepoint/__init__.py diff --git a/tests/main/__init__.py b/tests/main/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/main/driver/test_driver.py b/tests/main/driver/test_driver.py index c48b6510c..6e3f08e8b 100644 --- a/tests/main/driver/test_driver.py +++ b/tests/main/driver/test_driver.py @@ -1,6 +1,6 @@ import unittest.mock from datetime import datetime, timedelta -from typing import Literal, Tuple +from typing import Literal import pytest @@ -22,7 +22,7 @@ def get_driver_config( hours: int = 0, minutes: int = 0, seconds: int = 0, - layout: Tuple[int, int] = (1, 1), + layout: tuple[int, int] = (1, 1), frequency: int = 1, output_initial_state=False, start_time_type: Literal["timedelta", "datetime"] = "timedelta", diff --git a/tests/main/driver/test_example_configs.py b/tests/main/driver/test_example_configs.py index f8e77c833..e16ce84c9 100644 --- a/tests/main/driver/test_example_configs.py +++ b/tests/main/driver/test_example_configs.py @@ -1,6 +1,5 @@ import os from pathlib import Path -from typing import List import pytest import yaml @@ -9,7 +8,7 @@ from tests.paths import EXAMPLE_CONFIGS_DIR, JENKINS_CONFIGS_DIR -TESTED_CONFIGS: List[str] = [ +TESTED_CONFIGS: list[str] = [ "baroclinic_c12.yaml", "baroclinic_c12_dp.yaml", "baroclinic_c12_explicit_physics.yaml", @@ -20,7 +19,7 @@ "baroclinic_c48_6ranks_serialbox_test.yaml", "analytic_test.yaml", ] -EXCLUDED_CONFIGS: List[str] = [ +EXCLUDED_CONFIGS: list[str] = [ # We don't test serialbox example because it loads namelist # filepath that are not in git "baroclinic_c12_from_serialbox.yaml", @@ -33,13 +32,13 @@ ] -TESTED_JENKINS_CONFIGS: List[str] = [ +TESTED_JENKINS_CONFIGS: list[str] = [ "baroclinic_c48_6ranks_dycore_only.yaml", "baroclinic_c192_6ranks.yaml", "baroclinic_c192_54ranks.yaml", ] -EXCLUDED_JENKINS_CONFIGS: List[str] = [ +EXCLUDED_JENKINS_CONFIGS: list[str] = [ # We don't test serialbox example because it loads namelist # filepath that are not in git "baroclinic_c48_6ranks_dycore_only_serialbox.yaml", @@ -61,7 +60,7 @@ ], ) def test_all_configs_tested_or_excluded( - config_dir: Path, tested_configs: List[str], excluded_configs: List[str] + config_dir: Path, tested_configs: list[str], excluded_configs: list[str] ): """ If any configs are not tested or excluded, add them to TESTED_CONFIGS or @@ -84,7 +83,7 @@ def test_all_configs_tested_or_excluded( pytest.param(JENKINS_CONFIGS_DIR, TESTED_JENKINS_CONFIGS), ], ) -def test_example_config_can_initialize(path: Path, file_list: List[str]): +def test_example_config_can_initialize(path: Path, file_list: list[str]): for file_name in file_list: with open(path / file_name, "r") as f: config = DriverConfig.from_dict(yaml.safe_load(f)) diff --git a/tests/main/fv3core/__init__.py b/tests/main/fv3core/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/main/fv3core/test_dycore_call.py b/tests/main/fv3core/test_dycore_call.py index 7cc9552ff..43262c84c 100644 --- a/tests/main/fv3core/test_dycore_call.py +++ b/tests/main/fv3core/test_dycore_call.py @@ -2,7 +2,6 @@ from dataclasses import fields from datetime import timedelta from pathlib import Path -from typing import Tuple import pyfv3.initialization.analytic_init as ai from ndsl import ( @@ -27,7 +26,7 @@ from pyfv3.initialization.analytic_init import AnalyticCase -def setup_dycore() -> Tuple[DynamicalCore, DycoreState, Timer]: +def setup_dycore() -> tuple[DynamicalCore, DycoreState, Timer]: backend = Backend("st:numpy:cpu:IJK") config = DynamicalCoreConfig( layout=(1, 1), diff --git a/tests/main/fv3core/test_init_from_geos.py b/tests/main/fv3core/test_init_from_geos.py index 3947ddd93..4b24c5787 100644 --- a/tests/main/fv3core/test_init_from_geos.py +++ b/tests/main/fv3core/test_init_from_geos.py @@ -1,6 +1,5 @@ import f90nml import numpy as np -import pytest # noqa from ndsl.config import Backend from pace import NullComm @@ -108,11 +107,6 @@ def test_geos_wrapper(): namelist["nx_tile"] + 2 * nhalo + 1, namelist["nz"], ) - shape_z_interface = ( - namelist["nx_tile"] + 2 * nhalo, - namelist["nx_tile"] + 2 * nhalo, - namelist["nz"] + 1, - ) shape2d = ( namelist["nx_tile"] + 2 * nhalo, namelist["nx_tile"] + 2 * nhalo, diff --git a/tests/main/physics/__init__.py b/tests/main/physics/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/mpi/__init__.py b/tests/mpi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/mpi/ext_grid/__init__.py b/tests/mpi/ext_grid/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/mpi/restart/__init__.py b/tests/mpi/restart/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/savepoint/__init__.py b/tests/savepoint/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/savepoint/test_checkpoints.py b/tests/savepoint/test_checkpoints.py index 2a80abd32..259401f71 100644 --- a/tests/savepoint/test_checkpoints.py +++ b/tests/savepoint/test_checkpoints.py @@ -1,7 +1,6 @@ import dataclasses from datetime import timedelta from pathlib import Path -from typing import List, Tuple import dacite import f90nml @@ -37,7 +36,7 @@ def get_grid( - data_path: Path, rank: int, layout: Tuple[int, int], backend: Backend + data_path: Path, rank: int, layout: tuple[int, int], backend: Backend ) -> Grid: ds_grid: xr.Dataset = xr.open_dataset(data_path / "Grid-Info.nc").isel(savepoint=0) grid = TranslateGrid( @@ -58,7 +57,7 @@ def __init__( self._ds = ds self._translate = translate - def new_state(self) -> Tuple[DycoreState, GridData]: + def new_state(self) -> tuple[DycoreState, GridData]: input_data = dataset_to_dict(self._ds.copy()) state, grid_data = self._translate.prepare_data(input_data) return state, grid_data @@ -202,7 +201,7 @@ def set_manual_thresholds(thresholds: SavepointThresholds): entry[name] = Threshold(relative=0.0, absolute=0.0) -def merge_thresholds(all_thresholds: List[SavepointThresholds]): +def merge_thresholds(all_thresholds: list[SavepointThresholds]): thresholds = all_thresholds[0] for other_thresholds in all_thresholds[1:]: for savepoint_name in thresholds.savepoints: diff --git a/tests/savepoint/translate/translate_driver.py b/tests/savepoint/translate/translate_driver.py index 59016e913..4c85368e1 100644 --- a/tests/savepoint/translate/translate_driver.py +++ b/tests/savepoint/translate/translate_driver.py @@ -1,4 +1,6 @@ -from ndsl import Namelist, QuantityFactory, SubtileGridSizer +from f90nml import Namelist + +from ndsl import QuantityFactory, SubtileGridSizer from ndsl.constants import N_HALO_DEFAULT from pace import Driver, DriverConfig, TendencyState from pyfv3 import DynamicalCoreConfig From 4583921454aa4387989e87a5879bc4fdda91df3b Mon Sep 17 00:00:00 2001 From: Roman Cattaneo Date: Thu, 5 Mar 2026 19:02:37 +0100 Subject: [PATCH 2/2] remove stale reference to ndsl.Namelist --- tests/savepoint/test_checkpoints.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/savepoint/test_checkpoints.py b/tests/savepoint/test_checkpoints.py index 259401f71..316c42050 100644 --- a/tests/savepoint/test_checkpoints.py +++ b/tests/savepoint/test_checkpoints.py @@ -13,7 +13,6 @@ CubedSpherePartitioner, GridIndexing, MPIComm, - Namelist, Quantity, QuantityFactory, StencilConfig, @@ -67,7 +66,7 @@ def test_fv_dynamics( backend: str, data_path: Path, calibrate_thresholds: bool, threshold_path: Path ): print("start test call") - namelist = Namelist.from_f90nml(f90nml.read(data_path / "input.nml")) + namelist = f90nml.read(data_path / "input.nml") threshold_filename = threshold_path / "fv_dynamics.yaml" communicator = CubedSphereCommunicator( comm=MPIComm(),