Skip to content

Commit

Permalink
except error
Browse files Browse the repository at this point in the history
  • Loading branch information
JenniferHem committed May 16, 2024
1 parent 0cb53ea commit 80c3624
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions molpipeline/mol2any/mol2rdkit_phys_chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ def pretransform_single(
Optional[npt.NDArray[np.float_]]
Descriptor vector for given molecule. None if calculation failed.
"""
vec = np.array(
[RDKIT_DESCRIPTOR_DICT[name](value) for name in self._descriptor_list]
)
try:
vec = np.array(
[RDKIT_DESCRIPTOR_DICT[name](value) for name in self._descriptor_list]
)
except ZeroDivisionError as e:
return InvalidInstance(self.uuid, f"Descriptor calculation failed, {e}", self.name)

if np.any(np.isnan(vec)):
return InvalidInstance(self.uuid, "NaN in descriptor vector", self.name)
return vec
Expand Down

0 comments on commit 80c3624

Please sign in to comment.