take(..., out=something) does not seem to work
Hi, Either I have completely misunderstood what the out= arg to the take function is supposed to do, or there is a bug in numpy 1.0.2, as demonstrated below. First, some initialization: In [1]: from numpy import * In [2]: a=arange(12).reshape((3,4)) In [3]: a Out[3]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) Let's try take without an output argument: In [4]: take(a, [0,2], axis=1) Out[4]: array([[ 0, 2], [ 4, 6], [ 8, 10]]) Good. Now let's create an array of the right size and dtype, and use it for output: In [5]: b = zeros_like(_) In [6]: take(a, [0,2], axis=1, out=b) Out[6]: array([[ 0, 2], [ 4, 6], [ 8, 10]]) In [7]: b Out[7]: array([[0, 0], [0, 0], [0, 0]]) It seems that b was not affected at all. -- Jouni K. Seppänen http://www.iki.fi/jks
participants (2)
-
Jouni K. Seppänen
-
Travis Oliphant