You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discussion #76 made me realize that the nomenclature.validate() function does not (yet) perform a validation whether the reported unit is in line with the nomenclature.
I recently wrote a little script for another project, it would be great if someone would volunteer to merge the unit-related part into the validate() function (and also make sure that this works for lists of allowed units, see #76 (comment)).
Note: variable_config is roughly equivalent to the nomenclature.variables dictionary.
# validate variables and against valid templateillegal_vars, illegal_units= [], []
fori, (var, unit) indf.variables(include_units=True).iterrows():
ifvarnotinvariable_config:
illegal_vars.append(var)
elifunit!=variable_config[var]['unit']:
illegal_units.append((var, unit, variable_config[var]['unit']))
ifillegal_vars:
msg='The following variables are not defined in the project template:'log.error('ERROR: '+'\n - '.join([msg] +illegal_vars) +'\n')
ifillegal_units:
msg='The following units are not in line with the project template:'lst= [f'{v} - expected: {e}, found: {u}'forv, u, einillegal_units]
log.error('ERROR: '+'\n - '.join([msg] +lst) +'\n')
The text was updated successfully, but these errors were encountered:
Quick update: I have started and already tested with a dummy file. The comprehensive test_functions are still missing and then I start the pull request. I will do this until Monday at the latest.
Discussion #76 made me realize that the
nomenclature.validate()
function does not (yet) perform a validation whether the reported unit is in line with the nomenclature.I recently wrote a little script for another project, it would be great if someone would volunteer to merge the unit-related part into the
validate()
function (and also make sure that this works for lists of allowed units, see #76 (comment)).@erikfilias @sebastianzwickl, would you have an hour to give this a try?
Note:
variable_config
is roughly equivalent to thenomenclature.variables
dictionary.The text was updated successfully, but these errors were encountered: