coleygroup / molpal

active learning for accelerated high-throughput virtual screening
MIT License
159 stars 36 forks source link

fix `curr_max` bug with too few scores #36

Closed degraff-roivant closed 2 years ago

degraff-roivant commented 2 years ago

Description

in Acquirer.acquire_batch there is a bug when explored is not None but does not contain at least k scores. This PR addresses that.

Current bug

the current_max is currently determined using np.partition to find the kth best score without sorting the full array of input scores. However, this will raise a ValueError when the length of that array is less than k.

Fix

A simple ternary statement: curr_max = np.partition(Y, -k)[-k] if len(Y) >= k else Y.max() covers all cases

Notes

This PR also formats a few extraneous files

Relevant issues

N/A

Checklist