This has bitten me a few times, and I can't tell if it's a bug or a feature.
nums = np.arange(10)
indx1 = np.array([2,4,6,8])
indx2 = np.array([0,3])
It looks like I can index nums either way
nums[indx1][indx2], nums[indx1[indx2]]
outputs (array([2, 8]), array([2, 8]))
If I want to re-assign those values, This doesn't work
nums[indx1][indx2] = 20
nums
outputting array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
But this works as expected:
nums[indx1[indx2]] = 20
nums
outputting array([ 0, 1, 20, 3, 4, 5, 6, 7, 20, 9])
Why do I have to nest my index arrays rather than daisy-chain them?