GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 59002d...d6d549 )
by Oana
17:31
created

crowdtruth.models.unit.Unit.get_metrics()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 2
nop 2
crap 2
1 1
class Unit():
2
3
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
32 1
    @staticmethod
33
    def get_metrics(row, config):
34
        """ count the number of annotations for each unit """
35 1
        for col in config.output.values():
36 1
            row[col+'.unique_annotations'] = len(row[col])
37 1
            row[col+'.annotations'] = sum(row[col].values())
38
        return row
39