Passed
Push — dependabot/pip/pyarrow-5.0.0 ( 101caa...cfe875 )
by
unknown
01:39
created

mandos.analysis.io_defns   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 52
dl 0
loc 69
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A _to_long_form() 0 8 2
1
"""
2
Definitions of input types for analysis.
3
"""
4
5
import math
0 ignored issues
show
Unused Code introduced by
The import math seems to be unused.
Loading history...
6
from collections import defaultdict
0 ignored issues
show
Unused Code introduced by
Unused defaultdict imported from collections
Loading history...
7
from itertools import cycle
0 ignored issues
show
Unused Code introduced by
Unused cycle imported from itertools
Loading history...
8
from typing import Collection, Dict, Sequence, Set, Tuple, Union, Optional
0 ignored issues
show
Unused Code introduced by
Unused Dict imported from typing
Loading history...
Unused Code introduced by
Unused Union imported from typing
Loading history...
Unused Code introduced by
Unused Tuple imported from typing
Loading history...
Unused Code introduced by
Unused Set imported from typing
Loading history...
Unused Code introduced by
Unused Sequence imported from typing
Loading history...
Unused Code introduced by
Unused Collection imported from typing
Loading history...
Unused Code introduced by
Unused Optional imported from typing
Loading history...
9
10
import numpy as np
0 ignored issues
show
introduced by
Unable to import 'numpy'
Loading history...
Unused Code introduced by
Unused numpy imported as np
Loading history...
11
import pandas as pd
0 ignored issues
show
introduced by
Unable to import 'pandas'
Loading history...
Unused Code introduced by
Unused pandas imported as pd
Loading history...
12
from typeddfs import TypedDfs
0 ignored issues
show
introduced by
Unable to import 'typeddfs'
Loading history...
13
14
15
def _to_long_form(self, kind: str, key: str):
16
    if kind not in ["phi", "psi"]:
17
        raise ValueError(f"'type' should be 'phi' or 'psi', not {kind}")
18
    df = self.long_form()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
19
    df = df.rename(columns=dict(row="inchikey_1", column="inchikey_2"))
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" 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...
20
    df["type"] = kind
21
    df["key"] = key
22
    return SimilarityDfLongForm.convert(df)
23
24
25
SimilarityDfLongForm = (
26
    TypedDfs.typed("SimilarityDfLongForm")
27
    .require("inchikey_1", "inchikey_2", dtype=str)
28
    .require("type", "key", dtype=str)
29
    .require("value", dtype=float)
30
    .reserve("sample", dtype=int)
31
    .strict()
32
).build()
33
34
SimilarityDfShortForm = (
35
    TypedDfs.affinity_matrix("SimilarityDfShortForm").add_methods(to_long_form=_to_long_form)
36
).build()
37
38
ScoreDf = (
39
    TypedDfs.typed("InputScoreFrame")
40
    .require("inchikey", "score_name", dtype=str)
41
    .require("score_value", dtype=float)
42
).build()
43
44
45
EnrichmentDf = (
46
    TypedDfs.typed("EnrichmentFrame")
47
    .require("predicate", "object", "key", "source", dtype=str)
48
    .require("score_name", dtype=str)
49
    .require("value", "inverse", dtype=float)
50
    .reserve("sample", dtype=int)
51
).build()
52
53
54
ConcordanceDf = (
55
    TypedDfs.typed("ConcordanceDf")
56
    .require("phi", "psi", dtype=str)
57
    .require("tau", dtype=float)
58
    .reserve("sample", dtype=int)
59
).build()
60
61
62
PsiProjectedDf = (
63
    TypedDfs.typed("PsiProjectedDf")
64
    .require("psi", dtype=str)
65
    .require("inchikey", dtype=str)
66
    .require("x", "y", dtype=float)
67
    .reserve("color", "marker", dtype=str)
68
).build()
69