Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated function #1095

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compliance_checker/cf/cf_1_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def _check_valid_standard_units(self, ds, variable_name):
# IMPLEMENTATION CONFORMANCE 4.4 REQUIRED 1/2
elif standard_name == "time":
valid_standard_units.assert_true(
util.units_convertible(units, "seconds since 1970-01-01"),
cfutil.units_convertible(units, "seconds since 1970-01-01"),
"time must be in a valid units format <unit> since <epoch> "
f"not {units}",
)
Expand Down Expand Up @@ -1694,7 +1694,7 @@ def check_dimensional_vertical_coordinate(
"there is no default",
)

if not util.units_convertible("bar", units):
if not cfutil.units_convertible("bar", units):
valid_vertical_coord.assert_true(
positive in ("up", "down"),
f"{name}: vertical coordinates not defining pressure must include "
Expand Down
13 changes: 2 additions & 11 deletions compliance_checker/cf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from lxml import etree
from netCDF4 import Dataset

from compliance_checker.cfutil import units_convertible

# copied from paegan
# paegan may depend on these later
_possiblet = {
Expand Down Expand Up @@ -325,17 +327,6 @@ def units_known(units):
return True


def units_convertible(units1, units2, reftimeistime=True):
"""Return True if a Unit representing the string units1 can be converted
to a Unit representing the string units2, else False."""
try:
u1 = Unit(units1)
u2 = Unit(units2)
except ValueError:
return False
return u1.is_convertible(u2)


def units_temporal(units):
try:
u = Unit(units)
Expand Down
5 changes: 2 additions & 3 deletions compliance_checker/tests/test_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
download_cf_standard_name_table,
is_time_variable,
is_vertical_coordinate,
units_convertible,
units_temporal,
)
from compliance_checker.suite import CheckSuite
Expand Down Expand Up @@ -1903,8 +1902,8 @@ def test_check_cell_methods(self):
# --------------------------------------------------------------------------------

def test_temporal_unit_conversion(self):
self.assertTrue(units_convertible("hours", "seconds"))
self.assertFalse(units_convertible("hours", "hours since 2000-01-01"))
self.assertTrue(cfutil.units_convertible("hours", "seconds"))
self.assertFalse(cfutil.units_convertible("hours", "hours since 2000-01-01"))

def test_units_temporal(self):
self.assertTrue(units_temporal("hours since 2000-01-01"))
Expand Down