>> x = asmatrix(rand(3,2)) >> y = asmatrix(rand(3,1))
>> y matrix([[ 0.77952062], [ 0.97110465], [ 0.77450218]]) >> idx = where(y > 0.5)[0] >> idx matrix([[0, 1, 2]]) >> x[idx,:] matrix([[ 0.24837887, 0.52988253], [ 0.28661085, 0.43053076], [ 0.05360893, 0.22668509]]) So far everything works as it should. Now the problem: >> y[idx,:] --------------------------------------------------------------------------- exceptions.ValueError Traceback (most recent call last) /usr/local/lib/python2.4/site-packages/numpy/core/defmatrix.py in __getitem__(self, index) 120 121 def __getitem__(self, index): --> 122 out = N.ndarray.__getitem__(self, index) 123 # Need to swap if slice is on first index 124 retscal = False /usr/local/lib/python2.4/site-packages/numpy/core/defmatrix.py in __array_finalize__(self, obj) 116 self.shape = (1,1) 117 elif ndim == 1: --> 118 self.shape = (1,self.shape[0]) 119 return 120 ValueError: total size of new array must be unchanged And, on a related note, shouldn't this be a column vector? >> x[idx,0] matrix([[ 0.24837887, 0.28661085, 0.05360893]]) 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 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion