예제 #1
0
 def __contains__(self, t):
     if self._timestamps is None:
         return self._values is not None
     else:
         if type(t) in (int, float):
             i2 = bisect_right(self._timestamps, t)
             if i2 == 0: return False
             return close(self._timestamps[i2 - 1], t)
         else:
             raise NotImplementedError("__contains__")
예제 #2
0
 def __delitem__(self, t):
     if self._timestamps is None:
         if t is None:
             self.__init__()
         else:
             raise ObjectForAllTimeError("Currently has one object for all time - cannot delete any part")
     else:
         if type(t) in (int, float):
             i2 = bisect_right(self._timestamps, t)
             if i2 == 0: raise TimestampError("Timestamp before first timestamp")
             if not close(self._timestamps[i2 - 1], t): raise TimestampError("%s not in timeseries" % t)
             del self._timestamps[i2 - 1]
             del self._values[i2 - 1]
         else:
             raise NotImplementedError("__delitem__")