Temperature units do not properly format as string
degC, degF, and degR (along with their delta-equivalents) are not properly formatted in Unicode, HTML, or LaTeX.
We need to address this. Thanks for reporting
Possibly related? I got a
ValueError: Unknown format code g for object of type 'str'
when trying to cast a temperature to string.
Needed to change
mstr = format(obj.magnitude, mspec).replace("\n", "")
to
mstr = format(float(obj.magnitude), mspec).replace("\n", "")
in quantity.py, __format__() (ca. line 300) to make it work.
I have also realized that the LaTeX conversions for some units are wrong.
Steps to reproduce:
import pint
test = pint.Unit('celsius')
print(f'{test:L}')
print(f'{test:Lx}')
Output
\mathrm{degree\_Celsius}
\si[]{\degree_Celsius}
In LaTeX this renders completely wrong. The expected output would be:
For :L
\mathrm{\degree_C} or
Or better for :Lx
\si[]{\celsius}
Thanks for looking into this!
a PR fixing this is welcomed