From 999191265fef9533186d611ce4a1ea3da655cfdf Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Thu, 14 Nov 2024 15:45:10 +0100 Subject: [PATCH] converge on cf-units to reduce code change --- compliance_checker/cf/cf_1_6.py | 4 ++-- compliance_checker/cfunits.py | 3 --- compliance_checker/cfutil.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/compliance_checker/cf/cf_1_6.py b/compliance_checker/cf/cf_1_6.py index 8e7291a5..b2b96d8c 100644 --- a/compliance_checker/cf/cf_1_6.py +++ b/compliance_checker/cf/cf_1_6.py @@ -827,7 +827,7 @@ def _check_valid_cf_units(self, ds, variable_name): # being expressed as "s"/seconds if standard_name not in {"time", "forecast_reference_time"}: valid_units.assert_true( - units_conv.is_convertible_to(cfutil._units(reference)), + units_conv.is_convertible(cfutil._units(reference)), f'Units "{units}" for variable ' f"{variable_name} must be convertible to " f'canonical units "{reference}"', @@ -2849,7 +2849,7 @@ def _cell_measures_core(self, ds, var, external_set, variable_template): valid = False reasoning.append(conversion_failure_msg) else: - if not cell_measure_units.is_convertible_to( + if not cell_measure_units.is_convertible( cfutil._units(f"m{exponent}"), ): valid = False diff --git a/compliance_checker/cfunits.py b/compliance_checker/cfunits.py index e0339d08..0af201c6 100644 --- a/compliance_checker/cfunits.py +++ b/compliance_checker/cfunits.py @@ -12,9 +12,6 @@ class CFUnitMixin: """Standardize the methods from cf-untis and pyudunits2 used in compliance-checker.""" - def is_convertible_to(self, other): - return self.is_convertible(other) - def expand_definition(self): return self.definition diff --git a/compliance_checker/cfutil.py b/compliance_checker/cfutil.py index 69ce7209..3b63f068 100644 --- a/compliance_checker/cfutil.py +++ b/compliance_checker/cfutil.py @@ -2044,4 +2044,4 @@ def units_convertible(units1, units2): u2 = _units(units2) except ValueError: return False - return u1.is_convertible_to(u2) + return u1.is_convertible(u2)