Farnaz Heidar-Zadeh commited on
Commit
22e9d3d
·
1 Parent(s): b3e7016

Update HEADER

Browse files
HEADER CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
doc/conf.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of functions for transforming
3
- # a matrix to make it as similar as possible to a target matrix.
4
  #
5
- # Copyright (C) 2017-2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
doc/getting_started.rst CHANGED
@@ -1,3 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  Getting Started
2
  ===============
3
 
 
1
+ ..
2
+ : # -*- coding: utf-8 -*-
3
+ : # The Selector library provides a set of tools for selecting a
4
+ : # subset of the dataset and computing diversity.
5
+ : #
6
+ : # Copyright (C) 2023 The QC-Devs Community
7
+ : #
8
+ : # This file is part of Selector.
9
+ : #
10
+ : # Selector is free software; you can redistribute it and/or
11
+ : # modify it under the terms of the GNU General Public License
12
+ : # as published by the Free Software Foundation; either version 3
13
+ : # of the License, or (at your option) any later version.
14
+ : #
15
+ : # Selector is distributed in the hope that it will be useful,
16
+ : # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ : # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ : # GNU General Public License for more details.
19
+ : #
20
+ : # You should have received a copy of the GNU General Public License
21
+ : # along with this program; if not, see <http://www.gnu.org/licenses/>
22
+ : #
23
+ : # --
24
+ : --
25
+
26
  Getting Started
27
  ===============
28
 
doc/index.rst CHANGED
@@ -1,3 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .. DiverseSelector documentation master file, created by
2
  sphinx-quickstart on Thu Mar 15 13:55:56 2018.
3
  You can adapt this file completely to your liking, but it should at least
 
1
+ ..
2
+ : # -*- coding: utf-8 -*-
3
+ : # The Selector library provides a set of tools for selecting a
4
+ : # subset of the dataset and computing diversity.
5
+ : #
6
+ : # Copyright (C) 2023 The QC-Devs Community
7
+ : #
8
+ : # This file is part of Selector.
9
+ : #
10
+ : # Selector is free software; you can redistribute it and/or
11
+ : # modify it under the terms of the GNU General Public License
12
+ : # as published by the Free Software Foundation; either version 3
13
+ : # of the License, or (at your option) any later version.
14
+ : #
15
+ : # Selector is distributed in the hope that it will be useful,
16
+ : # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ : # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ : # GNU General Public License for more details.
19
+ : #
20
+ : # You should have received a copy of the GNU General Public License
21
+ : # along with this program; if not, see <http://www.gnu.org/licenses/>
22
+ : #
23
+ : # --
24
+ : --
25
+
26
  .. DiverseSelector documentation master file, created by
27
  sphinx-quickstart on Thu Mar 15 13:55:56 2018.
28
  You can adapt this file completely to your liking, but it should at least
selector/__init__.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/_version.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -348,9 +348,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
348
  pieces["distance"] = int(count_out) # total number of commits
349
 
350
  # commit date: see ISO-8601 comment in git_versions_from_keywords()
351
- date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[
352
- 0
353
- ].strip()
354
  pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
355
 
356
  return pieces
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
348
  pieces["distance"] = int(count_out) # total number of commits
349
 
350
  # commit date: see ISO-8601 comment in git_versions_from_keywords()
351
+ date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
 
 
352
  pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
353
 
354
  return pieces
selector/converter.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/distance.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/diversity.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/methods/__init__.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/methods/base.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/methods/dissimilarity.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/methods/partition.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,7 +20,6 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
  """Module for Partition-Based Selection Methods."""
24
 
25
  import collections
@@ -29,7 +29,7 @@ import bitarray
29
  import scipy.spatial
30
 
31
  from selector.methods.base import SelectionBase
32
- from selector.diversity import compute_diversity, hypersphere_overlap_of_subset
33
  from selector.methods.utils import optimize_radius
34
  import numpy as np
35
  from scipy import spatial
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Module for Partition-Based Selection Methods."""
24
 
25
  import collections
 
29
  import scipy.spatial
30
 
31
  from selector.methods.base import SelectionBase
32
+ from selector.diversity import compute_diversity
33
  from selector.methods.utils import optimize_radius
34
  import numpy as np
35
  from scipy import spatial
selector/methods/similarity.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,7 +20,6 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
  """Module for Similarity-Based Selection Methods.
24
 
25
  This module contains the classes and functions for the similarity-based selection methods. To select
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Module for Similarity-Based Selection Methods.
24
 
25
  This module contains the classes and functions for the similarity-based selection methods. To select
selector/methods/tests/__init__.py CHANGED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
+ #
7
+ # This file is part of Selector.
8
+ #
9
+ # Selector is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU General Public License
11
+ # as published by the Free Software Foundation; either version 3
12
+ # of the License, or (at your option) any later version.
13
+ #
14
+ # Selector is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program; if not, see <http://www.gnu.org/licenses/>
21
+ #
22
+ # --
selector/methods/tests/common.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
selector/methods/tests/test_dissimilarity.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,7 +20,6 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
  """Test Dissimilarity-Based Selection Methods."""
24
 
