I have a list of numpy array indices which I created with argsort():
i =
[array([0, 1, 3, 2, 4], dtype=int64),
array([1, 3, 0, 2, 4], dtype=int64),
array([2, 4, 0, 1, 3], dtype=int64),
array([3, 1, 0, 2, 4], dtype=int64),
array([4, 2, 0, 3, 1], dtype=int64)]
This is the corresponding list of arrays with values:
v =
[array([0. , 0.19648367, 0.24237755, 0.200832 , 0.28600039]),
array([0.19648367, 0. , 0.25492185, 0.15594099, 0.31378135]),
array([0.24237755, 0.25492185, 0. , 0.25685254, 0.2042604 ]),
array([0.200832 , 0.15594099, 0.25685254, 0. , 0.29995309]),
array([0.28600039, 0.31378135, 0.2042604 , 0.29995309, 0. ])]
When I try to loop over the lists like this:
for line in i:
v[line]
I get the error:
TypeError: only integer scalar arrays can be converted to a scalar index
But when I try to access them individually like this:
v[0][i[0]]
It works and outputs the values in v[0] in correct order like this:
array([0. , 0.19648367, 0.200832 , 0.24237755, 0.28600039])
I want the arrays in v ordered from the smallest value to biggest.
What am I doing wrong?
s— that probably makes a difference here?i[0]inv[0][line]to have code similar tov[0][i[0]]vordered from the smallest value to biggest.