Skip to content

Commit

Permalink
PR cleanup
Browse files Browse the repository at this point in the history
- removed note on the lru_cache
- sorting messages at printout
- added a docstring parameter

*** squashed commit message ***

Updated the priority level for _valid_udunits check
  • Loading branch information
daltonkell committed Feb 6, 2019
1 parent b4fa0fd commit fa166ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
20 changes: 3 additions & 17 deletions compliance_checker/acdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ def get_applicable_variables(self, ds):
if varname and (varname not in self.applicable_variables):
self.applicable_variables.append(varname)

# TODO?
# by assigning:

# self._applicable_variables = self.applicable_variables

# this entire if statement won't have to be called again;
# not assigning will result in some of th cached results being duplicated,
# and thus some check Results being duplicated. However, once assigned
# the cache is present for the entire life of the ACDD1_* checker object;
# this has unintended side effects on our unit tests which do not always
# (never, I believe) flush the cache between creating/loading new testing
# datasets. Because of this, cached objects from the previous dataset are
# kept in the object, causing downstream tests to fail.

return self.applicable_variables

def check_var_long_name(self, ds):
Expand Down Expand Up @@ -539,16 +525,16 @@ def verify_convention_version(self, ds):
Verify that the version in the Conventions field is correct
"""
try:
for convention in ds.getncattr("Conventions").replace(' ', '').split(','):
for convention in getattr(ds, "Conventions", '').replace(' ', '').split(','):
if convention == 'ACDD-' + self._cc_spec_version:
return ratable_result((2, 2), None, []) # name=None so grouped with Globals

# if no/wrong ACDD convention, return appropriate result
# Result will have name "Global Attributes" to group with globals
m = ["\"Conventions\" does not contain 'ACDD-{}'".format(self._cc_spec_version)]
m = ["Conventions does not contain 'ACDD-{}'".format(self._cc_spec_version)]
return ratable_result((1, 2), "Global Attributes", m)
except AttributeError: # NetCDF attribute not found
m = ["\"Conventions\" attribute not present"]
m = ["No Conventions attribute present; must contain ACDD-{}".format(self._cc_spec_version)]
# Result will have name "Global Attributes" to group with globals
return ratable_result((0, 2), "Global Attributes", m)

Expand Down
1 change: 1 addition & 0 deletions compliance_checker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def attr_check(l, ds, priority, ret_val, gname=None):
:param netCDF4 dataset ds : dataset being checked
:param int priority : priority level of check
:param list ret_val : result to be returned
:param str or None gname : group name assigned to a group of attribute Results
"""

msgs = []
Expand Down
2 changes: 1 addition & 1 deletion compliance_checker/cf/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def _check_valid_udunits(self, ds, variable_name):
should_be_dimensionless = (variable.dtype.char == 'S' or
std_name_units_dimensionless)

valid_udunits = TestCtx(BaseCheck.LOW, self.section_titles["3.1"])
valid_udunits = TestCtx(BaseCheck.HIGH, self.section_titles["3.1"])
are_udunits = (units is not None and util.units_known(units))
valid_udunits.assert_true(should_be_dimensionless or are_udunits,
'units for {}, "{}" are not recognized by UDUNITS'.format(variable_name, units))
Expand Down
3 changes: 2 additions & 1 deletion compliance_checker/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ def process_table(res, check):
# separating this and the previous level
if has_printed:
print("")
reason_str = "\n".join('* {}'.format(r) for r in reasons)
# join alphabetized reasons together
reason_str = "\n".join('* {}'.format(r) for r in sorted(reasons, key=lambda x: x[0]))
proc_str = "{}\n{}".format(issue, reason_str)
print(proc_str)
proc_strs.append(proc_str)
Expand Down

0 comments on commit fa166ef

Please sign in to comment.