On Sat, 26 Nov 2022 at 07:13, Teo <[email protected]> wrote:
>
> Hi all. I just started using Sympy this week. According to this video, when
> the following code was run, the units of ohm would be returned in SI base
> units.
>
> import sympy.physics.units as u
> u.ohm
>
> However, when I tried, I got the symbol omega instead. Is there a method to
> obtain the same SI base units (kgm^2)/(A^2s^3)?
You can do it like this:
In [1]: import sympy.physics.units as u
In [3]: u.convert_to(u.ohm, [u.kg,u.m,u.ampere,u.s])
Out[3]:
2
kilogram⋅meter
───────────────
2 3
ampere ⋅second
Probably there should be an easier way. It's also possible like this:
In [4]: u.convert_to(u.ohm, u.si.SI._base_units)
Out[4]:
2
kilogram⋅meter
───────────────
2 3
ampere ⋅second
In [5]: u.si.SI._base_units
Out[5]: (meter, kilogram, second, ampere, mole, candela, kelvin)
That's using _base_units which has a leading underscore indicating
that it should be considered "private". I don't see why it should be
considered private though...
Oscar
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAHVvXxQkXVCC5Fra4-NGh%2BVHVtd%3D6_DJ_M%3DP6im%3DHzwLEE5e1Q%40mail.gmail.com.