25
 
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Test Dissimilarity-Based Selection Methods."""
24
 
25
 
selector/methods/tests/test_partition.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,7 +20,6 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
  """Test Partition-Based Selection Methods."""
24
 
25
  import numpy as np
@@ -92,16 +92,16 @@ def test_directed_sphere_on_line_with_larger_radius():
92
  # (0,0) as the reference point
93
  x = np.array(
94
  [
95
- [0, 0],
96
- [0, 1],
97
- [0, 1.1],
98
- [0, 1.2],
99
- [0, 2],
100
- [0, 3],
101
- [0, 3.1],
102
- [0, 3.2],
103
- [0, 4],
104
- [0, 5],
105
  ]
106
  )
107
  selector = DirectedSphereExclusion(r0=2.0, tol=0)
@@ -230,6 +230,7 @@ def test_raises_grid_partitioning():
230
  ) # Test number selected should be int
231
  assert_raises(TypeError, selector.select_from_cluster, grid, 5, [5.0])
232
 
 
233
  def test_medoid():
234
  """Testing Medoid class."""
235
  coords, _, _ = generate_synthetic_data(
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Test Partition-Based Selection Methods."""
24
 
25
  import numpy as np
 
92
  # (0,0) as the reference point
93
  x = np.array(
94
  [
95
+ [0, 0],
96
+ [0, 1],
97
+ [0, 1.1],
98
+ [0, 1.2],
99
+ [0, 2],
100
+ [0, 3],
101
+ [0, 3.1],
102
+ [0, 3.2],
103
+ [0, 4],
104
+ [0, 5],
105
  ]
106
  )
107
  selector = DirectedSphereExclusion(r0=2.0, tol=0)
 
230
  ) # Test number selected should be int
231
  assert_raises(TypeError, selector.select_from_cluster, grid, 5, [5.0])
232
 
233
+
234
  def test_medoid():
235
  """Testing Medoid class."""
