[Numpy-discussion] Numpy unexpected (for me) behaviour
Fri Jan 23 01:42:40 CST 2009
On Fri, Jan 23, 2009 at 01:39, Matthew Brett <firstname.lastname@example.org> wrote:
>> #This does not work
>> import numpy
>> b=numpy.ones(4, numpy.int)
>> a[b] += 1
> The problem here is that you are setting a to a+1.
> I think you want:
> import numpy
> b=numpy.ones(4, numpy.bool)
> a[b] += 1
Judging from his for loop, he does want the integer array. He's doing
something like histogramming.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion