Conditions | 4 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 0 |
1 | 1 | class Unit(): |
|
4 | 1 | @staticmethod |
|
5 | def aggregate(judgments, config): |
||
6 | """ aggregate the judgments of a unit """ |
||
7 | 1 | agg = {} |
|
8 | 1 | for col in config.input.values(): |
|
9 | # for each input column the first value is taken. |
||
10 | # all rows have the same value for each unit. |
||
11 | 1 | agg[col] = 'first' |
|
12 | 1 | for col in config.output.values(): |
|
13 | # each output column dict is summed |
||
14 | 1 | agg[col] = 'sum' |
|
15 | 1 | agg['job'] = 'first' |
|
16 | 1 | agg['worker'] = 'count' |
|
17 | 1 | agg['duration'] = 'mean' |
|
18 | |||
19 | 1 | units = judgments.groupby('unit').agg(agg) |
|
20 | |||
21 | # |
||
22 | # get unit metrics |
||
23 | # |
||
24 | # for each vector in the unit get the unit metrics |
||
25 | 1 | units = units.apply(lambda row: Unit.get_metrics(row, config), axis=1) |
|
26 | |||
27 | # sort columns |
||
28 | 1 | units = units.reindex(sorted(units.columns), axis=1) |
|
29 | |||
30 | 1 | return units |
|
31 | |||
39 |