On Thu, Dec 3, 2009 at 10:24 AM, Howard Chong wrote:
> Thanks for all the help and suggestions. I think the partial sort is
> exactly what I need.
>
> I thought of doing it as a full sort with argsort(), but that would be much
> slower if I just need a small number (maybe 7) from a large array,
>
you are wondering, I am doing this to find the 7 nearest neighbors
in a GIS. For a list of zipcodes in America, find the 7 nearest weather
stations.
> Message: 8
> Date: Wed, 02 Dec 2009 22:26:29 -0500
> From: Neal Becker
> Subject: Re: [Numpy-discussion] Find the N maximu
On Wed, Dec 2, 2009 at 7:31 PM, Neal Becker wrote:
> Keith Goodman wrote:
>
>> On Wed, Dec 2, 2009 at 7:15 PM, Neal Becker
> wrote:
>>> Neal Becker wrote:
>>>
Keith Goodman wrote:
...
> Oh, I thought he meant there was a numpy function for partial
>>> sorting.
>
Actually, I
Keith Goodman wrote:
> On Wed, Dec 2, 2009 at 7:15 PM, Neal Becker
wrote:
>> Neal Becker wrote:
>>
>>> Keith Goodman wrote:
>>> ...
Oh, I thought he meant there was a numpy function for partial
>> sorting.
>>> Actually, I do use this myself. My code is a boost::python
wrapper
>> or
>
Neal Becker wrote:
> Keith Goodman wrote:
> ...
>> Oh, I thought he meant there was a numpy function for partial
sorting.
>>
Try this one:
template
inline void partial_sort (in_t in, int n_el) {
std::partial_sort (boost::begin (in), boost::begin(in) + n_el,
boost::end (in));
}
...
def ("pa
On Wed, Dec 2, 2009 at 7:15 PM, Neal Becker wrote:
> Neal Becker wrote:
>
>> Keith Goodman wrote:
>> ...
>>> Oh, I thought he meant there was a numpy function for partial
> sorting.
>>>
>> Actually, I do use this myself. My code is a boost::python wrapper
> or
>> the std::partial_sum using pyubla
Neal Becker wrote:
> Keith Goodman wrote:
> ...
>> Oh, I thought he meant there was a numpy function for partial
sorting.
>>
> Actually, I do use this myself. My code is a boost::python wrapper
or
> the std::partial_sum using pyublas. Here's the main pieces:
>
> template
> inline out_t parti
Keith Goodman wrote:
...
> Oh, I thought he meant there was a numpy function for partial sorting.
>
Actually, I do use this myself. My code is a boost::python wrapper or
the std::partial_sum using pyublas. Here's the main pieces:
template
inline out_t partial_sum (in_t const& in) {
out_t out
On Wed, Dec 2, 2009 at 5:44 PM, Charles R Harris
wrote:
>
>
> On Wed, Dec 2, 2009 at 6:32 PM, Anne Archibald
> wrote:
>>
>> 2009/12/2 David Warde-Farley :
>> > On 2-Dec-09, at 8:09 PM, Neal Becker wrote:
>> >
>> >> Not bad, although I wonder whether a partial sort could be faster.
>> >
>> > Proba
On 2-Dec-09, at 8:32 PM, Anne Archibald wrote:
> 2009/12/2 David Warde-Farley :
>> On 2-Dec-09, at 8:09 PM, Neal Becker wrote:
>>
>>> Not bad, although I wonder whether a partial sort could be faster.
>>
>> Probably (if the array is large) but depending on n, not if it's in
>> Python. Ideal probl
On Wed, Dec 2, 2009 at 5:52 PM, Anne Archibald
wrote:
> 2009/12/2 Keith Goodman :
>> On Wed, Dec 2, 2009 at 5:27 PM, Anne Archibald
>> wrote:
>>> 2009/12/2 Keith Goodman :
On Wed, Dec 2, 2009 at 5:09 PM, Neal Becker wrote:
> David Warde-Farley wrote:
>
>> On 2-Dec-09, at 6:55 PM
2009/12/2 Keith Goodman :
> On Wed, Dec 2, 2009 at 5:27 PM, Anne Archibald
> wrote:
>> 2009/12/2 Keith Goodman :
>>> On Wed, Dec 2, 2009 at 5:09 PM, Neal Becker wrote:
David Warde-Farley wrote:
> On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
>
>> def myFindMaxA(myList):
>
On Wed, Dec 2, 2009 at 6:32 PM, Anne Archibald wrote:
> 2009/12/2 David Warde-Farley :
> > On 2-Dec-09, at 8:09 PM, Neal Becker wrote:
> >
> >> Not bad, although I wonder whether a partial sort could be faster.
> >
> > Probably (if the array is large) but depending on n, not if it's in
> > Python.
On Wed, Dec 2, 2009 at 5:27 PM, Anne Archibald
wrote:
> 2009/12/2 Keith Goodman :
>> On Wed, Dec 2, 2009 at 5:09 PM, Neal Becker wrote:
>>> David Warde-Farley wrote:
>>>
On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
> def myFindMaxA(myList):
> """implement finding maximum valu
2009/12/2 David Warde-Farley :
> On 2-Dec-09, at 8:09 PM, Neal Becker wrote:
>
>> Not bad, although I wonder whether a partial sort could be faster.
>
> Probably (if the array is large) but depending on n, not if it's in
> Python. Ideal problem for Cython, though.
How is Cython support for generic
Keith Goodman wrote:
...
>> Not bad, although I wonder whether a partial sort could be faster.
>
> I'm doing a lot of sorting right now. I only need to sort the lowest
> 30% of values in a 1d array (about 250k elements), the rest I don't
> need to sort. How do I do a partial sort?
I only know of
2009/12/2 Keith Goodman :
> On Wed, Dec 2, 2009 at 5:09 PM, Neal Becker wrote:
>> David Warde-Farley wrote:
>>
>>> On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
>>>
def myFindMaxA(myList):
"""implement finding maximum value with for loop iteration"""
maxIndex=0
maxVal=m
On 2-Dec-09, at 8:09 PM, Neal Becker wrote:
> Not bad, although I wonder whether a partial sort could be faster.
Probably (if the array is large) but depending on n, not if it's in
Python. Ideal problem for Cython, though.
David
___
NumPy-Discussion
On Wed, Dec 2, 2009 at 5:09 PM, Neal Becker wrote:
> David Warde-Farley wrote:
>
>> On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
>>
>>> def myFindMaxA(myList):
>>> """implement finding maximum value with for loop iteration"""
>>> maxIndex=0
>>> maxVal=myList[0]
>>> for index, item in e
David Warde-Farley wrote:
> On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
>
>> def myFindMaxA(myList):
>>"""implement finding maximum value with for loop iteration"""
>>maxIndex=0
>>maxVal=myList[0]
>>for index, item in enumerate(myList):
>>if item[0]>maxVal:
>>
On 2-Dec-09, at 6:55 PM, Howard Chong wrote:
> def myFindMaxA(myList):
>"""implement finding maximum value with for loop iteration"""
>maxIndex=0
>maxVal=myList[0]
>for index, item in enumerate(myList):
>if item[0]>maxVal:
>maxVal=item[0]
>maxIndex=i
On Dec 2, 2009, at 6:55 PM, Howard Chong wrote:
>
> My question is: how can I make the latter version run faster? I think the
> answer is that I have to do the iteration in C.
>
> If that's the case, can anyone point me to where np.array.argmax() is
> implemented so I can write np.array.argmaxN
I will need to find the N largest numbers and corresponding indexes in an
1-D array.
If N==1, I can easily do:
def myFindMaxC(myList):
"""implement finding maximum value with using numpy.array()"""
myA=np.array(myList)
maxIndex=myA.argmax()
maxVal=myA[maxIndex]
return [maxInde
23 matches
Mail list logo