Skip to content

Commit

Permalink
feat: handling mismatch in property masks.
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Manica <[email protected]>
  • Loading branch information
drugilsberg committed Nov 26, 2024
1 parent c4b152c commit 5bcea3d
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import numpy as np
import torch
import warnings
from rdkit import Chem
from terminator.collators import MaskedTextCollator, PropertyCollator
from terminator.inference import InferenceRT
Expand Down Expand Up @@ -151,9 +152,19 @@ def load_inference(self, resources_path: str) -> None:
# Optional normalize parameter (for property) defaults to True
self.do_normalize = data.get("normalize", [True] * len(self.properties))

self.property_mask_lengths = [
data["property_mask_length"][p] for p in self.properties
]
self.property_mask_lengths = []
for p in self.properties:
mask_length = data["property_mask_length"][p]
if "property_ranges" in data:
max_value = data["property_ranges"][p][1]
max_value_as_string = f"{max_value:.3f}"
if len(max_value_as_string) > mask_length:
warnings.warn(
f"property={p} length should be {len(max_value_as_string)} (instead of {mask_length}). Updating it...",
RuntimeWarning,
)
mask_length = len(max_value_as_string)
self.property_mask_lengths.append(mask_length)
self._mins = [
data.get("property_ranges", {}).get(p, [0, 1])[0]
for p in self.properties
Expand Down

0 comments on commit 5bcea3d

Please sign in to comment.