[Numpy-discussion] How to use decorator numpy.vectorize for methods in class

2010-07-16 Thread Shailendra
ctorizing            return newfunc(x,y) #< calling the vectorized func def test_test():    test_instance=test()    x=numpy.arange(1,10)    y=numpy.arange(11,20)    print test_instance.operate('add',x,y) if __name__=='__main__':    test_test() ==

[Numpy-discussion] Resending: List of indices

2010-04-04 Thread Shailendra
On Fri, Apr 2, 2010 at 12:34 PM, Shailendra wrote: > Hi All, > >>>> x=arange(10) >>>> indices=[(1,),(2,)] >>>> x[indices] > Traceback (most recent call last): >  File "", line 1, in > IndexError: unsupported iterator index > >

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
Well, this is just a toy problem. argmax represent a method which will give me a index in x[cond] . And for the case of multiple value my requirement is fine with getting any "max" index. Thanks, Shailendra On Fri, Apr 2, 2010 at 3:00 PM, eat wrote: > Shailendra gmail.com> w

[Numpy-discussion] List of indices

2010-04-02 Thread Shailendra
[2, 3], [4, 5], [6, 7], [8, 9]]) >>> indices=[(1,0),(0,1)] >>> x[indices] array([2, 1]) Should not the first one also work? How to convert [(1,),(2,)] to [1,2] efficiently. Thanks, Shailendra ___ NumPy-Discussion maili

Re: [Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
I forgot to mention that i wanted this to work for general shape. So i modified it little bit >>> x = array([[1,2,3,4,5], [6,7,8,7,6], [1,2,3,4,5]]) >>> cond = (x > 5) >>> loc= where(cond) >>> arg_max=argmax(x[cond]) >>> x[tuple([e[arg_max] for e in

[Numpy-discussion] Getting index of array after applying cond

2010-04-02 Thread Shailendra
ax=argmax(x[cond]) >>> max 2 >>> x[cond][max] 8 Now , I want to get the index of this element in x. How to acheive this. In real situation x will be huge. Thanks, Shailendra ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Matrix operation.

2010-04-02 Thread Shailendra
ro=numpy.nonzero(A) >>> non_zero (array([0, 0, 1, 2]), array([0, 1, 0, 2])) >>> A[non_zero] array([1, 1, 1, 1]) >>> A[non_zero]=X >>> A array([[ 2, 9, 0], [10, 0, 0], [ 0, 0, 3]]) Thanks, Shailendra On Fri, Apr 2, 2010 at 10:35 AM, gerardob w

Re: [Numpy-discussion] Is this odd?

2010-04-02 Thread Shailendra
Thanks everyone for replies/suggestion. It is simple to avoid this problem. But my point that given the behavior of python this behavior seems inconsistent. There could other method provided which could evaluate bool value depending on values stored in the array. Thanks, Shailendra On Fri, Apr 2

[Numpy-discussion] Is this odd?

2010-04-01 Thread Shailendra
they have. Also, please suggest the best way to differentiate between an empty array and non-empty array( irrespective to what is inside array). Thanks, Shailendra ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] "Match" two arrays

2010-03-31 Thread Shailendra
t has either 1 "match"(closest point) or none Also, the size of the cordinates1 and cordinates2 are quite large and "outer" should not be used. I can think of only C style code to achieve this. Can any one suggest pythonic way of doing this? Thanks, Shailendra __