test.test_metrics   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 66
dl 0
loc 86
rs 10
c 0
b 0
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A test_b_cubed() 0 9 1
A example_clusters() 0 7 1
A test_corefevaluator() 0 11 1
A test_f1() 0 6 1
A test_ceafe() 0 8 1
A test_muc() 0 9 1
A test_evaluate_documents() 0 11 2
A test_f1_zero() 0 6 1
1
import e2edutch.metrics
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
import math
0 ignored issues
show
introduced by
standard import "import math" should be placed before "import e2edutch.metrics"
Loading history...
3
4
5
def test_f1():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
6
    num = 10
7
    p_den = 100
8
    r_den = 50
9
    f1 = e2edutch.metrics.f1(num, p_den, num, r_den)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f1" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
10
    assert math.isclose(f1, 2.0/15)
11
12
13
def test_f1_zero():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
14
    num = 0
15
    p_den = 0
16
    r_den = 0
17
    f1 = e2edutch.metrics.f1(num, p_den, num, r_den)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f1" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
18
    assert math.isclose(f1, 0)
19
20
21
def test_corefevaluator():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
22
    evaluator = e2edutch.metrics.CorefEvaluator()
23
    assert evaluator.get_f1() == 0
24
    assert evaluator.get_recall() == 0
25
    assert evaluator.get_precision() == 0
26
27
    # empty update
28
    evaluator.update([], [], {}, {})
29
    assert evaluator.get_f1() == 0
30
    assert evaluator.get_recall() == 0
31
    assert evaluator.get_precision() == 0
32
33
34
def test_evaluate_documents():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
35
    metrics = [e2edutch.metrics.muc,
36
               e2edutch.metrics.b_cubed,
37
               e2edutch.metrics.lea,
38
               e2edutch.metrics.ceafe]
39
    documents = []
40
    for metric in metrics:
41
        p, r, f = e2edutch.metrics.evaluate_documents(documents, metric)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "p" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "r" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
42
        assert p == 0
43
        assert r == 0
44
        assert f == 0
45
46
47
def example_clusters():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
48
    mentions = tuple([(i*2, i*2+1) for i in range(9)])
49
    a, b, c, d, e, f, g, h, i = mentions
0 ignored issues
show
Coding Style Naming introduced by
Variable name "a" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "b" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "c" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "d" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "e" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "g" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "h" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
50
    pred_clusters = [(a, b), (c, d), (f, g, h, i)]
51
    gold_clusters = [(a, b, c), (d, e, f, g)]
52
    mentions_to_gold = {m: cl for cl in tuple(gold_clusters) for m in cl}
53
    return pred_clusters, gold_clusters, mentions_to_gold
54
55
56
def test_muc():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
57
    clusters = [((0, 1), (2, 3))]
58
    mentions_to_gold = {m: cl for cl in tuple(clusters) for m in cl}
59
    num, dem = e2edutch.metrics.muc(clusters, mentions_to_gold)
60
    assert math.isclose(num/dem, 1)
61
62
    clusters, _, mentions_to_gold = example_clusters()
63
    num, dem = e2edutch.metrics.muc(clusters, mentions_to_gold)
64
    assert math.isclose(num/dem, 0.4)
65
66
67
def test_b_cubed():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
68
    clusters = [((0, 1), (2, 3))]
69
    mentions_to_gold = {m: cl for cl in tuple(clusters) for m in cl}
70
    num, dem = e2edutch.metrics.b_cubed(clusters, mentions_to_gold)
71
    assert math.isclose(num/dem, 1)
72
73
    clusters, _, mentions_to_gold = example_clusters()
74
    num, dem = e2edutch.metrics.b_cubed(clusters, mentions_to_gold)
75
    assert math.isclose(num/dem, 0.5)
76
77
78
def test_ceafe():
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
79
    clusters = [((0, 1), (2, 3))]
80
    pn, pd, rn, rd = e2edutch.metrics.ceafe(clusters, clusters)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "pn" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "pd" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "rn" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "rd" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Unused Code introduced by
The variable rn seems to be unused.
Loading history...
Unused Code introduced by
The variable rd seems to be unused.
Loading history...
81
    assert math.isclose(pn/pd, 1)
82
83
    clusters, gold_clusters, _ = example_clusters()
84
    pn, pd, rn, rd = e2edutch.metrics.ceafe(clusters, gold_clusters)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "pn" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "pd" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "rn" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "rd" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
85
    assert math.isclose(pn/pd, 0.43, abs_tol=0.005)
86