Skip to content

Commit 7b5b114

Browse files
committed
adding test with pint
1 parent 480e316 commit 7b5b114

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

gsw_xarray/tests/test_units.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Testing units with pint and UDUNITS2
3+
"""
4+
import pytest
5+
6+
from .test_imports import gsw_base
7+
from gsw_xarray._attributes import _func_attrs
8+
9+
from pint import UnitRegistry
10+
ureg = UnitRegistry()
11+
12+
@pytest.mark.parametrize("func_name", gsw_base)
13+
def test_unit_pint(func_name):
14+
if func_name in ["indexer", "match_args_return", "pchip_interp"]:
15+
# Internal gsw cookery or non wrapped functions
16+
return
17+
if func_name == 'geostrophic_velocity':
18+
pytest.xfail('geostrophic_velocity outputs "degree_north" and "degree_east" that are not compatible with pint')
19+
attrs = _func_attrs[func_name]
20+
if isinstance(attrs, dict):
21+
attrs = [attrs,]
22+
for a in attrs:
23+
print(a['units'])
24+
ureg.Unit(a['units'])

0 commit comments

Comments
 (0)