Nov-14-2019, 10:06 AM

Hi all

Does somebedoy know how to use vectors for slicing (see code herebellow)?

I got the following error "only integer scalar arrays can be converted to a scalar index" but I do not understand since I'm using a scalar (numpy) array, or I'm missing something

Thanks

Paul

Does somebedoy know how to use vectors for slicing (see code herebellow)?

I got the following error "only integer scalar arrays can be converted to a scalar index" but I do not understand since I'm using a scalar (numpy) array, or I'm missing something

Thanks

Paul

n = 100 m = 2 A = np.random.randint(66, size=(n,m), dtype=np.int32) i = np.random.randint(n-4, size=int(0.5*n), dtype=np.int32) j = i + 4*np.ones(int(0.5*n), dtype=np.int32) extract1_A = A[i,:] # as usual = OK #extract2_A = A[i:i+4,:] # fails extract3_A = A[i:j,:] # fails