From 4e6ed110fd65b1b6c97cf4c18d59e958d22e4c02 Mon Sep 17 00:00:00 2001 From: cpascual Date: Mon, 23 Nov 2015 08:41:12 +0100 Subject: [PATCH] Use empty string for dimensionless abbreviated format Make pint use empty string when formatting dimensionless units (instead of "dimensionless") if the abbreviation format spec ("~") is used. See https://github.com/hgrecco/pint/issues/300 --- pint/unit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pint/unit.py b/pint/unit.py index 1aa7323..bbf9dfb 100644 --- a/pint/unit.py +++ b/pint/unit.py @@ -101,6 +101,8 @@ class _Unit(SharedRegistryObject): spec = spec or self.default_format if '~' in spec: + if self.dimensionless: + return '' units = UnitsContainer(dict((self._REGISTRY._get_symbol(key), value) for key, value in self._units.items()))