diff --git a/compliance_checker/acdd.py b/compliance_checker/acdd.py index d3946fa7..831a4424 100644 --- a/compliance_checker/acdd.py +++ b/compliance_checker/acdd.py @@ -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): @@ -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) diff --git a/compliance_checker/base.py b/compliance_checker/base.py index 39b91fdd..31cb2d27 100644 --- a/compliance_checker/base.py +++ b/compliance_checker/base.py @@ -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 = [] diff --git a/compliance_checker/cf/cf.py b/compliance_checker/cf/cf.py index f8e0a8d1..6961bb94 100644 --- a/compliance_checker/cf/cf.py +++ b/compliance_checker/cf/cf.py @@ -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)) diff --git a/compliance_checker/suite.py b/compliance_checker/suite.py index 57cdbe6b..1fb5f93c 100644 --- a/compliance_checker/suite.py +++ b/compliance_checker/suite.py @@ -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)