[AstroPy] Problem with astropy 03 and quantities
thomas.robitaille at gmail.com
Mon Nov 25 04:47:37 EST 2013
First, regarding the ``copy`` issue, could you provide some code to
replicate this? ``copy`` should work with Quantites:
In : np.copy(np.array([1,2,3]) * u.m)
Out: array([1, 2, 3])
To adapt your code, you simply need to add ``.value`` to the quantity
to get the underlying Numpy array if you want to drop the units.
There is a performance penalty in using Quantity in 0.3, but already
in 0.3.1 there will be significant optimizations, and given that
``Quantity`` is widely used in Astropy, you can expect more work on
optimizations in future.
By the way, there *is* an entry in the changelog:
On 25 November 2013 00:50, Yannick Roehlly <yannick.roehlly at lam.fr> wrote:
> Dear all,
> I've encountered a problem with astropy 0.3 and I wonder how to solve
> it and if it's an astropy issue or not.
> I've got some code (a SED fitting code) that used to work with astropy
> 0.2.5 and no longer works with version 0.3, failing with a "ValueError:
> setting an array element with a sequence." when trying to copy an array
> with numpy.copy.
> I managed to trace the problem. At some point, I'm using the cosmology
> module to compute a luminosity distance while building an array of
> fluxes. With astropy 0.3, the luminosity_distance functions returns
> quantities. So I have a "quantified" array that can not be copied with
> So, I wonder if there is a way to disable this behaviour and make
> astropy not use quantities.
> Also, I wonder if this is not an astropy issue as it breaks working
> code (at least, there should be a warning in the changelog).
> PS: Does the use of quantities slows down the computation or their
> effect is negligible?
> Wernher von Braun settled for a V-2 when he coulda had a V-8.
> AstroPy mailing list
> AstroPy at scipy.org
More information about the AstroPy