[Numpy-discussion] amap: new function / ufunc method?

John J. Lee jjl at pobox.com
Tue Jan 29 08:40:04 EST 2002


On Sun, 27 Jan 2002, Travis Oliphant wrote:
[...]
> If I understand what you are trying to do, there is a function called
> arraymap in the SciPy package (special module) (it was in the Numeric source
[...]
> I think that using this function and a combination of take and put can do
> what you describe.

I don't see how, though I may very well be missing something.  To restate
the problem very quickly (though the Python function I posted is much
clearer -- it's only two or three lines of actual code): for every element
in a list of array indices, the element in an output array at that index
needs to be incremented; the tricky part is that this needs to happen once
for *every time the index appears in the list*.  Eg., in a 1D example,
[0,1,1,1,4,5] might give you

[1,3,0,0,1,1]

(again, see my previous post for an actual tested example)

I don't see how you can do this with arraymap, take and put.


John






More information about the NumPy-Discussion mailing list