Skip to content

Commit 877bd94

Browse files
committed
Attempt to add cf_units checker
1 parent 0d16a3e commit 877bd94

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ jobs:
4545
uses: actions/setup-python@v2
4646
with:
4747
python-version: ${{ matrix.python-version }}
48+
- name: Install udunits
49+
run: sudo apt-get install -y libudunits2-dev
4850
- name: Run image
4951
uses: abatilo/[email protected]
5052
with:
5153
poetry-version: ${{ matrix.poetry-version }}
5254
- name: Install dependencies
5355
run: |
5456
poetry install
57+
poetry run pip install cf_units==3.0.1
5558
- name: Test with pytest
5659
run: |
5760
poetry run pytest gsw_xarray/tests

gsw_xarray/tests/test_units.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ def test_unit_pint(func_name):
2828
for a in attrs:
2929
print(a["units"])
3030
ureg.Unit(a["units"])
31+
32+
@pytest.mark.parametrize("func_name", gsw_base)
33+
def test_unit_cf_units(func_name):
34+
cf_units = pytest.importorskip("cf_units")
35+
if func_name in ["indexer", "match_args_return", "pchip_interp"]:
36+
# Internal gsw cookery or non wrapped functions
37+
return
38+
attrs = _func_attrs[func_name]
39+
if isinstance(attrs, dict):
40+
attrs = [
41+
attrs,
42+
]
43+
for a in attrs:
44+
print(a["units"])
45+
cf_units.Unit(a["units"])

0 commit comments

Comments
 (0)