pint icon indicating copy to clipboard operation
pint copied to clipboard

user defined unit prints

Open mhechthz opened this issue 2 years ago • 2 comments

I want to do something like this:

myval = ureg.Quantity(0.4,ureg.dimensionless,repr='[-]')
print("myval =",myval)

> myval = 4 [-]

myval2 = 5 * ureg.m / myval
print("myval2 =",myval2)
> myval2 = 5 m

is this possible somehow?

mhechthz avatar Dec 04 '23 10:12 mhechthz

[-] would be the representation of dimensionless?

hgrecco avatar Dec 04 '23 11:12 hgrecco

well yes. [] is usually for units, i.e. "power [MW]" and "-" is for "no unit". It's just for convenience since i use a lot of units like kWh, A,V, and then "dimensionless" takes a lot of space compared to the others. Only minus "-" would be also convenient. but basically i want to replace the default print name by a user text.

mhechthz avatar Dec 04 '23 13:12 mhechthz