# Path: sc2/main.py
# class SlidingTimeWindow:
#     def __init__(self, size: int):
#         assert size > 0
# 
#         self.window_size = size
#         self.window = []
# 
#     def push(self, value: float):
#         self.window = (self.window + [value])[-self.window_size:]
# 
#     def clear(self):
#         self.window = []
# 
#     @property
#     def sum(self) -> float:
#         return sum(self.window)
# 
#     @property
#     def available(self) -> float:
#         return sum(self.window[1:])
# 
#     @property
#     def available_fmt(self) -> float:
#         return ",".join(f"{w:.2f}" for w in self.window[1:])


from sc2.main import SlidingTimeWindow


def test_sliding_time_window():
    stw = SlidingTimeWindow(5)

    stw.push(1.0)
    assert stw.sum == 1.0

    stw.push(1.0)
    assert stw.sum == 2.0


# Path: sc2/main.py
# class SlidingTimeWindow:
#     def __init__(self, size: int):
#         assert size > 0
# 
#         self.window_size = size
#         self.window = []
# 
#     def push(self, value: float):
#         self.window = (self.window + [value])[-self.window_size:]
# 
#     def clear(self):
#         self.window = []
# 
#     @property
#     def sum(self) -> float:
#         return sum(self.window)
# 
#     @property
#     def available(self) -> float:
#         return sum(self.window[1:])
# 
#     @property
#     def available_fmt(self) -> float:
#         return ",".join(f"{w:.2f}" for w in self.window[1:])


# Path: test/test_sliding_window.py
from sc2.main import SlidingTimeWindow


def test_sliding_time_window():
    stw = SlidingTimeWindow(5)

    stw.push(1.0)
    assert stw.sum == 1.0

    stw.push(1.0)
    assert stw.sum == 2.0


    stw.push(2.0)
