Skip to content

Commit

Permalink
Merge pull request #499 from ioos/cell-measures-fixup
Browse files Browse the repository at this point in the history
Fixup branching logic in cell_measures, fixes #495
  • Loading branch information
daf authored May 17, 2017
2 parents 8c3010f + 6213696 commit fa13745
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions compliance_checker/cf/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2595,40 +2595,40 @@ def check_cell_measures(self, ds):
"'volume: cell_var' where cell_var is the "
"variable describing the cell measures".format(
var.name))
continue
valid = True
cell_meas_var_name = search_res.groups()[0]
# TODO: cache previous results
if cell_meas_var_name not in ds.variables:
valid = False
reasoning.append(
"Cell measure variable {} referred to by "
"{} is not present in dataset variables".format(
var.name, cell_meas_var_name)
)
else:
cell_meas_var = ds.variables[cell_meas_var_name]
if not hasattr(cell_meas_var, 'units'):
valid = False
reasoning.append(
"Cell measure variable {} is required "
"to have units attribute defined.".format(
cell_meas_var_name)
)
if not set(cell_meas_var.dimensions).issubset(var.dimensions):
valid = True
cell_meas_var_name = search_res.groups()[0]
# TODO: cache previous results
if cell_meas_var_name not in ds.variables:
valid = False
reasoning.append(
"Cell measure variable {} must have "
"dimensions which are a subset of "
"those defined in variable {}.".format(
cell_meas_var_name, var.name)
"Cell measure variable {} referred to by "
"{} is not present in dataset variables".format(
var.name, cell_meas_var_name)
)
else:
cell_meas_var = ds.variables[cell_meas_var_name]
if not hasattr(cell_meas_var, 'units'):
valid = False
reasoning.append(
"Cell measure variable {} is required "
"to have units attribute defined.".format(
cell_meas_var_name)
)
if not set(cell_meas_var.dimensions).issubset(var.dimensions):
valid = False
reasoning.append(
"Cell measure variable {} must have "
"dimensions which are a subset of "
"those defined in variable {}.".format(
cell_meas_var_name, var.name)
)

result = Result(BaseCheck.MEDIUM,
valid,
('§7.2 Cell measures', var.name, 'cell_measures'),
reasoning)
ret_val.append(result)
result = Result(BaseCheck.MEDIUM,
valid,
('§7.2 Cell measures', var.name, 'cell_measures'),
reasoning)
ret_val.append(result)

return ret_val

Expand Down

0 comments on commit fa13745

Please sign in to comment.