From: Bernard K. <ber...@be...> - 2005-07-25 09:36:37
|
Dear all, I am using pytables mostly to store data in the form of simple two-dimensional arrays. For my calculations I often need to extract and update submatrices of these arrays. Unfortunately the row and column indexes I am using can not be described as slices because those can be quite random. Can anyone teach me a "good" (meaning memory efficient, fast and elegant) way to code submatrix extraction and update ? The ideal for me would be a code close to this one : x=array([1,2,5,8]) # row index y=array([0,3,7]) # column index a=data[x,y] # returns an array of size [4,3], 'data' is a pytables 2-d array data[x,y]=0 # set the submatrix defined by x rows and y columns to 0 data[x,y]=rand([4,3]) # update of a submatrix data[x,y]=data2[x,y] # copy of a submatrix from one array into another Sincerely, Bernard KAPLAN |