On Aug 29, 9:43 am, Jorgen Grahn <[EMAIL PROTECTED]> wrote:
> On 27 Aug 2008 15:50:14 GMT, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Tue, 26 Aug 2008 17:04:19 -0700, tdmj wrote:
>
> >> On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote:
> >>> I have a list that starts with zeros, has sporadi
On 27 Aug 2008 15:50:14 GMT, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Tue, 26 Aug 2008 17:04:19 -0700, tdmj wrote:
>
>> On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote:
>>> I have a list that starts with zeros, has sporadic data, and then has
>>> good data. I define the point at which the data
On Aug 27, 11:50 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Tue, 26 Aug 2008 17:04:19 -0700, tdmj wrote:
> > On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote:
> >> I have a list that starts with zeros, has sporadic data, and then has
> >> good data. I define the point at whi
On Aug 27, 3:42 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> Below are two more versions that pass all the doctests: the first
> works only for lists and modifies them in place and the second works
> for arbitrary iterables:
>
> def clean_inplace(seq, good_ones=4):
> start = 0
> n = len(s
George Sakkis wrote:
On Aug 27, 3:00 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is fol
On Aug 27, 6:14 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Aug 27, 5:48 pm, castironpi <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 27, 4:34 pm, [EMAIL PROTECTED] wrote:
>
> > > George Sakkis:
>
> > > > This seems the most efficient so far for arbitrary iterables.
>
> > > This one probably sc
On Aug 27, 5:48 pm, castironpi <[EMAIL PROTECTED]> wrote:
> On Aug 27, 4:34 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > George Sakkis:
>
> > > This seems the most efficient so far for arbitrary iterables.
>
> > This one probably scores well with Psyco ;-)
>
> > def start_good3(seq, good_ones=4):
> >
On Aug 27, 5:34 pm, [EMAIL PROTECTED] wrote:
> George Sakkis:
>
> > This seems the most efficient so far for arbitrary iterables.
>
> This one probably scores well with Psyco ;-)
I think if you update this so that it returns the "good" iterable
instead of the starting index, it is equivalent to Ge
On Aug 27, 4:34 pm, [EMAIL PROTECTED] wrote:
> George Sakkis:
>
> > This seems the most efficient so far for arbitrary iterables.
>
> This one probably scores well with Psyco ;-)
>
> def start_good3(seq, good_ones=4):
> n_good = 0
> pos = 0
> for el in seq:
> if el:
>
George Sakkis:
> This seems the most efficient so far for arbitrary iterables.
This one probably scores well with Psyco ;-)
def start_good3(seq, good_ones=4):
"""
>>> start_good = start_good3
>>> start_good([0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
4
>>> start_good([])
-1
On Aug 27, 3:00 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I have a list that starts with zeros, has sporadic data, and then has
> > good data. I define the point at which the data turns good to be the
> > first index with a non-zero entry that is followed by at
On Aug 26, 10:39 pm, [EMAIL PROTECTED] wrote:
> On Aug 26, 7:23 pm, Emile van Sebille <[EMAIL PROTECTED]> wrote:
>
>
>
> > [EMAIL PROTECTED] wrote:
> > > I have a list that starts with zeros, has sporadic data, and then has
> > > good data. I define the point at which the data turns good to be the
[EMAIL PROTECTED] wrote:
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is followed by at least 4
consecutive non-zero data items (i.e. a week's worth of non-zero
da
On Tue, 26 Aug 2008 17:04:19 -0700, tdmj wrote:
> On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote:
>> I have a list that starts with zeros, has sporadic data, and then has
>> good data. I define the point at which the data turns good to be the
>> first index with a non-zero entry that is followed by
[EMAIL PROTECTED] wrote:
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is followed by at least 4
consecutive non-zero data items (i.e. a week's worth of non-zero
da
Matthew Fitzgibbons wrote:
[EMAIL PROTECTED] wrote:
reHist = [0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 0
for i, d in enumerate(reHist):
if d == 0:
count = 0
else:
count += 1
if count == 5:
break
else:
raise Exception("No data found")
reHist = re
On Aug 26, 7:23 pm, Emile van Sebille <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I have a list that starts with zeros, has sporadic data, and then has
> > good data. I define the point at which the data turns good to be the
> > first index with a non-zero entry that is followed by a
On Aug 26, 5:49 pm, [EMAIL PROTECTED] wrote:
> I have a list that starts with zeros, has sporadic data, and then has
> good data. I define the point at which the data turns good to be the
> first index with a non-zero entry that is followed by at least 4
> consecutive non-zero data items (i.e. a w
[EMAIL PROTECTED] wrote:
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is followed by at least 4
consecutive non-zero data items (i.e. a week's worth of non-zero
da
On Aug 26, 4:49 pm, [EMAIL PROTECTED] wrote:
> I have a list that starts with zeros, has sporadic data, and then has
> good data. I define the point at which the data turns good to be the
> first index with a non-zero entry that is followed by at least 4
> consecutive non-zero data items (i.e. a w
[EMAIL PROTECTED] wrote:
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is followed by at least 4
consecutive non-zero data items (i.e. a week's worth of non-zero
da
Sorry, in the Psyco version replace this line:
for i, el in enumerate(alist):
With:
for i in xrange(len(alist)):
because Psyco doesn't digest enumerate well.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
First solutions I have found, not much tested beside the few doctests:
from itertools import islice
def start_good1(alist, good_ones=4):
"""
Maybe more efficient for Python
>>> start_good = start_good1
>>> start_good([0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
4
>>> start_go
I have a list that starts with zeros, has sporadic data, and then has
good data. I define the point at which the data turns good to be the
first index with a non-zero entry that is followed by at least 4
consecutive non-zero data items (i.e. a week's worth of non-zero
data). For example, if my lis
24 matches
Mail list logo