Skip to content

Commit

Permalink
Block logs for physchem descriptors (#49)
Browse files Browse the repository at this point in the history
* block logs for physchem descriptors
* version bump
  • Loading branch information
c-w-feldmann authored Jul 6, 2024
1 parent 0144baf commit 92703ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions molpipeline/mol2any/mol2rdkit_phys_chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import numpy.typing as npt
from loguru import logger
from rdkit import rdBase
from rdkit import Chem
from rdkit.Chem import Descriptors
from sklearn.preprocessing import StandardScaler
Expand Down Expand Up @@ -133,13 +134,15 @@ def pretransform_single(
Descriptor vector for given molecule. None if calculation failed.
"""
vec = np.full((len(self._descriptor_list),), np.nan)
log_block = rdBase.BlockLogs() # pylint: disable=unused-variable
for i, name in enumerate(self._descriptor_list):
descriptor_func = RDKIT_DESCRIPTOR_DICT[name]
try:
vec[i] = descriptor_func(value)
except Exception: # pylint: disable=broad-except
if self._log_exceptions:
logger.exception(f"Failed calculating descriptor: {name}")
del log_block
if not self._return_with_errors and np.any(np.isnan(vec)):
return InvalidInstance(self.uuid, "NaN in descriptor vector", self.name)
return vec
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
{name = "Jochen Sieg"}
]
description = "Integration of rdkit functionality into sklearn pipelines."
version = "0.8.4"
version = "0.8.5"
readme = "README.md"

[tool.setuptools.dynamic]
Expand Down

0 comments on commit 92703ac

Please sign in to comment.