<div dir="ltr">You can do something like Mike's example, but you need to remember that the sympy expr is contained in the expr attribute of the unit object:<div><br></div><div>In [1]: q = yt.YTQuantity(3, 'g/cm**2/s')<br></div><div><div>In [2]: q.units.expr.atoms()</div><div>Out[2]: {-2, -1, cm, g, s}</div></div><div><div>In [3]: srepr(q.units.expr)</div><div>Out[3]: "Mul(Pow(Symbol('cm'), Integer(-2)), Symbol('g'), Pow(Symbol('s'), Integer(-1)))"</div></div><div><div>In [4]: q.units.expr.args</div><div>Out[4]: (g, cm**(-2), 1/s)</div></div><div><br></div><div>The unit object itself is actually (a little embarrassingly) a sympy expression, but a trivial one that doesn't actually contain any unit information.  Admittedly this is not the best for discoverability of what's going on under the hood, but making it a class that inherits from object will require a bit of work and refactoring.</div><div><br></div><div>Note that if you want to transform these sympy subexpressions into unit objects, you'll need to pass them through the Unit() constructor.  See e.g. the __mul__ or __div__ function definitions in the Unit class definition (in yt/units/unit_object.py).</div><div><br></div><div>Hope that helps,</div><div><br></div><div>Nathan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 7:44 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There is a sympy atoms method.  If x and y are symbols, then:<div><br></div><div><br><div><div>> a = x*y</div></div><div><div>> print a.atoms(sympy.Symbol)</div><div>set([x, y])</div></div></div><div><br></div><div>I suspect that this would work with the units defined in yt.  There is probably a way to get powers too.</div><div><br></div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 10:38 AM, John ZuHone <span dir="ltr"><<a href="mailto:jzuhone@gmail.com" target="_blank">jzuhone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This should be obvious to me, but I can't seem to figure it out.<br>
<br>
Is there a way to take a compound units expression like:<br>
<br>
dyne*cm**2/g**2<br>
<br>
and split it into its constituent parts, so that I have a list like this:<br>
<br>
[dyne, cm, g]<br>
<br>
and maybe even containing the information about the powers?<br>
_______________________________________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org" target="_blank">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div><div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div><div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>
</font></span></div>
<br>_______________________________________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
<br></blockquote></div><br></div>