[AstroPy] Quantity does not own its own data with copy=True

Duncan Macleod duncan.macleod at ligo.org
Thu Mar 26 14:00:38 EDT 2015


Hi all,

I’m wondering why a new astropy.units.Quantity doesn’t own its own data, even when I specify copy=True when creating it:

>>> from astropy.units import Quantity
>>> a = Quantity([1, 2, 3], copy=True)
>>> print(a.flags.owndata)
False

I know technically how that is true, since there is a view() call in the __new__ constructor, but not why is was implemented in this way. There are lines in other parts of quantity.py that reference this fact, which makes it seem like this was a conscious decision, rather than an accident.

Can someone explain the thinking behind this decision?

I realise I can use Quantity([1, 2, 3]).copy() to create a clean copy that does own the data, but that seems a little inelegant.


Thanks
Duncan
--
Duncan Macleod
duncan.macleod at ligo.org
LIGO Data Grid systems development
Louisiana State University

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150326/b3650171/attachment.html>


More information about the AstroPy mailing list