<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Ole, Leo,</div><div class=""><br class=""></div><div class="">There’s also a mention of known issues with some numpy functions with Quantity objects here:</div><div class=""><a href="http://astropy.readthedocs.io/en/latest/known_issues.html#quantity-issues" class="">http://astropy.readthedocs.io/en/latest/known_issues.html#quantity-issues</a></div><div class="">(arange isn’t mentioned specifically).</div><div class=""><br class=""></div><div class="">The workaround is just to do something like this, i.e. call the function with the value array and after put the unit back on:</div><div class=""><br class=""></div><div class="">q_in = <some quantity></div><div class="">unit = <some fixed unit></div><div class="">a_out  = np.somefunction(a_in.to(unit).value)</div><div class="">q_out = Quantity(a_out, unit)</div><div class=""><br class=""></div><div class="">I don’t know if the Numpy / Quantity situation will get better over the years, or if it will mostly stay as-is due do backward-compatibility constraints in Numpy.</div><div class=""><br class=""></div><div class="">Christoph</div><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Nov 2016, at 10:19, Leonard Burtscher <<a href="mailto:burtscher@strw.leidenuniv.nl" class="">burtscher@strw.leidenuniv.nl</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">OK, I see. Have you seen the discussion here?<br class=""><a href="https://github.com/astropy/astropy/wiki/Quantity-Arrays" class="">https://github.com/astropy/astropy/wiki/Quantity-Arrays</a><br class=""><br class="">Seems to be a known problem, but I'm don't know if it has been solved.<br class=""><br class=""><br class=""><blockquote type="cite" class="">Am 29.11.2016 um 10:16 schrieb Ole Streicher <astropy@liska.ath.cx>:<br class=""><br class="">Leonard Burtscher <burtscher@strw.leidenuniv.nl> writes:<br class=""><blockquote type="cite" class="">r=np.arange(0,9,0.1)*u.km<br class=""><br class="">works.<br class=""></blockquote><br class="">Sure. But the quantities are already given. I could convert them to<br class="">numbers first (with a random unit), like<br class=""><br class="">np.arange(z0/u.m, z1/u.m, dz/u.m) * u.m<br class=""><br class="">But this looks really ugly.<br class=""><br class="">Cheers<br class=""><br class="">Ole<br class="">_______________________________________________<br class="">AstroPy mailing list<br class="">AstroPy@scipy.org<br class="">https://mail.scipy.org/mailman/listinfo/astropy<br class=""></blockquote><br class="">--<br class="">http://strw.leidenuniv.nl/~burtscher<br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">AstroPy mailing list<br class="">AstroPy@scipy.org<br class="">https://mail.scipy.org/mailman/listinfo/astropy<br class=""></div></div></blockquote></div><br class=""></body></html>