Skip to content

Commit 8cdc65e

Browse files
darianboggstclune
andauthored
Feature/wdboggs/#4660 add fill value acg3 (#4770)
* Add FILL_VALUE with alias to ACG3; unit tests * Update CHANGELOG.md --------- Co-authored-by: Tom Clune <thomas.l.clune@nasa.gov>
1 parent ec375a8 commit 8cdc65e

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

Apps/MAPL_GridCompSpecs_ACGv3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ def __str__(self):
9292
CONDITION = 'condition'
9393
DIMS = 'dims'
9494
EXPORT_NAME = 'export_name'
95+
FILL_VALUE = 'fill_value'
9596
INTENT_ARG = 'intent_arg'
9697
INTERNAL_NAME = 'internal_name'
9798
MANGLED = 'mangled'
9899
STANDARD_NAME_ARG = 'standard_name_arg'
99-
PRECISION = 'precision'
100100
RANK = 'rank'
101101
SHORT_NAME = 'short_name'
102102
SHORT_NAME_ARG = 'short_name_arg'
@@ -188,7 +188,6 @@ def get_options(args):
188188
SHORT_NAME: {MAPPING: MANGLED, FLAGS: MANDATORY},
189189
STATE_INTENT: {FLAGS: {MANDATORY}},
190190
STANDARD_NAME: {FLAGS: MANDATORY},
191-
PRECISION: {},
192191
UNGRIDDED_DIMS: {MAPPING: ARRAY},
193192
VSTAGGER: {FLAGS: MANDATORY, MAPPING: {
194193
'C': 'VERTICAL_STAGGER_CENTER',
@@ -201,6 +200,7 @@ def get_options(args):
201200
CONDITION: {FLAGS: {STORE}},
202201
'dependencies': {MAPPING: STRINGVECTOR},
203202
EXPORT_NAME: {MAPPING: STRING},
203+
FILL_VALUE: {},
204204
'itemtype': {},
205205
'orientation': {},
206206
'regrid_method': {},
@@ -228,12 +228,12 @@ def get_options(args):
228228
'long name': STANDARD_NAME,
229229
'long_name': STANDARD_NAME,
230230
'name': SHORT_NAME,
231-
'prec': PRECISION,
232231
'vloc': VSTAGGER,
233232
'vlocation': VSTAGGER,
234233
'add2export': ADD_TO_EXPORT,
235234
'field dictionary': USE_FIELD_DICTIONARY,
236-
'field_dictionary': USE_FIELD_DICTIONARY
235+
'field_dictionary': USE_FIELD_DICTIONARY,
236+
'fill': FILL_VALUE
237237
}
238238

239239
# flow control

Apps/tests/acg3/acg3_unittests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ def test_use_field_dictionary(self):
167167
values, missing_keys = digest_spec(s, options)
168168
assertFalse(use_field_dictionary in values, msg('use_field_dictionary should not be in values', s, values))
169169

170+
def test_fill_value(self):
171+
# helpers
172+
make_specs = lambda k, v: [{k: v, acg3.SHORT_NAME: 'FXX'}]
173+
def get_value(key, field_value, final_key=None):
174+
values, _ = acg3.get_values(make_specs(key, field_value), acg3.get_options({}))
175+
return values[0][final_key if final_key else key]
176+
177+
# test for different types
178+
for fv in '4.0 4.0D0 4 "4.0"'.split():
179+
test = make_equal_test(self, fv)
180+
actual = get_value(acg3.FILL_VALUE, fv)
181+
msg = general_msg(variable='Field value', value=fv)
182+
with self.subTest(test=test, actual=actual, msg=msg):
183+
test(actual, msg)
184+
185+
# make sure results are the same for the key and the alias
186+
fv = '4.0'
187+
test = make_equal_test(self, get_value(acg3.FILL_VALUE, fv))
188+
actual = get_value('fill', fv, final_key=acg3.FILL_VALUE)
189+
msg = general_msg(variable='Field value', value=fv)
190+
test(actual, msg)
191+
170192
class TestHelpers(unittest.TestCase):
171193

172194
def test_isiterable(self):

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9090
- Add `use_field_dictionary` column to ACG3 with new unit tests.
9191
- Update cap restart file with current time at end of run.
9292
- Read/write repeatCount from/to cap restart file at beginning/end of run.
93+
- Added FILL_VALUE with alias to ACG3
9394

9495

9596
### Changed

0 commit comments

Comments
 (0)