[Numpy-discussion] bug in numpy.where?

Christopher Hanley chanley@gmail....
Fri Jul 27 15:36:02 CDT 2012


On Fri, Jul 27, 2012 at 4:10 PM, Benjamin Root <ben.root@ou.edu> wrote:

>
>
> On Fri, Jul 27, 2012 at 3:58 PM, Andreas Mueller <amueller@ais.uni-bonn.de
> > wrote:
>
>> Hi Everybody.
>> The bug is that no error is raised, right?
>> The docs say
>>
>> where(condition, [x, y])
>>
>> x, y : array_like, optional
>>      Values from which to choose. `x` and `y` need to have the same
>>      shape as `condition`
>>
>> In the example you gave, x was a scalar.
>>
>> Cheers,
>> Andy
>>
>
> Hmm, that is incorrect, I believe.  I have used a scalar before.  Maybe it
> works because a scalar is broadcastable to the same shape as any other
> N-dim array?
>
> If so, then the wording of that docstring needs to be fixed.
>
> No, I think Christopher hit it on the head.  For whatever reason, the
> endian-ness somewhere is not being respected and causes a byte-swapped
> version to show up.  How that happens, though, is beyond me.
>
> Ben Root
>
>
>
It may have something to do with the dtype size as well.  The problem seen
with,
net = np.zeros(3, dtype='>f4')

Disappears for
net = np.zeros(3, dtype='>f8')

and above.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120727/19dad972/attachment.html 


More information about the NumPy-Discussion mailing list