From 78f50a58839d013d0b3278173072e47163978bae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:27:03 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- compliance_checker/cf/cf_1_9.py | 24 +++++++++++++++++------- compliance_checker/tests/test_cf.py | 10 ++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/compliance_checker/cf/cf_1_9.py b/compliance_checker/cf/cf_1_9.py index 73211e44..6e36ebe8 100644 --- a/compliance_checker/cf/cf_1_9.py +++ b/compliance_checker/cf/cf_1_9.py @@ -150,7 +150,10 @@ def check_domain_variables(self, ds: Dataset): continue appendix_a_not_recommended_attrs = [] for attr_name in domain_var.ncattrs(): - if attr_name in self.appendix_a and "D" not in self.appendix_a[attr_name]["attr_loc"]: + if ( + attr_name in self.appendix_a + and "D" not in self.appendix_a[attr_name]["attr_loc"] + ): appendix_a_not_recommended_attrs.append(attr_name) if appendix_a_not_recommended_attrs: @@ -163,10 +166,11 @@ def check_domain_variables(self, ds: Dataset): # no errors occurred domain_valid.score += 1 - # IMPLEMENTATION CONFORMANCE 5.8 REQUIRED 4/4 if hasattr(domain_var, "cell_measures"): - cell_measures_var_names = regex.findall(r"\b(?:area|volume):\s+(\w+)", domain_var.cell_measures) + cell_measures_var_names = regex.findall( + r"\b(?:area|volume):\s+(\w+)", domain_var.cell_measures, + ) # check exist for var_name in cell_measures_var_names: try: @@ -174,10 +178,16 @@ def check_domain_variables(self, ds: Dataset): except ValueError: # TODO: what to do here? continue - domain_coord_var_names = {var_like.name for var_like in domain_coord_vars} - domain_valid.assert_true(set(cell_measures_variable.dimensions).issubset(domain_coord_var_names), - "Variables named in the cell_measures attributes must have a dimensions attribute with " - "values that are a subset of the referring domain variable's dimension attribute") + domain_coord_var_names = { + var_like.name for var_like in domain_coord_vars + } + domain_valid.assert_true( + set(cell_measures_variable.dimensions).issubset( + domain_coord_var_names, + ), + "Variables named in the cell_measures attributes must have a dimensions attribute with " + "values that are a subset of the referring domain variable's dimension attribute", + ) results.append(domain_valid.to_result()) diff --git a/compliance_checker/tests/test_cf.py b/compliance_checker/tests/test_cf.py index f053f837..9738b78e 100644 --- a/compliance_checker/tests/test_cf.py +++ b/compliance_checker/tests/test_cf.py @@ -3258,10 +3258,12 @@ def test_domain(self): domain_var.cell_measures = "volume: cube_bad" dataset.createVariable("cube_bad", "f8", ("lon", "lat", "depth", "time")) results = self.cf.check_domain_variables(dataset) - self.assertTrue("Variables named in the cell_measures attributes must " - "have a dimensions attribute with values that are a " - "subset of the referring domain variable's dimension " - "attribute" in results[0].msgs) + self.assertTrue( + "Variables named in the cell_measures attributes must " + "have a dimensions attribute with values that are a " + "subset of the referring domain variable's dimension " + "attribute" in results[0].msgs, + ) del dataset dataset = MockTimeSeries() # domain should be dimensionless -- currently not an error in