236
  coords, _, _ = generate_synthetic_data(
selector/methods/utils.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,8 +20,8 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
  """Module for Selection Utilities."""
 
24
  import warnings
25
 
26
  import numpy as np
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Module for Selection Utilities."""
24
+
25
  import warnings
26
 
27
  import numpy as np
selector/tests/__init__.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -21,4 +21,4 @@
21
  #
22
  # --
23
 
24
- """Testing Module for DiverseSelector."""
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
21
  #
22
  # --
23
 
24
+ """Test Module."""
selector/tests/common.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -20,7 +20,6 @@
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
-
24
  """Common functions for test module."""
25
 
26
  import numpy as np
@@ -50,11 +49,10 @@ def load_testing_mols(mol_type: str = "2d") -> list:
50
  The list of RDKit molecules.
51
  """
52
  if mol_type == "2d":
53
- mols = [Chem.MolFromSmiles(smiles) for smiles in
54
- ["OC(=O)[C@@H](N)Cc1[nH]cnc1",
55
- "OC(=O)C(=O)C",
56
- "CC(=O)OC1=CC=CC=C1C(=O)O"]
57
- ]
58
  elif mol_type == "3d":
59
  with path("DiverseSelector.test.data", "drug_mols.sdf") as sdf_file:
60
  suppl = Chem.SDMolSupplier(str(sdf_file), removeHs=False)
@@ -130,7 +128,7 @@ def cosine(a, b):
130
  coeff : int
131
  cosine coefficient for molecule A and B.
132
  """
133
- coeff = (sum(a * b)) / (((sum(a ** 2)) + (sum(b ** 2))) ** 0.5)
134
  return coeff
135
 
136
 
@@ -149,5 +147,5 @@ def dice(a, b):
149
  coeff : int
150
  dice coefficient for molecule A and B.
151
  """
152
- coeff = (2 * (sum(a * b))) / ((sum(a ** 2)) + (sum(b ** 2)))
153
  return coeff
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
 
23
  """Common functions for test module."""
24
 
25
  import numpy as np
 
49
  The list of RDKit molecules.
50
  """
51
  if mol_type == "2d":
52
+ mols = [
53
+ Chem.MolFromSmiles(smiles)
54
+ for smiles in ["OC(=O)[C@@H](N)Cc1[nH]cnc1", "OC(=O)C(=O)C", "CC(=O)OC1=CC=CC=C1C(=O)O"]
55
+ ]
 
56
  elif mol_type == "3d":
57
  with path("DiverseSelector.test.data", "drug_mols.sdf") as sdf_file:
58
  suppl = Chem.SDMolSupplier(str(sdf_file), removeHs=False)
 
128
  coeff : int
129
  cosine coefficient for molecule A and B.
130
  """
131
+ coeff = (sum(a * b)) / (((sum(a**2)) + (sum(b**2))) ** 0.5)
132
  return coeff
133
 
134
 
 
147
  coeff : int
148
  dice coefficient for molecule A and B.
149
  """
150
+ coeff = (2 * (sum(a * b))) / ((sum(a**2)) + (sum(b**2)))
151
  return coeff
selector/tests/test_converter.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -20,8 +20,7 @@
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
-
24
- """Testing for Converter.py."""
25
 
26
  import selector.converter as cv
27
  import numpy as np
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
+ """Test Converter Module."""
 
24
 
25
  import selector.converter as cv
26
  import numpy as np
selector/tests/test_distance.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -20,8 +20,7 @@
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
-
24
- """Test distance.py Module."""
25
 
26
 
27
  from selector.distance import (
@@ -31,7 +30,7 @@ from selector.distance import (
31
  )
32
 
33
  import numpy as np
34
- from numpy.testing import assert_almost_equal, assert_equal, assert_raises
35
 
36
 
37
  def test_pairwise_similarity_bit_raises():
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
+ """Test Distance-Based Selection Methods."""
 
24
 
25
 
26
  from selector.distance import (
 
30
  )
31
 
32
  import numpy as np
33
+ from numpy.testing import assert_equal, assert_raises
34
 
35
 
36
  def test_pairwise_similarity_bit_raises():
selector/tests/test_diversity.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
@@ -21,7 +21,7 @@
21
  #
22
  # --
23
 
24
- """Testing for the diversity algorithms in the diversity.py module."""
25
 
26
  import pytest
27
  import numpy as np
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
21
  #
22
  # --
23
 
24
+ """Test Diversity Module."""
25
 
26
  import pytest
27
  import numpy as np
selector/tests/test_similarity.py CHANGED
@@ -1,16 +1,17 @@
1
- # The DiverseSelector library provides a set of tools to select molecule
2
- # subset with maximum molecular diversity.
 
3
  #
4
- # Copyright (C) 2022 The QC-Devs Community
5
  #
6
- # This file is part of DiverseSelector.
7
  #
8
- # DiverseSelector is free software; you can redistribute it and/or
9
  # modify it under the terms of the GNU General Public License
10
  # as published by the Free Software Foundation; either version 3
11
  # of the License, or (at your option) any later version.
12
  #
13
- # DiverseSelector is distributed in the hope that it will be useful,
14
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
  # GNU General Public License for more details.
@@ -19,8 +20,7 @@
19
  # along with this program; if not, see <http://www.gnu.org/licenses/>
20
  #
21
  # --
22
-
23
- """Test similarity-Based Selection Methods."""
24
 
25
  import ast
26
  import csv
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
20
  # along with this program; if not, see <http://www.gnu.org/licenses/>
21
  #
22
  # --
23
+ """Test Similarity-Based Selection Methods."""
 
24
 
25
  import ast
26
  import csv
setup.py CHANGED
@@ -1,17 +1,17 @@
1
  # -*- coding: utf-8 -*-
2
- # The DiverseSelector library provides a set of tools to select molecule
3
- # subset with maximum molecular diversity.
4
  #
5
- # Copyright (C) 2022 The QC-Devs Community
6
  #
7
- # This file is part of DiverseSelector.
8
  #
9
- # DiverseSelector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
- # DiverseSelector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
 
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
  #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
  #
7
+ # This file is part of Selector.
8
  #
9
+ # Selector is free software; you can redistribute it and/or
10
  # modify it under the terms of the GNU General Public License
11
  # as published by the Free Software Foundation; either version 3
12
  # of the License, or (at your option) any later version.
13
  #
14
+ # Selector is distributed in the hope that it will be useful,
15
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
  # GNU General Public License for more details.
versioneer.py CHANGED
@@ -1,3 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
  # Version: 0.18
3
 
@@ -277,6 +299,7 @@ https://creativecommons.org/publicdomain/zero/1.0/ .
277
  """
278
 
279
  from __future__ import print_function
 
280
  try:
281
  import configparser
282
  except ImportError:
@@ -290,6 +313,7 @@ import sys
290
 
291
  # pylint: skip-file
292
 
 
293
  class VersioneerConfig:
294
  """Container for Versioneer configuration parameters."""
295
 
@@ -309,11 +333,13 @@ def get_root():
309
  setup_py = os.path.join(root, "setup.py")
310
  versioneer_py = os.path.join(root, "versioneer.py")
311
  if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
312
- err = ("Versioneer was unable to run the project root directory. "
313
- "Versioneer requires setup.py to be executed from "
314
- "its immediate directory (like 'python setup.py COMMAND'), "
315
- "or in a way that lets it use sys.argv[0] to find the root "
316
- "(like 'python path/to/setup.py COMMAND').")
 
 
317
  raise VersioneerBadRootError(err)
318
  try:
319
  # Certain runtime workflows (setup.py install/develop in a setuptools
@@ -326,8 +352,10 @@ def get_root():
326
  me_dir = os.path.normcase(os.path.splitext(me)[0])
327
  vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
328
  if me_dir != vsr_dir:
329
- print("Warning: build in %s is using versioneer.py from %s"
330
- % (os.path.dirname(me), versioneer_py))
 
 
331
  except NameError:
332
  pass
333
  return root
@@ -349,6 +377,7 @@ def get_config_from_root(root):
349
  if parser.has_option("versioneer", name):
350
  return parser.get("versioneer", name)
351
  return None
 
352
  cfg = VersioneerConfig()
353
  cfg.VCS = VCS
354
  cfg.style = get(parser, "style") or ""
@@ -373,17 +402,18 @@ HANDLERS = {}
373
 
374
  def register_vcs_handler(vcs, method): # decorator
375
  """Decorator to mark a method as the handler for a particular VCS."""
 
376
  def decorate(f):
377
  """Store f in HANDLERS[vcs][method]."""
378
  if vcs not in HANDLERS:
379
  HANDLERS[vcs] = {}
380
  HANDLERS[vcs][method] = f
381
  return f
 
382
  return decorate
383
 
384
 
385
- def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
386
- env=None):
387
  """Call the given command(s)."""
388
  assert isinstance(commands, list)
389
  p = None
@@ -391,10 +421,13 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
391
  try:
392
  dispcmd = str([c] + args)
393
  # remember shell=False, so use git.cmd on windows, not just git
394
- p = subprocess.Popen([c] + args, cwd=cwd, env=env,
395
- stdout=subprocess.PIPE,
396
- stderr=(subprocess.PIPE if hide_stderr
397
- else None))
 
 
 
398
  break
399
  except EnvironmentError:
400
  e = sys.exc_info()[1]
@@ -419,7 +452,9 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
419
  return stdout, p.returncode
420
 
421
 
