Hello. I have a suggestion that might make slicing using matrices more user-friendly. I often have a matrix of row or column numbers that I wish to use as a slice. If K was a matrix of row numbers (nx1) and M was a nxm matrix, then I would use ans = M[K.A.ravel(),:] to obtain the matrix I want. It turns out that I use .A.ravel() quite a lot in my code, as I usually work with matrices rather than arrays. My suggestion is to create a new attribute, such as .AR, so that the following could be used: M[K.AR,:]. I believe this would be more concise, easier to read, and well used. If slices are made in both directions of the matrix, then the .A.ravel() becomes even more unwieldy. Does anyone else like this idea? John __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------------------------- 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
On 10/20/06, JJ <josh8912@yahoo.com> wrote:
My suggestion is to create a new attribute, such as .AR, so that the following could be used: M[K.AR,:]
It would be even better if M[K,:] worked. Would such a patch be accepted? (Not that I know how to make it.) ------------------------------------------------------------------------- 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
Keith Goodman wrote:
On 10/20/06, JJ <josh8912@yahoo.com> wrote:
My suggestion is to create a new attribute, such as .AR, so that the following could be used: M[K.AR,:]
It would be even better if M[K,:] worked. Would such a patch be accepted? (Not that I know how to make it.)
What exactly do you want to work? -Travis ------------------------------------------------------------------------- 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
On 10/23/06, Travis Oliphant <oliphant.travis@ieee.org> wrote:
Keith Goodman wrote:
On 10/20/06, JJ <josh8912@yahoo.com> wrote:
My suggestion is to create a new attribute, such as .AR, so that the following could be used: M[K.AR,:]
It would be even better if M[K,:] worked. Would such a patch be accepted? (Not that I know how to make it.)
What exactly do you want to work?
x matrix([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) idx matrix([[1], [3]]) I'd like (if it doesn't break the consistency of numpy): -------------------------------------- x[idx, :] to give matrix([[ 4, 5, 6 , 7], 12, 13, 14 ,15]]) instead of matrix([[[ 4, 5, 6, 7]], [[12, 13, 14, 15]]]) -------------------------------------- x[:, idx] top give a 4x2 matrix instead of an error -------------------------------------- x[x[:,0] > 4, :] to give a 2x4 matrix instead of a 1x2 matrix -------------------------------------- I'd also like a pony. ------------------------------------------------------------------------- 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
JJ wrote:
Hello. I have a suggestion that might make slicing using matrices more user-friendly. I often have a matrix of row or column numbers that I wish to use as a slice. If K was a matrix of row numbers (nx1) and M was a nxm matrix, then I would use ans = M[K.A.ravel(),:] to
I had thought that something like that would be useful. It's called .A1 -Travis ------------------------------------------------------------------------- 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
participants (3)
-
JJ
-
Keith Goodman
-
Travis Oliphant