slice assignment: strange behaviour
Alan G Isaac
aisaac at american.edu
Thu Nov 9 10:43:22 CST 2006
On Wed, 08 Nov 2006, koara apparently wrote:
> '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).
Using numpy 1.0 and trying the code below,
I do not see the problem.
import numpy
from numpy import random
m = random.randint(0,1000,(22973,1009))
v = random.randint(0,1000,(22973,))
fr = v[10001]
for i in xrange(1009):
m[:,i] = v
if m[10001, i] != fr:
print m[10001,i], fr
Upgrading to numpy 1.0 should be easy enough and may fix
your problem.
Cheers,
Alan Isaac
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
More information about the Numpy-discussion
mailing list