422
- LONG_VERSION_PY['git'] = '''
 
 
423
  # This file helps to compute a version number in source trees obtained from
424
  # git-archive tarball (such as those provided by githubs download-from-tag
425
  # feature). Distribution tarballs (built by setup.py sdist) and build
@@ -994,7 +1029,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
994
  # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
995
  # just "foo-1.0". If we see a "tag: " prefix, prefer those.
996
  TAG = "tag: "
997
- tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
998
  if not tags:
999
  # Either we're using git < 1.8.3, or there really are no tags. We use
1000
  # a heuristic: assume all version tags have a digit. The old git %d
@@ -1003,7 +1038,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
1003
  # between branches and tags. By ignoring refnames without digits, we
1004
  # filter out many common branch names like "release" and
1005
  # "stabilization", as well as "HEAD" and "master".
1006
- tags = set([r for r in refs if re.search(r'\d', r)])
1007
  if verbose:
1008
  print("discarding '%s', no digits" % ",".join(refs - tags))
1009
  if verbose:
@@ -1011,19 +1046,26 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
1011
  for ref in sorted(tags):
1012
  # sorting will prefer e.g. "2.0" over "2.0rc1"
1013
  if ref.startswith(tag_prefix):
1014
- r = ref[len(tag_prefix):]
1015
  if verbose:
1016
  print("picking %s" % r)
1017
- return {"version": r,
1018
- "full-revisionid": keywords["full"].strip(),
1019
- "dirty": False, "error": None,
1020
- "date": date}
 
 
 
1021
  # no suitable tags, so version is "0+unknown", but full hex is still there
1022
  if verbose:
1023
  print("no suitable tags, using unknown + full revision id")
1024
- return {"version": "0+unknown",
1025
- "full-revisionid": keywords["full"].strip(),
1026
- "dirty": False, "error": "no suitable tags", "date": None}
 
 
 
 
1027
 
1028
 
1029
  @register_vcs_handler("git", "pieces_from_vcs")
@@ -1038,8 +1080,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
1038
  if sys.platform == "win32":
1039
  GITS = ["git.cmd", "git.exe"]
1040
 
1041
- out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
1042
- hide_stderr=True)
1043
  if rc != 0:
1044
  if verbose:
1045
  print("Directory %s not under git control" % root)
@@ -1047,10 +1088,11 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
1047
 
1048
  # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
1049
  # if there isn't one, this yields HEX[-dirty] (no NUM)
1050
- describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
1051
- "--always", "--long",
1052
- "--match", "%s*" % tag_prefix],
1053
- cwd=root)
 
1054
  # --long was added in git-1.5.5
1055
  if describe_out is None:
1056
  raise NotThisMethod("'git describe' failed")
@@ -1073,17 +1115,16 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
1073
  dirty = git_describe.endswith("-dirty")
1074
  pieces["dirty"] = dirty
1075
  if dirty:
1076
- git_describe = git_describe[:git_describe.rindex("-dirty")]
1077
 
1078
  # now we have TAG-NUM-gHEX or HEX
1079
 
1080
  if "-" in git_describe:
1081
  # TAG-NUM-gHEX
1082
- mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
1083
  if not mo:
1084
  # unparseable. Maybe git-describe is misbehaving?
1085
- pieces["error"] = ("unable to parse git-describe output: '%s'"
1086
- % describe_out)
1087
  return pieces
1088
 
1089
  # tag
@@ -1092,10 +1133,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
1092
  if verbose:
1093
  fmt = "tag '%s' doesn't start with prefix '%s'"
1094
  print(fmt % (full_tag, tag_prefix))
1095
- pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
1096
- % (full_tag, tag_prefix))
1097
  return pieces
1098
- pieces["closest-tag"] = full_tag[len(tag_prefix):]
1099
 
1100
  # distance: number of commits since tag
1101
  pieces["distance"] = int(mo.group(2))
@@ -1106,13 +1146,11 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
1106
  else:
1107
  # HEX: no tags
1108
  pieces["closest-tag"] = None
1109
- count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"],
1110
- cwd=root)
1111
  pieces["distance"] = int(count_out) # total number of commits
1112
 
1113
  # commit date: see ISO-8601 comment in git_versions_from_keywords()
1114
- date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
1115
- cwd=root)[0].strip()
1116
  pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
1117
 
1118
  return pieces
@@ -1168,16 +1206,22 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
1168
  for i in range(3):
1169
  dirname = os.path.basename(root)
1170
  if dirname.startswith(parentdir_prefix):
1171
- return {"version": dirname[len(parentdir_prefix):],
1172
- "full-revisionid": None,
1173
- "dirty": False, "error": None, "date": None}
 
 
 
 
1174
  else:
1175
  rootdirs.append(root)
1176
  root = os.path.dirname(root) # up a level
1177
 
1178
  if verbose:
1179
- print("Tried directories %s but none started with prefix %s" %
1180
- (str(rootdirs), parentdir_prefix))
 
 
1181
  raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
1182
 
1183
 
@@ -1206,11 +1250,9 @@ def versions_from_file(filename):
1206
  contents = f.read()
1207
  except EnvironmentError:
1208
  raise NotThisMethod("unable to read _version.py")
1209
- mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_JSON",
1210
- contents, re.M | re.S)
1211
  if not mo:
1212
- mo = re.search(r"version_json = '''\r\n(.*)''' # END VERSION_JSON",
1213
- contents, re.M | re.S)
1214
  if not mo:
1215
  raise NotThisMethod("no version_json in _version.py")
1216
  return json.loads(mo.group(1))
@@ -1219,8 +1261,7 @@ def versions_from_file(filename):
1219
  def write_to_version_file(filename, versions):
1220
  """Write the given version number to the given _version.py file."""
1221
  os.unlink(filename)
1222
- contents = json.dumps(versions, sort_keys=True,
1223
- indent=1, separators=(",", ": "))
1224
  with open(filename, "w") as f:
1225
  f.write(SHORT_VERSION_PY % contents)
1226
 
@@ -1252,8 +1293,7 @@ def render_pep440(pieces):
1252
  rendered += ".dirty"
1253
  else:
1254
  # exception #1
1255
- rendered = "0+untagged.%d.g%s" % (pieces["distance"],
1256
- pieces["short"])
1257
  if pieces["dirty"]:
1258
  rendered += ".dirty"
1259
  return rendered
@@ -1367,11 +1407,13 @@ def render_git_describe_long(pieces):
1367
  def render(pieces, style):
1368
  """Render the given version pieces into the requested style."""
1369
  if pieces["error"]:
1370
- return {"version": "unknown",
1371
- "full-revisionid": pieces.get("long"),
1372
- "dirty": None,
1373
- "error": pieces["error"],
1374
- "date": None}
 
 
1375
 
1376
  if not style or style == "default":
1377
  style = "pep440" # the default
@@ -1391,9 +1433,13 @@ def render(pieces, style):
1391
  else:
1392
  raise ValueError("unknown style '%s'" % style)
1393
 
1394
- return {"version": rendered, "full-revisionid": pieces["long"],
1395
- "dirty": pieces["dirty"], "error": None,
1396
- "date": pieces.get("date")}
 
 
 
 
1397
 
1398
 
1399
  class VersioneerBadRootError(Exception):
@@ -1416,8 +1462,7 @@ def get_versions(verbose=False):
1416
  handlers = HANDLERS.get(cfg.VCS)
1417
  assert handlers, "unrecognized VCS '%s'" % cfg.VCS
1418
  verbose = verbose or cfg.verbose
1419
- assert cfg.versionfile_source is not None, \
1420
- "please set versioneer.versionfile_source"
1421
  assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix"
1422
 
1423
  versionfile_abs = os.path.join(root, cfg.versionfile_source)
@@ -1471,9 +1516,13 @@ def get_versions(verbose=False):
1471
  if verbose:
1472
  print("unable to compute version")
1473
 
1474
- return {"version": "0+unknown", "full-revisionid": None,
1475
- "dirty": None, "error": "unable to compute version",
1476
- "date": None}
 
 
 
 
1477
 
1478
 
1479
  def get_version():
@@ -1522,6 +1571,7 @@ def get_cmdclass():
1522
  print(" date: %s" % vers.get("date"))
1523
  if vers["error"]:
1524
  print(" error: %s" % vers["error"])
 
1525
  cmds["version"] = cmd_version
1526
 
1527
  # we override "build_py" in both distutils and setuptools
@@ -1554,14 +1604,15 @@ def get_cmdclass():
1554
  # now locate _version.py in the new build/ directory and replace
1555
  # it with an updated value
1556
  if cfg.versionfile_build:
1557
- target_versionfile = os.path.join(self.build_lib,
1558
- cfg.versionfile_build)
1559
  print("UPDATING %s" % target_versionfile)
1560
  write_to_version_file(target_versionfile, versions)
 
1561
  cmds["build_py"] = cmd_build_py
1562
 
1563
  if "cx_Freeze" in sys.modules: # cx_freeze enabled?
1564
  from cx_Freeze.dist import build_exe as _build_exe
 
1565
  # nczeczulin reports that py2exe won't like the pep440-style string
1566
  # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.
1567
  # setup(console=[{
@@ -1582,17 +1633,21 @@ def get_cmdclass():
1582
  os.unlink(target_versionfile)
1583
  with open(cfg.versionfile_source, "w") as f:
1584
  LONG = LONG_VERSION_PY[cfg.VCS]
1585
- f.write(LONG %
1586
- {"DOLLAR": "$",
1587
- "STYLE": cfg.style,
1588
- "TAG_PREFIX": cfg.tag_prefix,
1589
- "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1590
- "VERSIONFILE_SOURCE": cfg.versionfile_source,
1591
- })
 
 
 
 
1592
  cmds["build_exe"] = cmd_build_exe
1593
  del cmds["build_py"]
1594
 
1595
- if 'py2exe' in sys.modules: # py2exe enabled?
1596
  try:
1597
  from py2exe.distutils_buildexe import py2exe as _py2exe # py3
1598
  except ImportError:
@@ -1611,13 +1666,17 @@ def get_cmdclass():
1611
  os.unlink(target_versionfile)
1612
  with open(cfg.versionfile_source, "w") as f:
1613
  LONG = LONG_VERSION_PY[cfg.VCS]
1614
- f.write(LONG %
1615
- {"DOLLAR": "$",
1616
- "STYLE": cfg.style,
1617
- "TAG_PREFIX": cfg.tag_prefix,
1618
- "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1619
- "VERSIONFILE_SOURCE": cfg.versionfile_source,
1620
- })
 
 
 
 
1621
  cmds["py2exe"] = cmd_py2exe
1622
 
1623
  # we override different "sdist" commands for both environments
@@ -1644,8 +1703,8 @@ def get_cmdclass():
1644
  # updated value
1645
  target_versionfile = os.path.join(base_dir, cfg.versionfile_source)
1646
  print("UPDATING %s" % target_versionfile)
1647
- write_to_version_file(target_versionfile,
1648
- self._versioneer_generated_versions)
1649
  cmds["sdist"] = cmd_sdist
1650
 
1651
  return cmds
@@ -1700,11 +1759,9 @@ def do_setup():
1700
  root = get_root()
1701
  try:
1702
  cfg = get_config_from_root(root)
1703
- except (EnvironmentError, configparser.NoSectionError,
1704
- configparser.NoOptionError) as e:
1705
  if isinstance(e, (EnvironmentError, configparser.NoSectionError)):
1706
- print("Adding sample versioneer config to setup.cfg",
1707
- file=sys.stderr)
1708
  with open(os.path.join(root, "setup.cfg"), "a") as f:
1709
  f.write(SAMPLE_CONFIG)
1710
  print(CONFIG_ERROR, file=sys.stderr)
@@ -1713,15 +1770,18 @@ def do_setup():
1713
  print(" creating %s" % cfg.versionfile_source)
1714
  with open(cfg.versionfile_source, "w") as f:
1715
  LONG = LONG_VERSION_PY[cfg.VCS]
1716
- f.write(LONG % {"DOLLAR": "$",
1717
- "STYLE": cfg.style,
1718
- "TAG_PREFIX": cfg.tag_prefix,
1719
- "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1720
- "VERSIONFILE_SOURCE": cfg.versionfile_source,
1721
- })
1722
-
1723
- ipy = os.path.join(os.path.dirname(cfg.versionfile_source),
1724
- "__init__.py")
 
 
 
1725
  if os.path.exists(ipy):
1726
  try:
1727
  with open(ipy, "r") as f:
@@ -1763,8 +1823,7 @@ def do_setup():
1763
  else:
1764
  print(" 'versioneer.py' already in MANIFEST.in")
1765
  if cfg.versionfile_source not in simple_includes:
1766
- print(" appending versionfile_source ('%s') to MANIFEST.in" %
1767
- cfg.versionfile_source)
1768
  with open(manifest_in, "a") as f:
1769
  f.write("include %s\n" % cfg.versionfile_source)
1770
  else:
 
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
+ #
5
+ # Copyright (C) 2023 The QC-Devs Community
6
+ #
7
+ # This file is part of Selector.
8
+ #
9
+ # Selector is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU General Public License
11
+ # as published by the Free Software Foundation; either version 3
12
+ # of the License, or (at your option) any later version.
13
+ #
14
+ # Selector is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program; if not, see <http://www.gnu.org/licenses/>
21
+ #
22
+ # --
23
 
24
  # Version: 0.18
25
 
 
299
  """
300
 
301
  from __future__ import print_function
302
+
303
  try:
304
  import configparser
305
  except ImportError:
 
313
 
314
  # pylint: skip-file
315
 
316
+
317
  class VersioneerConfig:
318
  """Container for Versioneer configuration parameters."""
319
 
 
333
  setup_py = os.path.join(root, "setup.py")
334
  versioneer_py = os.path.join(root, "versioneer.py")
335
  if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)):
336
+ err = (
337
+ "Versioneer was unable to run the project root directory. "
338
+ "Versioneer requires setup.py to be executed from "
339
+ "its immediate directory (like 'python setup.py COMMAND'), "
340
+ "or in a way that lets it use sys.argv[0] to find the root "
341
+ "(like 'python path/to/setup.py COMMAND')."
342
+ )
343
  raise VersioneerBadRootError(err)
344
  try:
345
  # Certain runtime workflows (setup.py install/develop in a setuptools
 
352
  me_dir = os.path.normcase(os.path.splitext(me)[0])
353
  vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
354
  if me_dir != vsr_dir:
355
+ print(
356
+ "Warning: build in %s is using versioneer.py from %s"
357
+ % (os.path.dirname(me), versioneer_py)
358
+ )
359
  except NameError:
360
  pass
361
  return root
 
377
  if parser.has_option("versioneer", name):
378
  return parser.get("versioneer", name)
379
  return None
380
+
381
  cfg = VersioneerConfig()
382
  cfg.VCS = VCS
383
  cfg.style = get(parser, "style") or ""
 
402
 
403
  def register_vcs_handler(vcs, method): # decorator
404
  """Decorator to mark a method as the handler for a particular VCS."""
405
+
406
  def decorate(f):
407
  """Store f in HANDLERS[vcs][method]."""
408
  if vcs not in HANDLERS:
409
  HANDLERS[vcs] = {}
410
  HANDLERS[vcs][method] = f
411
  return f
412
+
413
  return decorate
414
 
415
 
416
+ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None):
 
417
  """Call the given command(s)."""
418
  assert isinstance(commands, list)
419
  p = None
 
421
  try:
422
  dispcmd = str([c] + args)
423
  # remember shell=False, so use git.cmd on windows, not just git
424
+ p = subprocess.Popen(
425
+ [c] + args,
426
+ cwd=cwd,
427
+ env=env,
428
+ stdout=subprocess.PIPE,
429
+ stderr=(subprocess.PIPE if hide_stderr else None),
430
+ )
431
  break
432
  except EnvironmentError:
433
  e = sys.exc_info()[1]
 
452
  return stdout, p.returncode
453
 
454
 
455
+ LONG_VERSION_PY[
456
+ "git"
457
+ ] = '''
458
  # This file helps to compute a version number in source trees obtained from
