From 09bee92e07924fd7c188be4d6316bf371dfbfc2e Mon Sep 17 00:00:00 2001 From: anton-seaice Date: Wed, 18 Sep 2024 16:18:34 +1000 Subject: [PATCH] PEP --- payu/models/cesm_cmeps.py | 14 +++++++------- test/models/access-om3/test_access_om3.py | 8 +++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/payu/models/cesm_cmeps.py b/payu/models/cesm_cmeps.py index 6332898b..4ffe6407 100644 --- a/payu/models/cesm_cmeps.py +++ b/payu/models/cesm_cmeps.py @@ -198,7 +198,7 @@ def _setup_checks(self): if nthreads < 1: raise ValueError(f"The number of {realm}_nthreads ({nthreads}) in " f"{NUOPC_CONFIG} must be at least 1.") - + if nthreads > 1: npes = nthreads*ntasks*pestride # this is taken from @@ -217,7 +217,7 @@ def _setup_checks(self): comp = "MED" # med and cpl names are both used in runconfig else: comp = realm.upper() - + if comp in self.runconfig.get_component_list(): io_section = f"{comp}_modelio" nc_type = self.runconfig.get(io_section, "pio_typename") @@ -242,17 +242,17 @@ def _setup_checks(self): case "netcdf4p" | "pnetcdf": niotasks = int(self.runconfig.get(io_section, "pio_numiotasks")) iostride = int(self.runconfig.get(io_section, "pio_stride")) - if (niotasks<=0) : + if (niotasks <= 0): warn(f"The pio_numiotasks for {io_section} in {NUOPC_CONFIG} is " "not set, using model default") - if (iostride<=0) : + if (iostride <= 0): warn(f"The pio_stride for {io_section} in {NUOPC_CONFIG} is " "not set, using model default") if (all([ - niotasks>0, - iostride>0, + niotasks > 0, + iostride > 0, (ioroot + (niotasks-1)*iostride) >= npes - ])): + ])): raise ValueError( f"The iolayout for {io_section} in {NUOPC_CONFIG} is " "requesting out of range cpus" diff --git a/test/models/access-om3/test_access_om3.py b/test/models/access-om3/test_access_om3.py index df78147a..18544eb7 100644 --- a/test/models/access-om3/test_access_om3.py +++ b/test/models/access-om3/test_access_om3.py @@ -278,14 +278,15 @@ def test__setup_checks_pio_async(pio_typename, pio_async_interface): with pytest.warns( Warning, match="does not do consistency checks for asynchronous pio" - ): + ): model._setup_checks() teardown_cmeps_config() + @pytest.mark.parametrize("pio_numiotasks, pio_stride", [ (1, -99), - (-99, 1), + (-99, 1), ]) def test__setup_checks_bad_io(pio_numiotasks, pio_stride): cmeps_config(1) @@ -310,4 +311,5 @@ def test__setup_checks_bad_io(pio_numiotasks, pio_stride): ): model._setup_checks() - teardown_cmeps_config() \ No newline at end of file + teardown_cmeps_config() + \ No newline at end of file