def __init__(self, timestamp, element=None, existing_windows=None): self.timestamp = Timestamp.of(timestamp) self.element = element self.existing_windows = existing_windows
def __init__(self, size, period, offset=0): if size <= 0: raise ValueError('The size parameter must be strictly positive.') self.size = Duration.of(size) self.period = Duration.of(period) self.offset = Timestamp.of(offset) % size
def assign(self, context): timestamp = context.timestamp start = timestamp - (timestamp - self.offset) % self.period return [IntervalWindow(Timestamp.of(s), Timestamp.of(s) + self.size) for s in range(start, start - self.size, -self.period)]
def __init__(self, value, timestamp): self.value = value self.timestamp = Timestamp.of(timestamp)
def __init__(self, value, timestamp, windows): self.value = value self.timestamp = Timestamp.of(timestamp) self.windows = windows
def __init__(self, start, end): super(IntervalWindow, self).__init__(end) self.start = Timestamp.of(start)
def __init__(self, end): self.end = Timestamp.of(end)
def test_of(self): interval = Timestamp(123) self.assertEqual(id(interval), id(Timestamp.of(interval))) self.assertEqual(interval, Timestamp.of(123.0)) with self.assertRaises(TypeError): Timestamp.of(Duration(10))