Fanwang Meng commited on
Commit
ba3d577
·
1 Parent(s): fff07bd

Clean up following pre-commit

Browse files
.bandit.yml CHANGED
@@ -3,9 +3,9 @@ skips:
3
  - B101
4
  # Standard pseudo-random generators are not suitable for security/cryptographic purposes
5
  - B311
6
- # Ignore warnings about importing subprocess
7
- - B404
8
  # Ignore warnings about calling subprocess
9
- - B603
10
  # Ignore warnings about calling subprocess
11
- - B607
 
3
  - B101
4
  # Standard pseudo-random generators are not suitable for security/cryptographic purposes
5
  - B311
6
+ # Ignore warnings about importing subprocess
7
+ - B404
8
  # Ignore warnings about calling subprocess
9
+ - B603
10
  # Ignore warnings about calling subprocess
11
+ - B607
selector/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -24,4 +23,3 @@
24
  """Selector Package."""
25
 
26
  from selector.methods import *
27
-
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
23
  """Selector Package."""
24
 
25
  from selector.methods import *
 
selector/converter.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -22,10 +21,9 @@
22
  # --
23
  """Module for converting similarity measures to distance/dissimilarity measures."""
24
 
25
- import numpy as np
26
-
27
  from typing import Union
28
 
 
29
 
