[SciPy-user] Selecting Array Indicies with an array of values?!?

Kevin Webster chuck.l.norris@gmail....
Thu Jan 8 19:29:27 CST 2009


  I am rather new to numpy and scipy so some of this may come from my ignorance,
but I am having an issue with using numpy to edit a large array of values. I
want to selectively edit items in an array with a list of those items. Some code
might explain better:

arrSV[usr_mov_ids[a[i]:a[i+1]]] =

here I am using numpy's great expressions to specify the range that I want to
work with. Inside usr_mov_ids I have an array of index values in specific order
that I want to place inside the array arrSV. Because of memory restrictions, I
had to chunk up the array operations, so I use the array a[] to hold the chunked
up index values. This compiles correctly and runs, but instead of using the
values coming from usr_mov_ids it just fills every item in the array with the
same values.

I thought I could sidestep the problem if I used weave and just inline some C to
flip through the array quickly. Here is the code that I wrote:

for (int x=a(i); x<a(i+1); ++x) {
    int mId = usr_mov_ids(x);
    for (int y=0; y<12; ++y) {
        arrSV(mId, y) = abs(SVD)-abs(arrSV(mId, y));

This ends up giving me the exact same result. I can even print the values that
should be used with mId and y. But it keeps filling the whole array with values.

Does anyone know what I am doing wrong?


More information about the SciPy-user mailing list