Skip to content

Commit

Permalink
Merge pull request #188 from VlachosGroup/speedup-dev
Browse files Browse the repository at this point in the history
Reducing Execution Time
  • Loading branch information
JacksonBurns authored Feb 4, 2022
2 parents 682198e + dd49f1e commit 3ecf94f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions AIMSim/ops/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def to_numpy(self):
if not hasattr(self, "numpy_"):
self.numpy_ = np.zeros((0,), dtype=np.int8)
DataStructs.ConvertToNumpyArray(self.rdkit_, self.numpy_)
self.numpy_ = self.numpy_.flatten()
self.numpy_ = self.numpy_.ravel()
return self.numpy_

def to_rdkit(self):
Expand All @@ -81,9 +81,7 @@ def to_rdkit(self):
return self.rdkit_

def check_init(self):
if hasattr(self, "numpy_") or hasattr(self, "rdkit_"):
return True
return False
return getattr(self, "numpy_", None) is not None or getattr(self, "rdkit_", None) is not None

def _set_morgan_fingerprint(self, molecule_graph, radius, n_bits, **kwargs):
"""Set the descriptor to a morgan fingerprint.
Expand Down
3 changes: 1 addition & 2 deletions AIMSim/ops/similarity_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ def __call__(self, mol1_descriptor, mol2_descriptor):
Returns:
similarity_ (float): Similarity value
"""
if sum(mol1_descriptor.to_numpy()) == 0 \
or sum(mol1_descriptor.to_numpy()) == 0:
if not np.any(mol1_descriptor.to_numpy()) or not np.any(mol2_descriptor.to_numpy()):
raise ValueError('Molecule descriptor has no active bits')
similarity_ = None
if self.metric == "l0_similarity":
Expand Down

0 comments on commit 3ecf94f

Please sign in to comment.