30
  __all__ = [
31
  "sim_to_dist",
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
21
  # --
22
  """Module for converting similarity measures to distance/dissimilarity measures."""
23
 
 
 
24
  from typing import Union
25
 
26
+ import numpy as np
27
 
28
  __all__ = [
29
  "sim_to_dist",
selector/diversity.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -26,8 +25,8 @@
26
  import warnings
27
 
28
  import numpy as np
29
- from selector.similarity import tanimoto
30
 
 
31
 
32
  __all__ = [
33
  "compute_diversity",
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
25
  import warnings
26
 
27
  import numpy as np
 
28
 
29
+ from selector.similarity import tanimoto
30
 
31
  __all__ = [
32
  "compute_diversity",
selector/methods/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
selector/methods/base.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -22,11 +21,11 @@
22
  # --
23
  """Base class for diversity based subset selection."""
24
 
25
- import numpy as np
26
  import warnings
27
-
28
  from abc import ABC, abstractmethod
29
 
 
 
30
  __all__ = ["SelectionBase"]
31
 
32
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
21
  # --
22
  """Base class for diversity based subset selection."""
23
 
 
24
  import warnings
 
25
  from abc import ABC, abstractmethod
26
 
27
+ import numpy as np
28
+
29
  __all__ = ["SelectionBase"]
30
 
31
 
selector/methods/distance.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -29,7 +28,6 @@ import scipy
29
  from selector.methods.base import SelectionBase
30
  from selector.methods.utils import optimize_radius
31
 
32
-
33
  __all__ = [
34
  "MaxMin",
35
  "MaxSum",
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
28
  from selector.methods.base import SelectionBase
29
  from selector.methods.utils import optimize_radius
30
 
 
31
  __all__ = [
32
  "MaxMin",
33
  "MaxSum",
selector/methods/partition.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -29,9 +28,8 @@ import bitarray
29
  import numpy as np
30
  import scipy
31
 
32
- from selector.methods.base import SelectionBase
33
  from selector.diversity import compute_diversity
34
-
35
 
36
  __all__ = [
37
  "GridPartition",
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
28
  import numpy as np
29
  import scipy
30
 
 
31
  from selector.diversity import compute_diversity
32
+ from selector.methods.base import SelectionBase
33
 
34
  __all__ = [
35
  "GridPartition",
selector/methods/similarity.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -36,13 +35,13 @@ The ideas behind the similarity-based selection methods are described in the fol
36
  """
37
 
38
  import math
39
- from math import log
40
  import random
 
41
  from typing import List, Optional, Union
42
 
43
- from selector.methods.base import SelectionBase
44
  import numpy as np
45
 
 
46
 
47
  __all__ = ["NSimilarity", "SimilarityIndex"]
48
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
35
  """
36
 
37
  import math
 
38
  import random
39
+ from math import log
40
  from typing import List, Optional, Union
41
 
 
42
  import numpy as np
43
 
44
+ from selector.methods.base import SelectionBase
45
 
46
  __all__ = ["NSimilarity", "SimilarityIndex"]
47
 
selector/methods/tests/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
selector/methods/tests/common.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -22,12 +21,11 @@
22
  # --
23
  """Common functions for test module."""
24
 
25
- import numpy as np
26
 
 
27
  from sklearn.datasets import make_blobs
28
  from sklearn.metrics import pairwise_distances
29
- from typing import Any, Tuple, Union
30
-
31
 
32
  __all__ = [
33
  "generate_synthetic_data",
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
21
  # --
22
  """Common functions for test module."""
23
 
24
+ from typing import Any, Tuple, Union
25
 
26
+ import numpy as np
27
  from sklearn.datasets import make_blobs
28
  from sklearn.metrics import pairwise_distances
 
 
29
 
30
  __all__ = [
31
  "generate_synthetic_data",
selector/methods/tests/test_distance.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -23,12 +22,13 @@
23
  """Test selector/methods/distance.py."""
24
 
25
 
26
- from selector.methods.distance import MaxMin, MaxSum, OptiSim, DISE
27
  import numpy as np
 
28
  from numpy.testing import assert_equal, assert_raises
29
  from sklearn.metrics import pairwise_distances
 
 
30
  from selector.methods.tests.common import generate_synthetic_data
31
- import pytest
32
 
33
 
34
  def test_maxmin():
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
22
  """Test selector/methods/distance.py."""
23
 
24
 
 
25
  import numpy as np
26
+ import pytest
27
  from numpy.testing import assert_equal, assert_raises
28
  from sklearn.metrics import pairwise_distances
29
+
30
+ from selector.methods.distance import DISE, MaxMin, MaxSum, OptiSim
31
  from selector.methods.tests.common import generate_synthetic_data
 
32
 
33
 
34
  def test_maxmin():
selector/methods/tests/test_partition.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -23,13 +22,10 @@
23
  """Test Partition-Based Selection Methods."""
24
 
25
  import numpy as np
26
- from numpy.testing import assert_equal, assert_raises
27
  import pytest
 
28
 
29
- from selector.methods.partition import (
30
- GridPartition,
31
- Medoid,
32
- )
33
  from selector.methods.tests.common import generate_synthetic_data
34
 
35
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
22
  """Test Partition-Based Selection Methods."""
23
 
24
  import numpy as np
 
25
  import pytest
26
+ from numpy.testing import assert_equal, assert_raises
27
 
28
+ from selector.methods.partition import GridPartition, Medoid
 
 
 
29
  from selector.methods.tests.common import generate_synthetic_data
30
 
31
 
selector/methods/utils.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -26,7 +25,6 @@ import warnings
26
 
27
  import numpy as np
28
 
29
-
30
  __all__ = [
31
  "optimize_radius",
32
  ]
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
25
 
26
  import numpy as np
27
 
 
28
  __all__ = [
29
  "optimize_radius",
30
  ]
selector/similarity.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -22,10 +21,9 @@
22
  # --
23
  """Similarity Module."""
24
 
25
- import numpy as np
26
-
27
  from itertools import combinations_with_replacement
28
 
 
29
 
30
  __all__ = ["pairwise_similarity_bit", "tanimoto", "modified_tanimoto"]
31
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
21
  # --
22
  """Similarity Module."""
23
 
 
 
24
  from itertools import combinations_with_replacement
25
 
26
+ import numpy as np
27
 
28
  __all__ = ["pairwise_similarity_bit", "tanimoto", "modified_tanimoto"]
29
 
selector/tests/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
selector/tests/common.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
selector/tests/test_converter.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -22,10 +21,10 @@
22
  # --
23
  """Test Converter Module."""
24
 
25
- import selector.converter as cv
26
  import numpy as np
27
  from numpy.testing import assert_almost_equal, assert_equal, assert_raises
28
 
 
29
 
30
  # Tests for variations on input `x` for sim_to_dist()
31
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
21
  # --
22
  """Test Converter Module."""
23
 
 
24
  import numpy as np
25
  from numpy.testing import assert_almost_equal, assert_equal, assert_raises
26
 
27
+ import selector.converter as cv
28
 
29
  # Tests for variations on input `x` for sim_to_dist()
30
 
selector/tests/test_diversity.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -23,21 +22,21 @@
23
 
24
  """Test Diversity Module."""
25
 
26
- import pytest
27
  import numpy as np
 
28
  from numpy.testing import assert_almost_equal, assert_equal, assert_raises, assert_warns
 
29
  from selector.diversity import (
30
  compute_diversity,
31
- gini_coefficient,
32
  explicit_diversity_index,
 
 
33
  logdet,
 
34
  shannon_entropy,
35
- hypersphere_overlap_of_subset,
36
  wdud,
37
- nearest_average_tanimoto,
38
  )
39
 
40
-
41
  # each row is a feature and each column is a molecule
42
  sample1 = np.array([[4, 2, 6], [4, 9, 6], [2, 5, 0], [2, 0, 9], [5, 3, 0]])
43
 
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
22
 
23
  """Test Diversity Module."""
24
 
 
25
  import numpy as np
26
+ import pytest
27
  from numpy.testing import assert_almost_equal, assert_equal, assert_raises, assert_warns
28
+
29
  from selector.diversity import (
30
  compute_diversity,
 
31
  explicit_diversity_index,
32
+ gini_coefficient,
33
+ hypersphere_overlap_of_subset,
34
  logdet,
35
+ nearest_average_tanimoto,
36
  shannon_entropy,
 
37
  wdud,
 
38
  )
39
 
 
40
  # each row is a feature and each column is a molecule
41
  sample1 = np.array([[4, 2, 6], [4, 9, 6], [2, 5, 0], [2, 0, 9], [5, 3, 0]])
42
 
selector/tests/test_similarity.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
  # The Selector library provides a set of tools for selecting a
3
  # subset of the dataset and computing diversity.
4
  #
@@ -26,11 +25,12 @@ import ast
26
  import csv
27
 
28
  import numpy as np
29
- from numpy.testing import assert_almost_equal, assert_equal, assert_raises
30
  import pkg_resources
31
  import pytest
32
- from selector.similarity import pairwise_similarity_bit, tanimoto, modified_tanimoto
 
33
  from selector.methods.similarity import NSimilarity, SimilarityIndex
 
34
 
35
 
36
  def test_pairwise_similarity_bit_raises():
@@ -1284,7 +1284,7 @@ def _get_selections_ref_dict():
1284
  """
1285
 
1286
  file_path = get_data_file_path("ref_similarity_data.csv")
1287
- with open(file_path, mode="r", encoding="utf-8") as file:
1288
  reader = csv.reader(file, delimiter=";")
1289
  next(reader) # skip header
1290
  # initialize the dictionary
 
 
1
  # The Selector library provides a set of tools for selecting a
2
  # subset of the dataset and computing diversity.
3
  #
 
25
  import csv
26
 
27
  import numpy as np
 
28
  import pkg_resources
29
  import pytest
30
+ from numpy.testing import assert_almost_equal, assert_equal, assert_raises
31
+
32
  from selector.methods.similarity import NSimilarity, SimilarityIndex
33
+ from selector.similarity import modified_tanimoto, pairwise_similarity_bit, tanimoto
34
 
35
 
36
  def test_pairwise_similarity_bit_raises():
 
1284
  """
1285
 
1286
  file_path = get_data_file_path("ref_similarity_data.csv")
1287
+ with open(file_path, encoding="utf-8") as file:
1288
  reader = csv.reader(file, delimiter=";")
1289
  next(reader) # skip header
1290
  # initialize the dictionary