@@ -72,9 +72,8 @@ def test_zco_uniform():
7272 zco = Zco (ds_bathy , jpk = 51 )
7373
7474 # Compare zco mesh with analytical VS finite difference e3
75- expected , actual = (
76- zco (** kwargs , ln_e3_dep = ln_e3_dep ) for ln_e3_dep in (True , False )
77- )
75+ expected = zco (** kwargs , ln_e3_dep = True )
76+ actual = zco (** kwargs , ln_e3_dep = False )
7877 eps = 1.0e-14 # truncation errors
7978 xr .testing .assert_allclose (expected , actual , rtol = eps , atol = 0 )
8079
@@ -98,34 +97,54 @@ def test_zco_errors():
9897 """Make sure we raise informative errors"""
9998
10099 # Input parameters
101- kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 )
100+ kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 , ppkth = 1 , ppacr = 1 )
102101
103102 # Generate test data
104103 ds_bathy = Bathymetry (1.0e3 , 1.2e3 , 1 , 1 ).flat (5.0e3 )
105104 zco = Zco (ds_bathy , jpk = 10 )
106105
107106 # Without ldbletanh flag, only allow all pps set or none of them
108- with pytest .raises (ValueError , match = "ppa2.*MUST be all None or float" ):
109- zco (** kwargs , ppa2 = 1 )
107+ with pytest .raises (
108+ ValueError , match = "ppa2, ppkth2 and ppacr2 MUST be all None or float"
109+ ):
110+ zco (** kwargs , ppa2 = 1 , ppkth2 = 1 , ppacr2 = None )
110111
111112 # When ldbletanh flag is True, all coefficients must be specified
112- with pytest .raises (ValueError , match = "ppa2.* MUST be all float" ):
113- zco (** kwargs , ldbletanh = True , ppa2 = None )
113+ with pytest .raises (ValueError , match = "ppa2, ppkth2 and ppacr2 MUST be all float" ):
114+ zco (** kwargs , ldbletanh = True , ppa2 = 1 , ppkth2 = 1 , ppacr2 = None )
114115
115116
116- @pytest .mark .parametrize ("ppname" , ("ppa2" , "ppsur" ))
117- def test_zco_warnings (ppname ):
117+ def test_zco_warnings ():
118118 """Make sure we warn when arguments are ignored"""
119119
120- # Input parameters
121- kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 )
122-
123- # Generate test data
120+ # Initialize test class
124121 ds_bathy = Bathymetry (1.0e3 , 1.2e3 , 1 , 1 ).flat (5.0e3 )
125122 zco = Zco (ds_bathy , jpk = 10 )
126123
127- # Warnings (ignored arguments)
128- expected = zco (** kwargs )
129- with pytest .warns (UserWarning , match = f"{ ppname } .*are ignored" ):
130- actual = zco (** kwargs , ldbletanh = False , ** {ppname : 1 })
124+ # Uniform: Ignore coefficients controlling stretching
125+ kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 , ppkth = 0 , ppacr = 0 )
126+ expected = zco (** kwargs , ppsur = None , ppa0 = None , ppa1 = None )
127+ with pytest .warns (
128+ UserWarning , match = "ppsur, ppa0 and ppa1 are ignored when ppacr == ppkth == 0"
129+ ):
130+ actual = zco (** kwargs , ppsur = 2 , ppa0 = 2 , ppa1 = 2 )
131+ xr .testing .assert_identical (expected , actual )
132+
133+ # ldbletanh = False : Ignore parameters controlling double tanh
134+ kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 , ldbletanh = False )
135+ expected = zco (** kwargs , ppa2 = None , ppkth2 = None , ppacr2 = None )
136+ with pytest .warns (
137+ UserWarning , match = "ppa2, ppkth2 and ppacr2 are ignored when ldbletanh is False"
138+ ):
139+ actual = zco (** kwargs , ppa2 = 2 , ppkth2 = 2 , ppacr2 = 2 )
140+ xr .testing .assert_identical (expected , actual )
141+
142+ # Uniform case: Ignore double tanh
143+ kwargs = dict (ppdzmin = 10 , pphmax = 5.0e3 , ppkth = 0 , ppacr = 0 )
144+ expected = zco (** kwargs , ppa2 = None , ppkth2 = None , ppacr2 = None )
145+ with pytest .warns (
146+ UserWarning ,
147+ match = "ppa2, ppkth2 and ppacr2 are ignored when ppacr == ppkth == 0" ,
148+ ):
149+ actual = zco (** kwargs , ppa2 = 2 , ppkth2 = 2 , ppacr2 = 2 )
131150 xr .testing .assert_identical (expected , actual )
0 commit comments