comparison dataset.py @ 314:105b54ac8260

bug fixed concerning the slicing, now ds[0:len(ds) + 1000 : 2] is accepted, same a python list
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Wed, 11 Jun 2008 13:57:34 -0400
parents 009ce84e9f52
children 5fe6d0c93109
comparison
equal deleted inserted replaced
313:009ce84e9f52 314:105b54ac8260
479 # if slice has a step param, convert it to list and handle it with the 479 # if slice has a step param, convert it to list and handle it with the
480 # list code 480 # list code
481 if type(i) is slice: 481 if type(i) is slice:
482 offset = 0 if i.start is None else i.start 482 offset = 0 if i.start is None else i.start
483 upper_bound = len(self) if i.stop is None else i.stop 483 upper_bound = len(self) if i.stop is None else i.stop
484 upper_bound = min(len(self) , upper_bound)
484 i = list(range(offset, upper_bound, i.step)) 485 i = list(range(offset, upper_bound, i.step))
485 486
486 # handle tuples, arrays, lists 487 # handle tuples, arrays, lists
487 if hasattr(i, '__getitem__'): 488 if hasattr(i, '__getitem__'):
488 for idx in i: 489 for idx in i: