-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.py
308 lines (285 loc) · 10.9 KB
/
results.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
def highest_score(types, scores_table, sorted_types):
"""
Select the type with the highest score
"""
highest_score = sorted_types[-1]
if not all(types):
raise ValueError("Test score is zero")
for score, type in scores_table.items():
if score == highest_score:
return type
def wing_tie(types, scores_table, sorted_types):
"""
In case there are two top types with the same score, select
the one with higher scored wings
"""
second_highest = 0
wing_sum = 0
if not all(types):
raise ValueError("Test score is zero")
if sorted_types[-1] == sorted_types[-2]:
for score, type in scores_table.items():
if sorted_types[-2] == score and type != types["result"]:
second_highest = type
break
wing_scores = [
scores_table[score]
for score, type in scores_table.items()
if type == types["result"] or type == second_highest
]
for index, score in enumerate(wing_scores):
wing_sum += (index + 1) * score
if wing_sum < 5 * 2 * (second_highest + sorted_types[-2]):
return second_highest
def check_triads(types):
"""
Check if the score correlates to the triad groups for a type,
and select it if so
"""
if all(types) == 0:
raise ValueError("Test score is zero")
groups_triads = {
"intelligence": {
"feeling": types["f_2"] + types["c_3"] + types["e_4"],
"thinking": types["h_5"] + types["b_6"] + types["i_7"],
"instinct": types["a_9"] + types["g_8"] + types["d_1"],
},
"hornevian": {
"assertive": types["c_3"] + types["i_7"] + types["g_8"],
"dutiful": types["d_1"] + types["f_2"] + types["b_6"],
"withdrawn": types["e_4"] + types["h_5"] + types["a_9"],
},
"harmonic": {
"positive": types["f_2"] + types["i_7"] + types["a_9"],
"reactive": types["e_4"] + types["b_6"] + types["g_8"],
"competency": types["d_1"] + types["c_3"] + types["h_5"],
},
}
checks = [
(
groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["reactive"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["reactive"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["competency"]
),
(
groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["reactive"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["intelligence"]["feeling"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["competency"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["reactive"]
and groups_triads["harmonic"]["competency"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["hornevian"]["dutiful"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["competency"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["intelligence"]["thinking"]
> groups_triads["intelligence"]["instinct"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["competency"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["reactive"]
),
(
groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["withdrawn"]
and groups_triads["hornevian"]["assertive"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["competency"]
and groups_triads["harmonic"]["reactive"]
> groups_triads["harmonic"]["positive"]
),
(
groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["feeling"]
and groups_triads["intelligence"]["instinct"]
> groups_triads["intelligence"]["thinking"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["assertive"]
and groups_triads["hornevian"]["withdrawn"]
> groups_triads["hornevian"]["dutiful"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["reactive"]
and groups_triads["harmonic"]["positive"]
> groups_triads["harmonic"]["positive"]
),
]
for index, check in enumerate(checks, start=1):
if check:
return index
def result_type(types):
"""
Calculates the Enneagram Type, using various methods
"""
scores_table = {
types["d_1"]: 1,
types["f_2"]: 2,
types["c_3"]: 3,
types["e_4"]: 4,
types["h_5"]: 5,
types["b_6"]: 6,
types["i_7"]: 7,
types["g_8"]: 8,
types["a_9"]: 9,
}
sorted_types = sorted(types.values())
try:
types["result"] = highest_score(types, scores_table, sorted_types)
types["result"] = (wing_tie(types, scores_table, sorted_types) or
types["result"])
types["result"] = check_triads(types) or types["result"]
except ValueError:
raise ValueError("Test score is zero")
return types["result"]
def result_wing(types):
"""
Calculates the Enneagram Type's wing
It just checks which type, corresponding to the wing of the matched basic
type, has a higher score, and assigns the respective wing to it
"""
match types["result"]:
case 1:
if types["a_9"] == types["f_2"]:
wing = 0
elif types["a_9"] > types["f_2"]:
wing = 9
else:
wing = 2
case 2:
if types["d_1"] == types["c_3"]:
wing = 0
elif types["d_1"] > types["c_3"]:
wing = 1
else:
wing = 3
case 3:
if types["f_2"] == types["e_4"]:
wing = 0
elif types["f_2"] > types["e_4"]:
wing = 2
else:
wing = 4
case 4:
if types["c_3"] == types["h_5"]:
wing = 0
elif types["c_3"] > types["h_5"]:
wing = 3
else:
wing = 5
case 5:
if types["e_4"] == types["b_6"]:
wing = 0
elif types["e_4"] > types["b_6"]:
wing = 4
else:
wing = 6
case 6:
if types["h_5"] == types["i_7"]:
wing = 0
elif types["h_5"] > types["i_7"]:
wing = 5
else:
wing = 7
case 7:
if types["b_6"] == types["g_8"]:
wing = 0
elif types["b_6"] > types["g_8"]:
wing = 6
else:
wing = 8
case 8:
if types["i_7"] == types["a_9"]:
wing = 0
elif types["i_7"] > types["a_9"]:
wing = 7
else:
wing = 9
case 9:
if types["g_8"] == types["d_1"]:
wing = 0
elif types["g_8"] > types["d_1"]:
wing = 8
else:
wing = 1
case _:
wing = 0
return wing