Example #1
0
 def __getitem__(self, index):
     if isinstance(index, slice):
         # Set the new epoch---note that index.start may also be None
         if self._epoch is None:
             new_epoch = None
         elif index.start is None:
             new_epoch = self._epoch
         else:
             if index.start < 0:
                 raise ValueError('Negative start index not supported')
             new_epoch = self._epoch + index.start * self._delta_t
         return TimeSeries(Array.__getitem__(self, index), self._delta_t, new_epoch, copy=False)
     else:
         return Array.__getitem__(self, index)
Example #2
0
 def __getitem__(self, index):
     if isinstance(index, slice):
         # Set the new epoch---note that index.start may also be None
         if self._epoch is None:
             new_epoch = None
         elif index.start is None:
             new_epoch = self._epoch
         else:
             if index.start < 0:
                 index.start += len(self)
             new_epoch = self._epoch + index.start * self._delta_t
         return TimeSeries(Array.__getitem__(self, index), self._delta_t, new_epoch, copy=False)
     else:
         return Array.__getitem__(self, index)
Example #3
0
 def __getitem__(self, index):
     if isinstance(index, slice):
         # Set the new epoch---note that index.start may also be None
         if self._epoch is None:
             new_epoch = None
         elif index.start is None:
             new_epoch = self._epoch
         else:
             if index.start < 0:
                 raise ValueError('Negative start index not supported')
             new_epoch = self._epoch + index.start * self._delta_t
         return TimeSeries(Array.__getitem__(self, index), self._delta_t, new_epoch, copy=False)
     else:
         return Array.__getitem__(self, index)
Example #4
0
 def __getitem__(self, index):
     if isinstance(index, slice):
         if index.start > index.stop:
             raise ValueError('start index must be smaller than stop index')
         if index.step is None:
             new_delta_t = self._delta_t
         elif index.step < 0:
             raise ValueError('negative step is not supported')
         else:
             new_delta_t = index.step * self._delta_t
         if self._epoch is None:
             new_epoch = None
         else:
             new_epoch = self._epoch + index.start * self._delta_t
         return TimeSeries(Array.__getitem__(self, index),
                           new_delta_t,
                           new_epoch,
                           copy=False)
     else:
         return Array.__getitem__(self, index)