-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResultsAnalyzer.py
33 lines (25 loc) · 950 Bytes
/
ResultsAnalyzer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import statistics
from ChartController import ChartController
class ResultsAnalyzer:
def __init__(self):
self.trailsLengths = []
def analiseResult(self, trailsLengths):
self.trailsLengths = trailsLengths.copy()
bestSolution = self.getBestSolution()
worstSolution = self.getWorstSolution()
avg = self.getAvg()
sd = self.getSd()
return trailsLengths, bestSolution, worstSolution, avg, sd
def getBestSolution(self):
self.trailsLengths.sort()
return round(self.trailsLengths[0])
def getWorstSolution(self):
self.trailsLengths.sort(reverse=True)
return round(self.trailsLengths[0])
def getAvg(self):
return round(sum(self.trailsLengths) / len(self.trailsLengths), 2)
def getSd(self):
if(len(self.trailsLengths)) == 1:
return 0
else:
return round(statistics.stdev(self.trailsLengths), 2)