459
  # git-archive tarball (such as those provided by githubs download-from-tag
460
  # feature). Distribution tarballs (built by setup.py sdist) and build
 
1029
  # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
1030
  # just "foo-1.0". If we see a "tag: " prefix, prefer those.
1031
  TAG = "tag: "
1032
+ tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)])
1033
  if not tags:
1034
  # Either we're using git < 1.8.3, or there really are no tags. We use
1035
  # a heuristic: assume all version tags have a digit. The old git %d
 
1038
  # between branches and tags. By ignoring refnames without digits, we
1039
  # filter out many common branch names like "release" and
1040
  # "stabilization", as well as "HEAD" and "master".
1041
+ tags = set([r for r in refs if re.search(r"\d", r)])
1042
  if verbose:
1043
  print("discarding '%s', no digits" % ",".join(refs - tags))
1044
  if verbose:
 
1046
  for ref in sorted(tags):
1047
  # sorting will prefer e.g. "2.0" over "2.0rc1"
1048
  if ref.startswith(tag_prefix):
1049
+ r = ref[len(tag_prefix) :]
1050
  if verbose:
1051
  print("picking %s" % r)
1052
+ return {
1053
+ "version": r,
1054
+ "full-revisionid": keywords["full"].strip(),
1055
+ "dirty": False,
1056
+ "error": None,
1057
+ "date": date,
1058
+ }
1059
  # no suitable tags, so version is "0+unknown", but full hex is still there
