diff --git a/AIMSim/ops/descriptor.py b/AIMSim/ops/descriptor.py index d25f4886..4b382c53 100644 --- a/AIMSim/ops/descriptor.py +++ b/AIMSim/ops/descriptor.py @@ -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): @@ -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. diff --git a/AIMSim/ops/similarity_measures.py b/AIMSim/ops/similarity_measures.py index c469c401..6e319418 100644 --- a/AIMSim/ops/similarity_measures.py +++ b/AIMSim/ops/similarity_measures.py @@ -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":