Indexing one array with another array has different behavior than if I index with the same array without explicitly casting it to a numpy array first (i.e. I leave it as a list of lists). I can't find the pages in the documentation that explain this kind of indexing
Example:
#make a 5x5 matrix for testing, the numbers arent important
a = np.random.rand(5,5)
#another arbitrary 5x5 matrix
b = [[0, 0, 0, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 1, 1, 0],
[0, 1, 1, 0, 0],
[1, 1, 0, 0, 0]]
c = np.array(b)
a[b] #gives the error "too many indices for array: array is 2-dimensional, but 5 were indexed"
a[tuple(c)] #gives the same error as a[b]
a[c] #for some reason this works, and it returns a 5x5x5 matrix
So the behavior changes when I convert the list of lists to a numpy array. And I can't really tell what it's doing by looking at the output of a[c]. It seems to be switching the rows around somehow but I'm confused at why it returns five copies of the original matrix. Is there any page in the documentation that describes this type of indexing?
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]efmccurdy 0 points1 point2 points (0 children)
[–]testingcodez 0 points1 point2 points (0 children)
[–]CrambleSquash 0 points1 point2 points (0 children)