1060
  if verbose:
1061
  print("no suitable tags, using unknown + full revision id")
1062
+ return {
1063
+ "version": "0+unknown",
1064
+ "full-revisionid": keywords["full"].strip(),
1065
+ "dirty": False,
1066
+ "error": "no suitable tags",
1067
+ "date": None,
1068
+ }
1069
 
1070
 
1071
  @register_vcs_handler("git", "pieces_from_vcs")
 
1080
  if sys.platform == "win32":
1081
  GITS = ["git.cmd", "git.exe"]
1082
 
1083
+ out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True)
 
1084
  if rc != 0:
1085
  if verbose:
1086
  print("Directory %s not under git control" % root)
 
1088
 
1089
  # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
1090
  # if there isn't one, this yields HEX[-dirty] (no NUM)
1091
+ describe_out, rc = run_command(
1092
+ GITS,
1093
+ ["describe", "--tags", "--dirty", "--always", "--long", "--match", "%s*" % tag_prefix],
1094
+ cwd=root,
1095
+ )
1096
  # --long was added in git-1.5.5
1097
  if describe_out is None:
1098
  raise NotThisMethod("'git describe' failed")
 
1115
  dirty = git_describe.endswith("-dirty")
1116
  pieces["dirty"] = dirty
1117
  if dirty:
