Passed
Push — main ( 83a9fb...fa90c4 )
by Douglas
03:43
created

DataValidityComment.resolve()   B

Complexity

Conditions 6

Size

Total Lines 16
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nop 2
dl 0
loc 16
rs 8.6666
c 0
b 0
f 0
1
from __future__ import annotations
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
import enum
4
from typing import Set, Union
5
6
from mandos.model.utils import CleverEnum
7
8
9
class ActivityRelation(CleverEnum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
10
    lt = enum.auto()
11
    gt = enum.auto()
12
    le = enum.auto()
13
    ge = enum.auto()
14
    eq = enum.auto()
15
    approx = enum.auto()
16
17
    @classmethod
18
    def of(cls, name: Union[int, str]) -> CleverEnum:
0 ignored issues
show
Bug introduced by
Parameters differ from overridden 'of' method
Loading history...
19
        return super().of(
20
            {
21
                "<": "lt",
22
                ">": "gt",
23
                "=": "eq",
24
                "~": "approx",
25
                "<=": "le",
26
                ">=": "ge",
27
            }.get(name, name)
28
        )
29
30
31
class DataValidityComment(CleverEnum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
32
    potential_missing_data = enum.auto()
33
    potential_transcription_error = enum.auto()
34
    potential_author_error = enum.auto()
35
    manually_validated = enum.auto()
36
    outside_typical_range = enum.auto()
37
    non_standard_unit_for_type = enum.auto()
38
    author_confirmed_error = enum.auto()
39
40
    @property
41
    def is_positive(self) -> bool:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
42
        return self in DataValidityComment.positive_comments()
43
44
    @property
45
    def is_negative(self) -> bool:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
46
        return self in DataValidityComment.negative_comments()
47
48
    @classmethod
49
    def positive_comments(cls) -> Set[DataValidityComment]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
50
        return {DataValidityComment.manually_validated}
51
52
    @classmethod
53
    def negative_comments(cls) -> Set[DataValidityComment]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
54
        return {
55
            DataValidityComment.potential_missing_data,
56
            DataValidityComment.potential_transcription_error,
57
            DataValidityComment.potential_author_error,
58
            DataValidityComment.outside_typical_range,
59
            DataValidityComment.non_standard_unit_for_type,
60
            DataValidityComment.author_confirmed_error,
61
        }
62
63
64
class AssayType(enum.Enum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
65
    binding = enum.auto()
66
    functional = enum.auto()
67
    adme = enum.auto()
68
    physicochemical = enum.auto()
69
70
    @property
71
    def character(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
72
        return {
73
            AssayType.binding: "B",
74
            AssayType.functional: "F",
75
            AssayType.adme: "A",
76
            AssayType.physicochemical: "P",
77
        }[self]
78
79
80
__all__ = [
81
    "AssayType",
82
    "DataValidityComment",
83
    "ActivityRelation",
84
]
85