Re: [Numpy-discussion] Index update

2012-01-10 Thread Mads Ipsen
Thanks - very cool! On 10/01/2012 21:45, Val Kalatsky wrote: A - np.digitize(A, S) Should do the trick, just make sure that S is sorted and A and S do not overlap, if they do remove those items from A using set operations. Val On Tue, Jan 10, 2012 at 2:14 PM, Mads Ipsen

Re: [Numpy-discussion] Index update

2012-01-10 Thread Val Kalatsky
A - np.digitize(A, S) Should do the trick, just make sure that S is sorted and A and S do not overlap, if they do remove those items from A using set operations. Val On Tue, Jan 10, 2012 at 2:14 PM, Mads Ipsen wrote: > ** > Hi, > > Suppose you have N items, say N = 10. > > Now a subset of these

[Numpy-discussion] Index update

2012-01-10 Thread Mads Ipsen
Hi, Suppose you have N items, say N = 10. Now a subset of these items are selected given by a list A of indices. Lets say that items A = [2,5,7] are selected. Assume now that you delete some of the items given by the indices S = [1,4,8]. This means that the list of indices A must be updated,

Re: [Numpy-discussion] Ufuncs and flexible types, CAPI

2012-01-10 Thread Val Kalatsky
Hi Samuel, Thanks for the reply. I hoped somebody will prove me wrong on ufuncs' limitation: no flexible type support. Also wanted to bring up a discussion on changing ufunc API. I think adding another parameter that delivers pointers to arrays to the loops would not lead to any undesirable conse

Re: [Numpy-discussion] Ufuncs and flexible types, CAPI

2012-01-10 Thread Samuel John
[sorry for duplicate - I used the wrong mail address] I am afraid, I didn't quite get the question. What is the scenario? What is the benefit that would weight out the performance hit of checking whether there is a callback or not. This has to be evaluated quite a lot. Oh well ... and 1.3.0 is

Re: [Numpy-discussion] SParse feature vector generation

2012-01-10 Thread Samuel John
I would just use a lookup dict: names = [ "uc_berkeley", "stanford", "uiuc", "google", "intel", "texas_instruments", "bool"] lookup = dict( zip( range(len(names)), names ) ) Now, given you have n entries: S = numpy.zeros( (n, len(names)) ,dtype=numpy.int32) for k in ["uc_berkeley", "google",