1118
+ git_describe = git_describe[: git_describe.rindex("-dirty")]
1119
 
1120
  # now we have TAG-NUM-gHEX or HEX
1121
 
1122
  if "-" in git_describe:
1123
  # TAG-NUM-gHEX
1124
+ mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe)
1125
  if not mo:
1126
  # unparseable. Maybe git-describe is misbehaving?
1127
+ pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out
 
1128
  return pieces
1129
 
1130
  # tag
 
1133
  if verbose:
1134
  fmt = "tag '%s' doesn't start with prefix '%s'"
1135
  print(fmt % (full_tag, tag_prefix))
1136
+ pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix)
 
1137
  return pieces
1138
+ pieces["closest-tag"] = full_tag[len(tag_prefix) :]
1139
 
1140
  # distance: number of commits since tag
1141
  pieces["distance"] = int(mo.group(2))
 
1146
  else:
1147
  # HEX: no tags
1148
  pieces["closest-tag"] = None
1149
+ count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
 
1150
  pieces["distance"] = int(count_out) # total number of commits
1151
 
1152
  # commit date: see ISO-8601 comment in git_versions_from_keywords()
1153
+ date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
 
1154
  pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
1155
 
1156
  return pieces
 
1206
  for i in range(3):
1207
  dirname = os.path.basename(root)
1208
  if dirname.startswith(parentdir_prefix):
1209
+ return {
1210
+ "version": dirname[len(parentdir_prefix) :],
1211
+ "full-revisionid": None,
1212
+ "dirty": False,
1213
+ "error": None,
1214
+ "date": None,
1215
+ }
1216
  else:
1217
  rootdirs.append(root)
1218
  root = os.path.dirname(root) # up a level
1219
 
1220
  if verbose:
1221
+ print(
1222
+ "Tried directories %s but none started with prefix %s"
1223
+ % (str(rootdirs), parentdir_prefix)
1224
+ )
1225
  raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
1226
 
1227
 
 
1250
  contents = f.read()
1251
  except EnvironmentError:
1252
  raise NotThisMethod("unable to read _version.py")
1253
+ mo = re.search(r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S)
 
1254
  if not mo:
1255
+ mo = re.search(r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S)
 
1256
  if not mo:
1257
  raise NotThisMethod("no version_json in _version.py")
1258
  return json.loads(mo.group(1))
 
1261
  def write_to_version_file(filename, versions):
1262
  """Write the given version number to the given _version.py file."""
1263
  os.unlink(filename)
1264
+ contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": "))
 
1265
  with open(filename, "w") as f:
1266
  f.write(SHORT_VERSION_PY % contents)
1267
 
 
1293
  rendered += ".dirty"
1294
  else:
1295
  # exception #1
1296
+ rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"])
 
1297
  if pieces["dirty"]:
1298
  rendered += ".dirty"
1299
  return rendered
 
1407
  def render(pieces, style):
1408
  """Render the given version pieces into the requested style."""
1409
  if pieces["error"]:
1410
+ return {
1411
+ "version": "unknown",
1412
+ "full-revisionid": pieces.get("long"),
1413
+ "dirty": None,
1414
+ "error": pieces["error"],
1415
+ "date": None,
1416
+ }
1417
 
1418
  if not style or style == "default":
1419
  style = "pep440" # the default
 
1433
  else:
1434
  raise ValueError("unknown style '%s'" % style)
1435
 
