Skip to content

Commit

Permalink
refactor(node_evaluators): Move the empty list handling to the base c…
Browse files Browse the repository at this point in the history
…lass
  • Loading branch information
kmaziarz committed Sep 8, 2023
1 parent 107fb0c commit d85c728
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions syntheseus/search/node_evaluation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def num_calls(self) -> int:
def __call__(
self, nodes: Sequence[NodeType], graph: Optional[RetrosynthesisSearchGraph] = None
) -> Sequence[float]:
if not nodes: # handle the case when there are no nodes to score
return []

self._num_calls += len(nodes)
return self._evaluate_nodes(nodes, graph)

Expand Down Expand Up @@ -138,9 +141,6 @@ def _get_probability(self, node, graph) -> float:
return metadata["probability"] # type: ignore

def _evaluate_nodes(self, nodes, graph=None) -> Sequence[float]:
if not nodes: # handle the case when there are no nodes to score
return []

probs = np.asarray([self._get_probability(n, graph) for n in nodes])
probs = np.clip(probs, a_min=self._clip_probability_min, a_max=self._clip_probability_max)

Expand Down

0 comments on commit d85c728

Please sign in to comment.