Used colored header in the presence graph

parent f6833a7b
from datetime import datetime, timedelta, time, date
from typing import Tuple, List
from typing import Tuple, List, Union
import numpy
from sqlalchemy import asc
......@@ -7,7 +7,6 @@ from sqlalchemy import asc
from bitsd.persistence.engine import session_scope
from bitsd.persistence.models import Status
from .graph import PresenceGraph
from .parameters import WINDOW_WIDTH, START_TIME, END_TIME, DELTA_SAMPLE, DATA_WEIGHTS
......@@ -79,7 +78,7 @@ class Presence():
return data
def get_prevision(self) -> List[List[float]]:
def get_prevision(self, with_average=False) -> Union[List[List[float]], Tuple[List[List[float]], List[float]]]:
raw_data = self.get_data()
data = [[], [], [], [], []]
......@@ -90,7 +89,15 @@ class Presence():
for j, _ in enumerate(day_data):
data[i].append(numpy.average(day_data[j], weights=DATA_WEIGHTS[:len(day_data[j])]))
return data
if with_average:
average = []
for i in range(5):
average.append(numpy.average(data[i]))
return data, average
else:
return data
def _status(self, data: List[Tuple[time, bool]], hour: time) -> bool:
status = False
......@@ -104,6 +111,6 @@ class Presence():
return status
def get_graph(self) -> PresenceGraph:
g = PresenceGraph(self.get_prevision())
g = PresenceGraph(*self.get_prevision(True))
g.generate()
return g
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment