Skip to content

Commit 8047680

Browse files
Merge pull request #26 from cthoyt/add-black-isort
Re-enable flake8 check
2 parents acd14d4 + cee93b1 commit 8047680

17 files changed

+69
-38
lines changed

.github/workflows/main.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323
python-version: 3.7
2424
- run: conda --version
2525
- run: which python
26+
- name: Install general requirements
27+
run: |
28+
pip install tox
29+
- name: Run flake8
30+
run: |
31+
tox -e flake8
2632
- name: Run installation.
2733
run: |
2834
conda install -y scipy

chemicalx/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
from chemicalx.data import contextfeatureset, drugfeatureset, labeledtriples, datasetloader # noqa:F401,F403
2-
1+
from chemicalx.data import ( # noqa:F401,F403
2+
contextfeatureset,
3+
datasetloader,
4+
drugfeatureset,
5+
labeledtriples,
6+
)
37
from chemicalx.models import ( # noqa:F401,F403
48
audnnsynergy,
59
caster,
@@ -16,5 +20,4 @@
1620
mrgnn,
1721
ssiddi,
1822
)
19-
2023
from chemicalx.version import __version__

chemicalx/data/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from class_resolver import Resolver
22

3+
from .batchgenerator import * # noqa:F401,F403
34
from .contextfeatureset import * # noqa:F401,F403
4-
from .drugfeatureset import * # noqa:F401,F403
5-
from .labeledtriples import * # noqa:F401,F403
65
from .datasetloader import * # noqa:F401,F403
6+
from .drugfeatureset import * # noqa:F401,F403
77
from .drugpairbatch import * # noqa:F401,F403
8-
from .batchgenerator import * # noqa:F401,F403
8+
from .labeledtriples import * # noqa:F401,F403
99

1010
dataset_resolver = Resolver.from_subclasses(base=DatasetLoader)

chemicalx/data/batchgenerator.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import math
2-
import torch
3-
import pandas as pd
4-
import numpy as np
52
from typing import List
3+
4+
import numpy as np
5+
import pandas as pd
6+
import torch
67
from torchdrug.data import PackedGraph
7-
from chemicalx.data import LabeledTriples, DrugFeatureSet, ContextFeatureSet, DrugPairBatch
8+
9+
from chemicalx.data import (
10+
ContextFeatureSet,
11+
DrugFeatureSet,
12+
DrugPairBatch,
13+
LabeledTriples,
14+
)
815

916

1017
class BatchGenerator:

chemicalx/data/contextfeatureset.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import torch
2-
import numpy as np
31
from typing import Dict, List
42

3+
import numpy as np
4+
import torch
5+
56

67
class ContextFeatureSet(dict):
78
"""

chemicalx/data/datasetloader.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import io
22
import json
3-
import numpy as np
4-
import pandas as pd
53
import urllib.request
64
from typing import Dict
7-
from chemicalx.data import DrugFeatureSet, ContextFeatureSet, LabeledTriples
5+
6+
import numpy as np
7+
import pandas as pd
8+
9+
from chemicalx.data import ContextFeatureSet, DrugFeatureSet, LabeledTriples
810

911
__all__ = [
1012
"DatasetLoader",

chemicalx/data/drugfeatureset.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from typing import Dict, List, Union
2+
3+
import numpy as np
14
import torch
25
import torchdrug
3-
import numpy as np
4-
from typing import List, Dict, Union
5-
from torchdrug.data import Molecule, Graph, PackedGraph
6+
from torchdrug.data import Graph, Molecule, PackedGraph
67

78

89
class DrugFeatureSet(dict):

chemicalx/data/labeledtriples.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import pandas as pd
21
from typing import List, Tuple
2+
3+
import pandas as pd
34
from sklearn.model_selection import train_test_split
45

56

chemicalx/models/deepsynergy.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
class DeepSynergy(torch.nn.Module):
66
r"""The DeepSynergy model from the `"DeepSynergy: Predicting
7-
Anti-Cancer Drug Synergy with Deep Learning" <https://academic.oup.com/bioinformatics/article/34/9/1538/4747884>`_ paper.
7+
Anti-Cancer Drug Synergy with Deep Learning"
8+
<https://academic.oup.com/bioinformatics/article/34/9/1538/4747884>`_ paper.
89
910
Args:
1011
context_channels (int): The number of context features.

chemicalx/models/epgcnds.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
class EPGCNDS(torch.nn.Module):
99
r"""The EPGCN-DS model from the `"Structure-Based Drug-Drug Interaction Detection
10-
via Expressive Graph Convolutional Networks and Deep Sets " <https://ojs.aaai.org/index.php/AAAI/article/view/7236>`_ paper.
10+
via Expressive Graph Convolutional Networks and Deep Sets"
11+
<https://ojs.aaai.org/index.php/AAAI/article/view/7236>`_ paper.
1112
1213
Args:
1314
in_channels (int): The number of molecular features.

examples/deepsynergy_examples.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import torch
21
import pandas as pd
3-
from tqdm import tqdm
2+
import torch
43
from sklearn.metrics import roc_auc_score
4+
from tqdm import tqdm
5+
6+
from chemicalx.data import BatchGenerator, DatasetLoader
57
from chemicalx.models import DeepSynergy
6-
from chemicalx.data import DatasetLoader, BatchGenerator
78

89
loader = DatasetLoader("drugcombdb")
910

examples/epgcnds_examples.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import torch
21
import pandas as pd
3-
from tqdm import tqdm
2+
import torch
43
from sklearn.metrics import roc_auc_score
5-
from chemicalx.data import DatasetLoader, BatchGenerator
4+
from tqdm import tqdm
5+
6+
from chemicalx.data import BatchGenerator, DatasetLoader
67
from chemicalx.models import EPGCNDS
78

89
loader = DatasetLoader("drugcombdb")

tests/unit/test_batching.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
2-
from chemicalx.data import DatasetLoader, BatchGenerator
2+
3+
from chemicalx.data import BatchGenerator, DatasetLoader
34

45

56
class TestGeneratorDrugCombDB(unittest.TestCase):

tests/unit/test_dataset.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
23
from chemicalx.data import DatasetLoader
34

45

tests/unit/test_datastructures.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
2+
23
import numpy as np
34
import pandas as pd
5+
46
from chemicalx.data import ContextFeatureSet, DrugFeatureSet, LabeledTriples
57

68

@@ -16,8 +18,8 @@ def setUp(self):
1618

1719
def test_get(self):
1820
assert self.context_feature_set["context_2"].shape == (1, 3)
19-
assert ("context_2" in self.context_feature_set) == True
20-
assert self.context_feature_set.has_context("context_2") == True
21+
assert "context_2" in self.context_feature_set
22+
assert self.context_feature_set.has_context("context_2")
2123

2224
def test_delete(self):
2325
self.another_context_feature_set = self.context_feature_set
@@ -63,8 +65,8 @@ def setUp(self):
6365

6466
def test_get(self):
6567
assert self.drug_feature_set["drug_1"]["features"].shape == (1, 3)
66-
assert ("drug_2" in self.drug_feature_set) == True
67-
assert self.drug_feature_set.has_drug("drug_2") == True
68+
assert "drug_2" in self.drug_feature_set
69+
assert self.drug_feature_set.has_drug("drug_2")
6870

6971
def test_delete(self):
7072
self.another_drug_feature_set = self.drug_feature_set

tests/unit/test_models.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import unittest
2+
23
import torch
3-
from chemicalx.data import DatasetLoader, BatchGenerator
44

5+
from chemicalx.data import BatchGenerator, DatasetLoader
56
from chemicalx.models import (
67
CASTER,
78
DPDDI,

tox.ini

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@ deps =
1515
isort
1616
skip_install = true
1717
commands =
18-
black ./chemicalx/ ./tests/ setup.py
19-
isort ./chemicalx/ ./tests/ setup.py
18+
black chemicalx/ tests/ examples/ setup.py
19+
isort chemicalx/ tests/ examples/ setup.py
2020
description = Run linters.
2121

2222
[testenv:flake8]
2323
deps =
2424
flake8
2525
flake8-black
2626
flake8-isort
27+
skip_install = true
2728
commands =
28-
flake8 --ignore=F401,F403 --max-line-length 120 ./chemicalx/ ./tests/ setup.py
29+
flake8 --ignore=F401,F403,F405,E203 --max-line-length 120 chemicalx/ tests/ examples/ setup.py
2930

3031
[testenv:mypy]
3132
deps = mypy
3233
skip_install = true
3334
commands =
34-
mypy --install-types --non-interactive --ignore-missing-imports ./chemicalx/ ./tests/
35-
description = Run the mypy tool to check static typing on the project.
35+
mypy --install-types --non-interactive --ignore-missing-imports chemicalx/ tests/ examples/ setup.py
36+
description = Run the mypy tool to check static typing on the project.

0 commit comments

Comments
 (0)