fix(embeddings): handle registry records with empty openpom/shape embeddings
Browse files- src/pino/embeddings.py +11 -5
src/pino/embeddings.py
CHANGED
|
@@ -144,8 +144,12 @@ class OlfactoryEmbeddingEngine:
|
|
| 144 |
try:
|
| 145 |
record = self.registry.get(normalized_cas)
|
| 146 |
if record:
|
| 147 |
-
structural = np.asarray(record.get("openpom_embedding"
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
physical = self._extract_physical_features(record)
|
| 150 |
functional = self._extract_functional_features(record)
|
| 151 |
combined = np.concatenate([structural, shape, physical, functional]).astype(np.float32)
|
|
@@ -170,8 +174,10 @@ class OlfactoryEmbeddingEngine:
|
|
| 170 |
if normalized_cas:
|
| 171 |
try:
|
| 172 |
record = self.registry.get(normalized_cas)
|
| 173 |
-
if record
|
| 174 |
-
|
|
|
|
|
|
|
| 175 |
except Exception as exc:
|
| 176 |
logger.debug("Registry lookup failed for %s: %s", normalized_cas, exc)
|
| 177 |
|
|
@@ -227,7 +233,7 @@ class OlfactoryEmbeddingEngine:
|
|
| 227 |
record = self.registry.get(normalized_cas)
|
| 228 |
if record:
|
| 229 |
shape_3d = record.get("shape_3d_features")
|
| 230 |
-
if shape_3d and any(v != 0.0 for v in shape_3d):
|
| 231 |
return np.asarray(shape_3d, dtype=np.float32)
|
| 232 |
except Exception as exc:
|
| 233 |
logger.debug("Registry lookup failed for %s: %s", normalized_cas, exc)
|
|
|
|
| 144 |
try:
|
| 145 |
record = self.registry.get(normalized_cas)
|
| 146 |
if record:
|
| 147 |
+
structural = np.asarray(record.get("openpom_embedding") or [0.0] * STRUCTURAL_DIM, dtype=np.float32)
|
| 148 |
+
if structural.shape[0] != STRUCTURAL_DIM:
|
| 149 |
+
structural = self._compute_structural_embedding(smiles, cas)
|
| 150 |
+
shape = np.asarray(record.get("shape_3d_features") or [0.0] * SHAPE_DIM, dtype=np.float32)
|
| 151 |
+
if shape.shape[0] != SHAPE_DIM:
|
| 152 |
+
shape = self._compute_shape_features(smiles, cas)
|
| 153 |
physical = self._extract_physical_features(record)
|
| 154 |
functional = self._extract_functional_features(record)
|
| 155 |
combined = np.concatenate([structural, shape, physical, functional]).astype(np.float32)
|
|
|
|
| 174 |
if normalized_cas:
|
| 175 |
try:
|
| 176 |
record = self.registry.get(normalized_cas)
|
| 177 |
+
if record:
|
| 178 |
+
openpom_embedding = record.get("openpom_embedding")
|
| 179 |
+
if openpom_embedding and len(openpom_embedding) > 0:
|
| 180 |
+
return np.asarray(openpom_embedding, dtype=np.float32)
|
| 181 |
except Exception as exc:
|
| 182 |
logger.debug("Registry lookup failed for %s: %s", normalized_cas, exc)
|
| 183 |
|
|
|
|
| 233 |
record = self.registry.get(normalized_cas)
|
| 234 |
if record:
|
| 235 |
shape_3d = record.get("shape_3d_features")
|
| 236 |
+
if shape_3d and len(shape_3d) > 0 and any(v != 0.0 for v in shape_3d):
|
| 237 |
return np.asarray(shape_3d, dtype=np.float32)
|
| 238 |
except Exception as exc:
|
| 239 |
logger.debug("Registry lookup failed for %s: %s", normalized_cas, exc)
|