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:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user