From: koara <ko...@at...> - 2006-11-08 22:50:41
|
Hello, a piece of my code started giving strange results with certain data; i managed to track down the cause to a slice array assignment. In the following code snip; 'mat' is a numpy.array with shape=(22973, 1009), 'vec' is a numpy.array with shape=(22973,), both of type int: for i in xrange(1009): ... fr = vec[10001] mat[:, i] = vec # assign whole column if mat[10001, i] != fr: print "how come?" ... for elements beyond index 10000, nothing is assigned (ie, numpy.sum(mat[row, :]) is zero for any row > 10000). As soon as i replace the assignment with a cycle that assigns each element explicitly (for j in xrange(22973): result[j, i] = vec[j]), everything's OK. With some matrices, the above seems to work fine though, as well as for smaller dimensions, so i am unable to provide a full simple example. Any ideas? I am using enthought python (python 2.4.3) which uses numpy version 0.9.9. |