1436
+ return {
1437
+ "version": rendered,
1438
+ "full-revisionid": pieces["long"],
1439
+ "dirty": pieces["dirty"],
1440
+ "error": None,
1441
+ "date": pieces.get("date"),
1442
+ }
1443
 
1444
 
1445
  class VersioneerBadRootError(Exception):
 
1462
  handlers = HANDLERS.get(cfg.VCS)
1463
  assert handlers, "unrecognized VCS '%s'" % cfg.VCS
1464
  verbose = verbose or cfg.verbose
1465
+ assert cfg.versionfile_source is not None, "please set versioneer.versionfile_source"
 
1466
  assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix"
1467
 
1468
  versionfile_abs = os.path.join(root, cfg.versionfile_source)
 
1516
  if verbose:
1517
  print("unable to compute version")
1518
 
1519
+ return {
1520
+ "version": "0+unknown",
1521
+ "full-revisionid": None,
1522
+ "dirty": None,
1523
+ "error": "unable to compute version",
1524
+ "date": None,
1525
+ }
1526
 
1527
 
1528
  def get_version():
 
1571
  print(" date: %s" % vers.get("date"))
1572
  if vers["error"]:
1573
  print(" error: %s" % vers["error"])
1574
+
1575
  cmds["version"] = cmd_version
1576
 
1577
  # we override "build_py" in both distutils and setuptools
 
1604
  # now locate _version.py in the new build/ directory and replace
1605
  # it with an updated value
1606
  if cfg.versionfile_build:
1607
+ target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build)
 
1608
  print("UPDATING %s" % target_versionfile)
1609
  write_to_version_file(target_versionfile, versions)
1610
+
1611
  cmds["build_py"] = cmd_build_py
1612
 
1613
  if "cx_Freeze" in sys.modules: # cx_freeze enabled?
1614
  from cx_Freeze.dist import build_exe as _build_exe
1615
+
1616
  # nczeczulin reports that py2exe won't like the pep440-style string
1617
  # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.
1618
  # setup(console=[{
 
1633
  os.unlink(target_versionfile)
1634
  with open(cfg.versionfile_source, "w") as f:
1635
  LONG = LONG_VERSION_PY[cfg.VCS]
1636
+ f.write(
1637
+ LONG
1638
+ % {
1639
+ "DOLLAR": "$",
1640
+ "STYLE": cfg.style,
1641
+ "TAG_PREFIX": cfg.tag_prefix,
1642
+ "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1643
+ "VERSIONFILE_SOURCE": cfg.versionfile_source,
1644
+ }
1645
+ )
1646
+
1647
  cmds["build_exe"] = cmd_build_exe
1648
  del cmds["build_py"]
1649
 
1650
+ if "py2exe" in sys.modules: # py2exe enabled?
1651
  try:
1652
  from py2exe.distutils_buildexe import py2exe as _py2exe # py3
1653
  except ImportError:
 
1666
  os.unlink(target_versionfile)
1667
  with open(cfg.versionfile_source, "w") as f:
1668
  LONG = LONG_VERSION_PY[cfg.VCS]
1669
+ f.write(
1670
+ LONG
1671
+ % {
1672
+ "DOLLAR": "$",
1673
+ "STYLE": cfg.style,
1674
+ "TAG_PREFIX": cfg.tag_prefix,
1675
+ "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1676
+ "VERSIONFILE_SOURCE": cfg.versionfile_source,
1677
+ }
1678
+ )
1679
+
1680
  cmds["py2exe"] = cmd_py2exe
1681
 
1682
  # we override different "sdist" commands for both environments
 
1703
  # updated value
1704
  target_versionfile = os.path.join(base_dir, cfg.versionfile_source)
1705
  print("UPDATING %s" % target_versionfile)
1706
+ write_to_version_file(target_versionfile, self._versioneer_generated_versions)
1707
+
1708
  cmds["sdist"] = cmd_sdist
1709
 
1710
  return cmds
 
1759
  root = get_root()
1760
  try:
1761
  cfg = get_config_from_root(root)
1762
+ except (EnvironmentError, configparser.NoSectionError, configparser.NoOptionError) as e:
 
1763
  if isinstance(e, (EnvironmentError, configparser.NoSectionError)):
1764
+ print("Adding sample versioneer config to setup.cfg", file=sys.stderr)
 
1765
  with open(os.path.join(root, "setup.cfg"), "a") as f:
1766
  f.write(SAMPLE_CONFIG)
1767
  print(CONFIG_ERROR, file=sys.stderr)
 
1770
  print(" creating %s" % cfg.versionfile_source)
1771
  with open(cfg.versionfile_source, "w") as f:
1772
  LONG = LONG_VERSION_PY[cfg.VCS]
1773
+ f.write(
1774
+ LONG
1775
+ % {
1776
+ "DOLLAR": "$",
1777
+ "STYLE": cfg.style,
1778
+ "TAG_PREFIX": cfg.tag_prefix,
1779
+ "PARENTDIR_PREFIX": cfg.parentdir_prefix,
1780
+ "VERSIONFILE_SOURCE": cfg.versionfile_source,
1781
+ }
1782
+ )
1783
+
1784
+ ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py")
1785
  if os.path.exists(ipy):
1786
  try:
1787
  with open(ipy, "r") as f:
 
1823
  else:
1824
  print(" 'versioneer.py' already in MANIFEST.in")
1825
  if cfg.versionfile_source not in simple_includes:
1826
+ print(" appending versionfile_source ('%s') to MANIFEST.in" % cfg.versionfile_source)
 
1827
  with open(manifest_in, "a") as f:
1828
  f.write("include %s\n" % cfg.versionfile_source)
1829
  else: