bblean 0.6.0b2__tar.gz → 0.6.1b0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {bblean-0.6.0b2 → bblean-0.6.1b0}/.github/workflows/upload-to-pypi.yaml +5 -3
  2. {bblean-0.6.0b2 → bblean-0.6.1b0}/PKG-INFO +2 -1
  3. {bblean-0.6.0b2 → bblean-0.6.1b0}/README.md +1 -0
  4. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_legacy/bb_int64.py +2 -0
  5. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_version.py +2 -2
  6. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/bitbirch.py +36 -0
  7. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/cli.py +16 -13
  8. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/multiround.py +2 -7
  9. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/plotting.py +7 -0
  10. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/sklearn.py +1 -2
  11. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/PKG-INFO +2 -1
  12. {bblean-0.6.0b2 → bblean-0.6.1b0}/.cruft.json +0 -0
  13. {bblean-0.6.0b2 → bblean-0.6.1b0}/.flake8 +0 -0
  14. {bblean-0.6.0b2 → bblean-0.6.1b0}/.github/CODEOWNERS +0 -0
  15. {bblean-0.6.0b2 → bblean-0.6.1b0}/.github/workflows/ci-cpp.yaml +0 -0
  16. {bblean-0.6.0b2 → bblean-0.6.1b0}/.github/workflows/ci.yaml +0 -0
  17. {bblean-0.6.0b2 → bblean-0.6.1b0}/.gitignore +0 -0
  18. {bblean-0.6.0b2 → bblean-0.6.1b0}/.pre-commit-config.yaml +0 -0
  19. {bblean-0.6.0b2 → bblean-0.6.1b0}/LICENSE +0 -0
  20. {bblean-0.6.0b2 → bblean-0.6.1b0}/LICENSES/BSD-3-Clause.txt +0 -0
  21. {bblean-0.6.0b2 → bblean-0.6.1b0}/LICENSES/GPL-3.0-only.txt +0 -0
  22. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/__init__.py +0 -0
  23. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_config.py +0 -0
  24. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_console.py +0 -0
  25. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_legacy/__init__.py +0 -0
  26. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_legacy/bb_uint8.py +0 -0
  27. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_memory.py +0 -0
  28. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_merges.py +0 -0
  29. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_py_similarity.py +0 -0
  30. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/_timer.py +0 -0
  31. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/analysis.py +0 -0
  32. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/csrc/README.md +0 -0
  33. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/csrc/similarity.cpp +0 -0
  34. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/fingerprints.py +0 -0
  35. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/metrics.py +0 -0
  36. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/similarity.py +0 -0
  37. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/smiles.py +0 -0
  38. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean/utils.py +0 -0
  39. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean-demo-v2.gif +0 -0
  40. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean-demo.cast +0 -0
  41. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/SOURCES.txt +0 -0
  42. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/dependency_links.txt +0 -0
  43. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/entry_points.txt +0 -0
  44. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/requires.txt +0 -0
  45. {bblean-0.6.0b2 → bblean-0.6.1b0}/bblean.egg-info/top_level.txt +0 -0
  46. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/api.svg +0 -0
  47. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/installing.svg +0 -0
  48. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/logo-dark-bw.svg +0 -0
  49. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/logo-light-bw.svg +0 -0
  50. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/publications.svg +0 -0
  51. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/style.css +0 -0
  52. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_static/user-guide.svg +0 -0
  53. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/_templates/module.rst +0 -0
  54. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/api-reference.rst +0 -0
  55. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/conf.py +0 -0
  56. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/index.rst +0 -0
  57. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/installing.rst +0 -0
  58. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/publications.rst +0 -0
  59. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/user-guide/linux_memory_setup.rst +0 -0
  60. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/user-guide/notebooks/bitbirch_best_practices.ipynb +0 -0
  61. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/user-guide/notebooks/bitbirch_quickstart.ipynb +0 -0
  62. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/user-guide/parameters.rst +0 -0
  63. {bblean-0.6.0b2 → bblean-0.6.1b0}/docs/src/user-guide.rst +0 -0
  64. {bblean-0.6.0b2 → bblean-0.6.1b0}/environment.yaml +0 -0
  65. {bblean-0.6.0b2 → bblean-0.6.1b0}/examples/biogen_logS.csv +0 -0
  66. {bblean-0.6.0b2 → bblean-0.6.1b0}/examples/bitbirch_best_practices.ipynb +0 -0
  67. {bblean-0.6.0b2 → bblean-0.6.1b0}/examples/bitbirch_quickstart.ipynb +0 -0
  68. {bblean-0.6.0b2 → bblean-0.6.1b0}/examples/chembl-33-natural-products-subset.smi +0 -0
  69. {bblean-0.6.0b2 → bblean-0.6.1b0}/examples/dataset_splitting.ipynb +0 -0
  70. {bblean-0.6.0b2 → bblean-0.6.1b0}/pyproject.toml +0 -0
  71. {bblean-0.6.0b2 → bblean-0.6.1b0}/setup.cfg +0 -0
  72. {bblean-0.6.0b2 → bblean-0.6.1b0}/setup.py +0 -0
  73. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/chembl-sample-3k.smi +0 -0
  74. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/chembl-sample-bad.smi +0 -0
  75. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/legacy_merges.py +0 -0
  76. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/legacy_metrics.py +0 -0
  77. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_bb_consistency.py +0 -0
  78. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_cli.py +0 -0
  79. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_fake_fps.py +0 -0
  80. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_fingerprints.py +0 -0
  81. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_global_clustering.py +0 -0
  82. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_import_bblean.py +0 -0
  83. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_merges.py +0 -0
  84. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_metrics.py +0 -0
  85. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_multiround.py +0 -0
  86. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_refine.py +0 -0
  87. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_regression.py +0 -0
  88. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_sampling.py +0 -0
  89. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_similarity.py +0 -0
  90. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_simple.py +0 -0
  91. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_sklearn.py +0 -0
  92. {bblean-0.6.0b2 → bblean-0.6.1b0}/tests/test_utils.py +0 -0
@@ -15,10 +15,12 @@ on:
15
15
  required: false
16
16
  default: false
17
17
  type: boolean
18
+ release:
19
+ types: [published]
18
20
 
19
21
  env:
20
22
  PYTHON_VERSION: '3.11'
21
- SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
23
+ SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.version }}
22
24
  # cibuildwheel configuration:
23
25
  # Skip py 3.14, 32 bit and musllinux (Alpine) wheels
24
26
  CIBW_SKIP: "cp314-* cp314t-* *-manylinux_i686 *-win32 *-musllinux_*"
@@ -93,7 +95,7 @@ jobs:
93
95
  publish_to_testpypi:
94
96
  needs: [build_wheels, make_sdist]
95
97
  runs-on: ubuntu-latest
96
- if: ${{ github.event.inputs.upload-testpypi == 'true' }}
98
+ if: ${{ github.event_name != 'release' && github.event.inputs.upload-testpypi }}
97
99
  environment:
98
100
  name: testpypi
99
101
  url: https://test.pypi.org/p/bblean
@@ -115,7 +117,7 @@ jobs:
115
117
  publish_to_pypi:
116
118
  needs: [build_wheels, make_sdist]
117
119
  runs-on: ubuntu-latest
118
- if: ${{ github.event.inputs.upload-pypi == 'true' }}
120
+ if: ${{ github.event_name == 'release' || github.event.inputs.upload-pypi }}
119
121
  environment:
120
122
  name: pypi
121
123
  url: https://pypi.org/p/bblean
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bblean
3
- Version: 0.6.0b2
3
+ Version: 0.6.1b0
4
4
  Summary: BitBirch-Lean Python package
5
5
  Author: The Miranda-Quintana Lab and other BitBirch developers
6
6
  Author-email: Ramon Alain Miranda Quintana <quintana@chem.ufl.edu>, Krisztina Zsigmond <kzsigmond@ufl.edu>, Ignacio Pickering <ipickering@ufl.edu>, Kenneth Lopez Perez <klopezperez@chem.ufl.edu>, Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>
@@ -90,6 +90,7 @@ macOS via pip, which automatically includes C++ extensions:
90
90
 
91
91
  ```bash
92
92
  pip install bblean
93
+ # Alternatively you can use 'uv pip install'
93
94
  bb --help
94
95
  ```
95
96
 
@@ -47,6 +47,7 @@ macOS via pip, which automatically includes C++ extensions:
47
47
 
48
48
  ```bash
49
49
  pip install bblean
50
+ # Alternatively you can use 'uv pip install'
50
51
  bb --help
51
52
  ```
52
53
 
@@ -633,6 +633,7 @@ class BitBirch:
633
633
  X = X[:max_fps]
634
634
  threshold = self.threshold
635
635
  branching_factor = self.branching_factor
636
+
636
637
  n_features = _validate_n_features(X, input_is_packed, n_features)
637
638
  d_type = X.dtype
638
639
 
@@ -718,6 +719,7 @@ class BitBirch:
718
719
  """
719
720
  threshold = self.threshold
720
721
  branching_factor = self.branching_factor
722
+
721
723
  n_features = _validate_n_features(X, input_is_packed, n_features)
722
724
  d_type = X.dtype
723
725
 
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.6.0b2'
32
- __version_tuple__ = version_tuple = (0, 6, 0, 'b2')
31
+ __version__ = version = '0.6.1b0'
32
+ __version_tuple__ = version_tuple = (0, 6, 1, 'b0')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -47,6 +47,8 @@
47
47
  # ./LICENSES/GPL-3.0-only.txt. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
48
48
  r"""BitBirch 'Lean' class for fast, memory-efficient O(N) clustering"""
49
49
  from __future__ import annotations # Stringize type annotations for no runtime overhead
50
+ import pickle
51
+ import sys
50
52
  import typing_extensions as tpx
51
53
  import os
52
54
  import random
@@ -1316,6 +1318,40 @@ class BitBirch:
1316
1318
  parts.append(f"tolerance={self.tolerance}")
1317
1319
  return f"{self.__class__.__name__}({', '.join(parts)})"
1318
1320
 
1321
+ def save(self, path: Path | str) -> None:
1322
+ r""":meta private:"""
1323
+ # TODO: BitBIRCH is highly recursive. pickling may crash python,
1324
+ # an alternative solution would be better
1325
+ msg = (
1326
+ "Saving large BitBIRCH trees may result in large memory peaks."
1327
+ " An alternative serialization method may be implemented in the future"
1328
+ )
1329
+ warnings.warn(msg)
1330
+ _old_limit = sys.getrecursionlimit()
1331
+ sys.setrecursionlimit(1_000_000_000)
1332
+ with open(path, mode="wb") as f:
1333
+ pickle.dump(self, f)
1334
+ sys.setrecursionlimit(_old_limit)
1335
+
1336
+ @classmethod
1337
+ def load(cls, path: Path | str) -> tpx.Self:
1338
+ r""":meta private:"""
1339
+ # TODO: BitBIRCH is highly recursive. pickling may crash python,
1340
+ # an alternative solution would be better
1341
+ msg = (
1342
+ "Loading large BitBIRCH trees may result in large memory peaks."
1343
+ " An alternative serialization method may be implemented in the future"
1344
+ )
1345
+ warnings.warn(msg)
1346
+ _old_limit = sys.getrecursionlimit()
1347
+ sys.setrecursionlimit(1_000_000_000)
1348
+ with open(path, mode="rb") as f:
1349
+ tree = pickle.load(f)
1350
+ sys.setrecursionlimit(_old_limit)
1351
+ if not isinstance(tree, cls):
1352
+ raise ValueError("Path does not contain a bitbirch object")
1353
+ return tree
1354
+
1319
1355
  def global_clustering(
1320
1356
  self,
1321
1357
  n_clusters: int,
@@ -1096,26 +1096,29 @@ def _run(
1096
1096
 
1097
1097
  timer.end_timing("total", console, indent=False)
1098
1098
  console.print_peak_mem(out_dir, indent=False)
1099
+ if save_tree:
1100
+ if variant != "lean":
1101
+ console.print("Can't save tree for non-lean variants", style="red")
1102
+ else:
1103
+ # TODO: Find alternative solution
1104
+ tree.save_pickle(out_dir / "bitbirch.pkl")
1099
1105
  if variant == "lean":
1100
- if save_tree:
1101
- # TODO: BitBIRCH is highly recursive. pickling may crash python,
1102
- # an alternative solution would be better
1103
- _old_limit = sys.getrecursionlimit()
1104
- sys.setrecursionlimit(100_000)
1105
- with open(out_dir / "bitbirch.pkl", mode="wb") as f:
1106
- pickle.dump(tree, f)
1107
- sys.setrecursionlimit(_old_limit)
1108
1106
  tree.delete_internal_nodes()
1109
- # Dump outputs (peak memory, timings, config, cluster ids)
1110
- if save_centroids:
1107
+ # Dump outputs (peak memory, timings, config, cluster ids)
1108
+ if save_centroids:
1109
+ if variant != "lean":
1110
+ console.print("Can't save centroids for non-lean variants", style="red")
1111
+ with open(out_dir / "clusters.pkl", mode="wb") as f:
1112
+ pickle.dump(tree.get_cluster_mol_ids(), f)
1113
+ else:
1111
1114
  output = tree.get_centroids_mol_ids()
1112
1115
  with open(out_dir / "clusters.pkl", mode="wb") as f:
1113
1116
  pickle.dump(output["mol_ids"], f)
1114
1117
  with open(out_dir / "cluster-centroids-packed.pkl", mode="wb") as f:
1115
1118
  pickle.dump(output["centroids"], f)
1116
- else:
1117
- with open(out_dir / "clusters.pkl", mode="wb") as f:
1118
- pickle.dump(tree.get_cluster_mol_ids(), f)
1119
+ else:
1120
+ with open(out_dir / "clusters.pkl", mode="wb") as f:
1121
+ pickle.dump(tree.get_cluster_mol_ids(), f)
1119
1122
 
1120
1123
  collect_system_specs_and_dump_config(ctx.params)
1121
1124
  timer.dump(out_dir / "timings.json")
@@ -298,13 +298,8 @@ class _FinalTreeMergingRound(_TreeMergingRound):
298
298
 
299
299
  # Save clusters and exit
300
300
  if self.save_tree:
301
- # TODO: BitBIRCH is highly recursive. pickling may crash python,
302
- # an alternative solution would be better
303
- _old_limit = sys.getrecursionlimit()
304
- sys.setrecursionlimit(100_000)
305
- with open(self.out_dir / "bitbirch.pkl", mode="wb") as f:
306
- pickle.dump(tree, f)
307
- sys.setrecursionlimit(_old_limit)
301
+ # TODO: Find alternative solution
302
+ tree.save_pickle(self.out_dir / "bitbirch.pkl")
308
303
  tree.delete_internal_nodes()
309
304
  if self.save_centroids:
310
305
  output = tree.get_centroids_mol_ids()
@@ -399,13 +399,17 @@ def dump_mol_images(
399
399
  clusters: list[list[int]],
400
400
  cluster_idx: int = 0,
401
401
  batch_size: int = 30,
402
+ limit: int = -1,
402
403
  ) -> None:
403
404
  r"""Dump smiles associated with a specific cluster as ``*.png`` image files"""
404
405
  if isinstance(smiles, str):
405
406
  smiles = [smiles]
406
407
  smiles = np.asarray(smiles)
407
408
  idxs = clusters[cluster_idx]
409
+ num = 0
408
410
  for i, idx_seq in enumerate(batched(idxs, batch_size)):
411
+ if num + len(idx_seq) > limit:
412
+ idx_seq = idx_seq[: num + len(idx_seq) - limit]
409
413
  mols = []
410
414
  for smi in smiles[list(idx_seq)]:
411
415
  mol = Chem.MolFromSmiles(smi)
@@ -415,6 +419,9 @@ def dump_mol_images(
415
419
  img = Draw.MolsToGridImage(mols, molsPerRow=5)
416
420
  with open(f"cluster_{cluster_idx}_{i}.png", "wb") as f:
417
421
  f.write(img.data)
422
+ num += len(idx_seq)
423
+ if num >= limit:
424
+ break
418
425
 
419
426
 
420
427
  # For internal use, dispatches a visualization workflow and optionally saves
@@ -131,8 +131,7 @@ class BitBirch(
131
131
  .astype(np.uint8, copy=False)
132
132
  .view(np.bool)
133
133
  )
134
- # TODO: Even when both inputs are bool, this function warns for some reason
135
- # I believe this may be a sklearn bug
134
+ # TODO: Due to a sklearn bug this performs unnecessary casts
136
135
  centers = self.subcluster_centers_.astype(np.uint8, copy=False).view(np.bool)
137
136
  argmin = pairwise_distances_argmin(X, centers, metric="jaccard")
138
137
  return self.subcluster_labels_[argmin]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bblean
3
- Version: 0.6.0b2
3
+ Version: 0.6.1b0
4
4
  Summary: BitBirch-Lean Python package
5
5
  Author: The Miranda-Quintana Lab and other BitBirch developers
6
6
  Author-email: Ramon Alain Miranda Quintana <quintana@chem.ufl.edu>, Krisztina Zsigmond <kzsigmond@ufl.edu>, Ignacio Pickering <ipickering@ufl.edu>, Kenneth Lopez Perez <klopezperez@chem.ufl.edu>, Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>
@@ -90,6 +90,7 @@ macOS via pip, which automatically includes C++ extensions:
90
90
 
91
91
  ```bash
92
92
  pip install bblean
93
+ # Alternatively you can use 'uv pip install'
93
94
  bb --help
94
95
  ```
95
96
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes