Hi list,
I have two questions on numarray indexing:
1) does anyone know an elegant way to assign values to a non-contiguous
slice. Like:
In [1]:from numarray import *
In [2]:a = arange(25).resize((5,5))
In [3]:a
Out[3]:
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
In [4]:i = [1,3]
In [5]:transpose(a[i])[i]=1
----------------------------------------------------------------
exceptions.ValueError Traceback
(most recent call last)
...
ValueError: Invalid destination array: partial indices require
contiguous non-byteswapped destination
2) And second: why didn't you choose to return all combinations of
indices:
In [8]:a[i,i]
Out[8]:array([ 6, 18])
Where I, in my humble opinion, would prefer to see all possible
combinations. e.g. a[[1,3],[1,3]] = a[[1,1,3,3],[1,3,1,3]]
Anyone has an idea how to easyly obtain this behaviour?
Greets+thanks,
Joost