From 1ead68502b710e874a3df93aca05413839a2e34d Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 16 Oct 2023 20:24:14 -0600 Subject: [PATCH 1/3] Bug fix in metavar.py: optional var props with a default value need to return the default value when variable doesn't have a value --- scripts/metavar.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/metavar.py b/scripts/metavar.py index dc088fdc..6391a9a0 100755 --- a/scripts/metavar.py +++ b/scripts/metavar.py @@ -116,8 +116,14 @@ class Var: ['Bob', 'Ray'] >>> Var.get_prop('active') #doctest: +ELLIPSIS + >>> Var.get_prop('active').get_default_val({}) + '.true.' >>> Var.get_prop('active').valid_value('flag_for_aerosol_physics') 'flag_for_aerosol_physics' + >>> Var({'local_name' : 'foo', 'standard_name' : 'hi_mom', 'units' : 'm s-1', 'dimensions' : '()', 'type' : 'real', 'intent' : 'in'}, ParseSource('vname', 'DDT', ParseContext()), _MVAR_DUMMY_RUN_ENV).get_prop_value('active') + '.true.' + >>> Var({'local_name' : 'foo', 'standard_name' : 'hi_mom', 'units' : 'm s-1', 'dimensions' : '()', 'type' : 'real', 'intent' : 'in', 'active' : 'child_is_home==.true.'}, ParseSource('vname', 'DDT', ParseContext()), _MVAR_DUMMY_RUN_ENV).get_prop_value('active') + 'child_is_home==.true.' >>> Var({'local_name' : 'foo', 'standard_name' : 'hi_mom', 'units' : 'm s-1', 'dimensions' : '()', 'type' : 'real', 'intent' : 'in'}, ParseSource('vname', 'SCHEME', ParseContext()), _MVAR_DUMMY_RUN_ENV).get_prop_value('long_name') 'Hi mom' >>> Var({'local_name' : 'foo', 'standard_name' : 'hi_mom', 'units' : 'm s-1', 'dimensions' : '()', 'type' : 'real', 'intent' : 'in'}, ParseSource('vname', 'SCHEME', ParseContext()), _MVAR_DUMMY_RUN_ENV).get_prop_value('intent') @@ -496,7 +502,7 @@ def get_prop_value(self, name): pvalue = self._prop_dict[name] elif name in Var.__var_propdict: vprop = Var.__var_propdict[name] - if vprop.has_default_func: + if vprop.optional: pvalue = vprop.get_default_val(self._prop_dict, context=self.context) else: From 163c397bfef3bd4d0ad9bd58c0b872ba021d1ce0 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 16 Oct 2023 20:37:37 -0600 Subject: [PATCH 2/3] Trigger CI From 294eecf673a3af7486bb6b3f00f0f6eb80d838b0 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Tue, 17 Oct 2023 11:34:23 -0600 Subject: [PATCH 3/3] Bug fix in scripts/metavar.py: use correct boolean default value 'False' for optional var prop 'polymorphic' --- scripts/metavar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/metavar.py b/scripts/metavar.py index 6391a9a0..8c600546 100755 --- a/scripts/metavar.py +++ b/scripts/metavar.py @@ -202,7 +202,7 @@ class Var: VariableProperty('active', str, optional_in=True, default_in='.true.'), VariableProperty('polymorphic', bool, optional_in=True, - default_in='.false.')] + default_in=False)] # XXgoldyXX: v debug only __to_add = VariableProperty('valid_values', str,