diff --git a/src/pint/__init__.py b/src/pint/__init__.py index 5706dff7e..7906be01f 100644 --- a/src/pint/__init__.py +++ b/src/pint/__init__.py @@ -105,6 +105,9 @@ "hourangle_second": hourangle_second, } +# define a units equivalency for gauss in cgs +gauss_equiv = [u.Gauss, u.Hz * (u.g / u.cm) ** (1 / 2), lambda x: x, lambda x: x] + import astropy.version if astropy.version.major < 4: diff --git a/src/pint/derived_quantities.py b/src/pint/derived_quantities.py index 8f3373cf6..24dcb1934 100644 --- a/src/pint/derived_quantities.py +++ b/src/pint/derived_quantities.py @@ -141,8 +141,7 @@ def _to_gauss(B: u.Quantity) -> u.G: In cgs units, magnetic field is has units (mass/length)^(1/2) / time. """ - eq = [u.Gauss, u.Hz * (u.g / u.cm) ** (1 / 2), lambda x: x, lambda x: x] - return B.to(u.Gauss, equivalencies=[eq]) + return B.to(u.Gauss, equivalencies=[pint.gauss_equiv]) @u.quantity_input(f=u.Hz, fdot=u.Hz / u.s, fo=u.Hz)