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

Merge in develop #1097

Merged
merged 9 commits into from
Jul 11, 2024
12 changes: 1 addition & 11 deletions .github/workflows/default-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [windows-latest, ubuntu-latest, macos-latest]
experimental: [false]
include:
- python-version: "3.12"
os: "ubuntu-latest"
experimental: true
fail-fast: false
defaults:
run:
Expand All @@ -35,11 +30,6 @@ jobs:
--file test_requirements.txt
--channel conda-forge

- name: Install unstable dependencies
if: matrix.experimental == true
run: |
micromamba install conda-forge/label/numpy_dev::numpy

- name: Install compliance-checker
run: |
python -m pip install -e . --no-deps --force-reinstall
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.6
rev: v0.5.0
hooks:
- id: ruff

Expand Down
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ entry-points."compliance_checker.suites"."acdd-1.3" = "compliance_checker.acdd:A
entry-points."compliance_checker.suites"."cf-1.6" = "compliance_checker.cf.cf:CF1_6Check"
entry-points."compliance_checker.suites"."cf-1.7" = "compliance_checker.cf.cf:CF1_7Check"
entry-points."compliance_checker.suites"."cf-1.8" = "compliance_checker.cf.cf:CF1_8Check"
entry-points."compliance_checker.suites"."cf-1.9" = "compliance_checker.cf.cf:CF1_9Check"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

We should also update the README to reflect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in README do you think this should go? I think in general there should be more documentation for developing plugins, but current README doesn't really cover development workflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main table, that describes the checks, is stuck in CF 1.8. That README file is also used to build the docs. I can send a PR for it later today.

entry-points."compliance_checker.suites"."ioos-0.1" = "compliance_checker.ioos:IOOS0_1Check"
entry-points."compliance_checker.suites"."ioos-1.1" = "compliance_checker.ioos:IOOS1_1Check"
entry-points."compliance_checker.suites"."ioos-1.2" = "compliance_checker.ioos:IOOS1_2Check"
Expand Down
Loading