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
This commit is contained in:
cpascual
2015-11-23 08:41:12 +01:00
parent b869d7c6ec
commit 4e6ed110fd

View File

@@ -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()))