Thanks Oscar, that works. I can see why the current output is preferred by 
many, but the SI base units output is still useful for learners of Physics. 
My learners are young, so I hope there could be an easier way to achieve 
this.

On Tuesday, 29 November 2022 at 01:55:20 UTC+11 Oscar wrote:

> 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/6a36739e-687e-41db-b57d-c26df64c241en%40googlegroups.com.

Reply via email to