Skip to content

Commit

Permalink
Improve candidate filtering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Nov 12, 2024
1 parent 2a6f993 commit 8bff13b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions baybe/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,15 @@ def toggle_discrete_candidates(
"""
exp_rep = self.searchspace.discrete.exp_rep
index_name = exp_rep.index.name

# Identify points to be dropped
points = pd.merge(
exp_rep.reset_index(names="_df_index"), filter, how="left", indicator=True
).set_index("_df_index")
selector = "left_only" if anti else "both"
points = points[points["_merge"] == selector]
to_drop = points["_merge"] == ("both" if anti else "left_only")

# Drop the points
points.drop(index=points[to_drop].index, inplace=True)
points.drop("_merge", axis=1, inplace=True)
points.index.name = index_name

Expand Down

0 comments on commit 8bff13b

Please sign in to comment.