[Numpy-discussion] indexing bug in numpy r2694 (original) (raw)
Pau Gargallo pau.gargallo at gmail.com
Wed Jun 28 13:40:35 EDT 2006
- Previous message (by thread): [Numpy-discussion] indexing bug in numpy r2694
- Next message (by thread): [Numpy-discussion] indexing bug in numpy r2694
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
i don't know why 'where' is returning matrices. if you use:
idx = where(y.A > 0.5)[0]
everything will work fine (I guess)
pau
On 6/28/06, Keith Goodman <kwgoodman at gmail.com> wrote:
>> 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 arrayfinalize(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 at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
- Previous message (by thread): [Numpy-discussion] indexing bug in numpy r2694
- Next message (by thread): [Numpy-discussion] indexing bug in numpy r2694
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]