Re: min max of a list

2005-05-06 Thread Steven Bethard
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > >> I get a syntax error in : >> >> py> [(min((abs(p - v), v) for v in valleys + [0] if v < p)[1], >> ... p, >> ... min((abs(p - v), v) for v in valleys if v > p)[1]) >> ... for p in peaks] > > > I think we already covered the part where you

Re: min max of a list

2005-05-06 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I get a syntax error in : > > py> [(min((abs(p - v), v) for v in valleys + [0] if v < p)[1], > ... p, > ... min((abs(p - v), v) for v in valleys if v > p)[1]) > ... for p in peaks] I think we already covered the part where you were using an older version of Pyth

Re: min max of a list

2005-05-06 Thread querypk
oh yes its the same case. even [0,4,9,2,0] as a set [2,6] and may be not [2,7]. Its not that you are wrong its jus that I was not clear. Sorry about that. -- http://mail.python.org/mailman/listinfo/python-list

Re: min max of a list

2005-05-06 Thread querypk
I get a syntax error in : py> [(min((abs(p - v), v) for v in valleys + [0] if v < p)[1], ... p, ... min((abs(p - v), v) for v in valleys if v > p)[1]) ... for p in peaks] -- http://mail.python.org/mailman/listinfo/python-list

Re: min max of a list

2005-05-06 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi Kent, > Thanks for that. But We are considering [..., 0, 101, 0, 0, 0, 0, 0] -> > [13,18] .In fact if you look at the list, the histogram ends at 15 that > is [0,101,0] --> [13,15]. Dont you think so. > Well you consider ..., 0, 4, 9, 2, 0, 0, ... as an int

Re: min max of a list

2005-05-06 Thread querypk
Hi Kent, Thanks for that. But We are considering [..., 0, 101, 0, 0, 0, 0, 0] -> [13,18] .In fact if you look at the list, the histogram ends at 15 that is [0,101,0] --> [13,15]. Dont you think so. -- http://mail.python.org/mailman/listinfo/python-list

Re: min max of a list

2005-05-06 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Hi Steve! > I am not sure if I was clear with my previous post .Ok let me rephrase > it . > > Assume the values list is the > content of a histogram. Then we see that > values = [ 0, 72, 2, 4, 9, 2, 0, 0, 42, 26, 0, 282, > 23, 0, 101, 0, 0, 0, 0

Re: min max of a list

2005-05-06 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > If this is the list. > > values = [ 0, 72, 0, 4, 9, 2, 0, 0, 42, 26, 0, 282, > 23, 0, 101, 0, 0, 0, 0, 0] > > as we can see there are peaks in the list.that is 0,72,0 is a > group(triangle) with peak 72.then 0, 4, 9, 2, 0, 0 with pe

Re: min max of a list

2005-05-06 Thread querypk
Hi Steve! I am not sure if I was clear with my previous post .Ok let me rephrase it . Assume the values list is the content of a histogram. Then we see that values = [ 0, 72, 2, 4, 9, 2, 0, 0, 42, 26, 0, 282, 23, 0, 101, 0, 0, 0, 0, 0] 1 is repeated 72 times, 3 -> 4 t

Re: min max of a list

2005-05-05 Thread querypk
what if we do something like this. Assume the values list is the content of a histogram. Then we see that values = [ 0, 72, 0, 4, 9, 2, 0, 0, 42, 26, 0, 282, 23, 0, 101, 0, 0, 0, 0, 0] 1 is repeated 72 times, 3 -> 4 times and so on. That is the index would be the value

Re: min max of a list

2005-05-05 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Thanks for that. My version of python does'nt find "groupby". I am > using python 2.3.2. Is there a way I could do it with out using groupby itertools.groupby is in Python 2.4. The docs[1] give a Python equivalent, so if for some reason you can't upgrade to the current

Re: min max of a list

2005-05-04 Thread querypk
Thanks for that. My version of python does'nt find "groupby". I am using python 2.3.2. Is there a way I could do it with out using groupby -- http://mail.python.org/mailman/listinfo/python-list

Re: min max of a list

2005-05-04 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > If this is the list. > > values = [ 0, 72, 0, 4, 9, 2, 0, 0, 42, 26, 0, 282, > 23, 0, 101, 0, 0, 0, 0, 0] > > as we can see there are peaks in the list.that is 0,72,0 is a > group(triangle) with peak 72.then 0, 4, 9, 2, 0, 0 with pe

min max of a list

2005-05-04 Thread querypk
If this is the list. values = [ 0, 72, 0, 4, 9, 2, 0, 0, 42, 26, 0, 282, 23, 0, 101, 0, 0, 0, 0, 0] as we can see there are peaks in the list.that is 0,72,0 is a group(triangle) with peak 72.then 0, 4, 9, 2, 0, 0 with peak 9 and 0, 42, 26, 0 with 42 and s