Closed
Description
Let's consider this code
import pint as pt
# sets compact display mode
u = pt.UnitRegistry()
u.default_format = '~P'
# creates quantity
q = u.Quantity("1 kW * 1 h")
# this prints "1 h·kW", not "1 kW·h" as expected
print(q)
During the string conversion I believe the units are sorted alphabetically, in fact hour
comes before kilowatt
.
How can I override this behaviour to have it printed correctly as 1 kW·h
?
For now I am doing str(q).replace("h·kW", "kW·h")
but I am looking for a better solution, that may act globally and before string conversion.
Any suggestions?
Thank you!
Metadata
Metadata
Assignees
Labels
No labels