diff --git a/cf_xarray/tests/test_units.py b/cf_xarray/tests/test_units.py index 36c677cd..0a94ba7a 100644 --- a/cf_xarray/tests/test_units.py +++ b/cf_xarray/tests/test_units.py @@ -4,6 +4,7 @@ Copyright (c) 2017 MetPy Developers. """ +import numpy as np import pytest pytest.importorskip("pint") @@ -90,7 +91,14 @@ def test_udunits_format(units, expected): @pytest.mark.parametrize( "alias", - [ureg("Celsius"), ureg("degC"), ureg("C"), ureg("deg_C"), ureg("degrees_Celsius")], + [ureg("Celsius"), ureg("degC"), ureg("deg_C"), ureg("degrees_Celsius")], ) def test_temperature_aliases(alias): assert alias == ureg("celsius") + + +def test_coulomb_symbol_survives_cf_units(): + assert ureg("C") == ureg("coulomb") + speed = np.sqrt(100 * ureg.eV / ureg.m_e).to("km/s") + assert speed.units == ureg("km/s") + assert speed.magnitude == pytest.approx(4193.828809546234) diff --git a/cf_xarray/units.py b/cf_xarray/units.py index 7f0fb281..63de43c2 100644 --- a/cf_xarray/units.py +++ b/cf_xarray/units.py @@ -92,7 +92,7 @@ def short_formatter(unit, registry, **options): units.define("year = 365.25 * day = yr") # Define commonly encountered units not defined by pint -units.define("@alias degC = C = deg_C = Celsius = degrees_Celsius") +units.define("@alias degC = deg_C = Celsius = degrees_Celsius") units.define("@alias degK = deg_K") units.define("@alias day = d") units.define("@alias hour = h") # Not the Planck constant...