Open DiegoTheWolf opened 3 years ago
I have the same problem. In my notebook, some forces are displayed as kN (F1 = 674 kN) and others as MN (F2 = 1.508 MN). Can I explicitely convert/require F2 to be in kN (for a more straightforward comparison)? It would be nice to have such an option in the library.
Hi @DiegoTheWolf and @eagle-tex,
There is a method called .prefix()
that accepts a string prefix to be "forced" upon the unit so that it always displays that way. It works like this:
a = 4 * m
b = 200 *mm
c = (a+b).prefix('c')
c
420.000 cm
The same would work as follows:
F2 = 1508*kN
F2
1.508 MN
F2.prefix('k')
1508 kN
@connorferster
Thanks a lot for the reply. I tried the code you provided and it worked... to a point.
L = 3347.526*m
When I try to display L, it shows 3.348 km (automatic conversion in km) a.prefix("") is supposed to display L back into m (meters). But for some reason, it does not work.
Do you have any idea why and what could be done to solve that problem?
Btw, on the GitHub page of forallpeople, the method prefix does not exist. prefixed exists but that one doesn't work. That was probably a typo in the markdown file.
Hi @eagle-tex,
Ah, yes this part is less obvious. For specifying no prefix, as follows:
L = 3347.526*m
a = L.prefix('unity')
I need to update the documentation, badly. Ideally with a proper readthedocs site. Coming soon. Will update the Github page in the mean time.
Hi @connorferster At this purpose, you can just assign the prefix default value with the prefix of creation?
I mean, instead of doing this:
%%render param
f = 5000*si.kN.prefix('k')
it automatically add the prefix k
since I defined f
with kN
.
And maybe adding a switch with this behaviur like you did in HandCalcs
automatically_convert_units_over_1000
True | False
@sononicola
It actually does this with all SI units that are a power of 1000
between 1e24
and 1e-24
. The behavior is not so much defined by the creation of the unit with kN
but more because 1 kN
is actually 1000 N
and it will "auto-prefix" the value because of this.
One way to manage this would be to have a toggle to just auto-prefixing on and off.
I made a new json which includes
now i have a calculation of
m * cm * mm
and it's result ism³
. when i leave out them
i get a result ofmm²
.On what basis is the resulting unit calculated.
And how can i change it? (i want
cm
in both lines)