On Fri, Jan 23, 2009 at 01:39, Matthew Brett <matthew.br...@gmail.com> wrote:
> Hi,
>
>> #This does not work
>> import numpy
>> a=numpy.zeros(10)
>> b=numpy.ones(4, numpy.int)
>> a[b] += 1
>
> The problem here is that you are setting a[1]  to a[1]+1.
>
> I think you want:
>
> import numpy
> a=numpy.zeros(10)
> 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.

-- 
Robert Kern

"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
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to