[NumPy-Tickets] [NumPy] #2122: numpy.take gives corrupted result with inplace operation
NumPy Trac
numpy-tickets@scipy....
Mon Apr 30 16:25:52 CDT 2012
#2122: numpy.take gives corrupted result with inplace operation
-------------------------+--------------------------------------------------
Reporter: rainwoodman | Owner: somebody
Type: defect | Status: new
Priority: high | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.1
Keywords: |
-------------------------+--------------------------------------------------
Comment(by david.warde-farley):
I don't think this is a bug. AFAIK `numpy.take` isn't really intended to
be used in this way. Furthermore, because arrays may not be contiguous in
memory (e.g. smallest stride > 1 element), determining whether there is
any overlap between input and output arrays is quite complicated, and I'm
not sure it's practical to do so.
There are lots of places in NumPy where inplace operations will
unavoidably fail if you're not careful, e.g. you might think that `a =
arange(50); a[:] += a[::-1]` will return an array of 49s, but it doesn't.
I do agree that `take()` should at least document that it's not meant to
be used when `a` and `out` alias each other, and to prefer fancy indexing
in this case; ideally, an error would be raised, but I'm not sure that's
practical for the reasons above.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2122#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list