-
Notifications
You must be signed in to change notification settings - Fork 0
/
aTestFunctions.py
99 lines (73 loc) · 3.79 KB
/
aTestFunctions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from toolGetters import *
import aTestIdealScores
#Weighted percentage distances
def calcDisplaySizeScore(minDS,maxDS,devices):
for aDevice in devices:
deviceDS=get_display_size(aDevice)
if minDS<=deviceDS<=maxDS:
aDevice['displaySizeScore']=0
else:
if deviceDS<minDS:
aDevice['displaySizeScore']=(deviceDS-minDS)*100*5
else:
aDevice['displaySizeScore']=(maxDS-deviceDS)*100*5
def calcPPIScore(devicePPI,touGoal):
idealMinimum=touGoal
return ((devicePPI-idealMinimum)/idealMinimum)*100 if devicePPI<touGoal else 0
def calcStBScore(deviceStB,touGoal):
if touGoal<=75: #Gaming
idealMaximum=touGoal
return ((idealMaximum-deviceStB)/idealMaximum)*100*2
idealMinimum=touGoal
return ((deviceStB-idealMinimum)/idealMinimum)*100
def calcRAMScore(deviceRAM,touGoal):
idealMinimum=touGoal
return ((deviceRAM-idealMinimum)/idealMinimum)*100 if deviceRAM<idealMinimum else 0
def calcCapScore(aDevice,touGoal):
idealMinimum=touGoal
deviceCap=get_capacity(aDevice)
if deviceCap<idealMinimum:
return 0 if hasStorageExpansion(aDevice) else ((deviceCap-idealMinimum)/idealMinimum)*100
return 0
def calcYearScore(deviceYear):
currentYear=2019
return 0 if deviceYear==currentYear else -((currentYear-deviceYear)/10)*100
def calcWeightScore(deviceWeight,touGoal):
idealMaximum=touGoal
if touGoal>=170: #Gaming
return ((idealMaximum-deviceWeight)/idealMaximum)*100 if deviceWeight>idealMaximum else 0
return -float(deviceWeight-idealMaximum)
def calcW20PScore(deviceW20P,touGoal):
idealMinimum=touGoal
return ((deviceW20P-idealMinimum)/idealMinimum)*100 if deviceW20P<idealMinimum else 0
def calcW20BScore(deviceW20B,touGoal):
idealMinimum=touGoal
return ((deviceW20B-idealMinimum)/idealMinimum)*100*3 if deviceW20B<idealMinimum else 0
def calcSSEScore(deviceSSE,touGoal):
idealMinimum=touGoal
return ((deviceSSE-idealMinimum)/idealMinimum)*100 if deviceSSE<idealMinimum else 0
def calcToUScore(aDevice,ToU):
aDevice['ppiScore']=calcPPIScore(get_ppi(aDevice),ToU['tou_goals']()['ppi'])
aDevice['stbScore']=calcStBScore(get_stb(aDevice),ToU['tou_goals']()['stb'])
aDevice['ramScore']=calcRAMScore(get_ram(aDevice),ToU['tou_goals']()['ram'])
aDevice['capScore']=calcCapScore(aDevice,ToU['tou_goals']()['cap'])
aDevice['yearScore']=calcYearScore(get_year(aDevice))
aDevice['weightScore']=calcWeightScore(get_weight(aDevice),ToU['tou_goals']()['weight'])
aDevice['w20PScore']=calcW20PScore(get_w2_0_score(aDevice),ToU['tou_goals']()['w2_0_score'])
aDevice['w20BScore']=calcW20BScore(get2_0_battery(aDevice),ToU['tou_goals']()['w2_0_battery'])
aDevice['sseScore']=calcSSEScore(get_grafix(aDevice),ToU['tou_goals']()['grafix'])
aDevice['yearScore']=calcYearScore(get_year(aDevice))
aDevice[ToU["name"]]=float(sum(aDevice[aField] for aField in aDevice if 'Score' in aField))
return aDevice[ToU["name"]]
def calcTotalScore(aDevice,typesOfUse,sumOfWeights):
aDevice['totalPoints']=sum(float(aToU['weight']/sumOfWeights)*calcToUScore(aDevice,typesOfUse[index]) for index,aToU in enumerate(typesOfUse) if typesOfUse[index]['weight']>0)
return aDevice["totalPoints"]
def printDevices(devices):
for index,aDevice in enumerate(devices):
print(f'{index+1}.) {aDevice["fullname"]}')
for aField in aDevice:
if 'Score' in aField:
print(f"{aField}:{aDevice[aField]}")
print(f'Total points: {aDevice["totalPoints"]}\nWork 2.0: {get_w2_0_score(aDevice)}\nBattery 2.0: {get2_0_battery(aDevice,1)} hours\nSling shot score: {get_grafix(aDevice)}\nCapacity: {get_capacity(aDevice)} GB\nDisplay size: {get_display_size(aDevice)}\nStB: {(get_stb(aDevice))}%\nRAM: {get_ram(aDevice)} GB\nPPI: {get_ppi(aDevice)}\nWeight: {get_weight(aDevice)}\nYear: {get_year(aDevice)}\n')
if index==5:
break