Skip to content

Commit

Permalink
moved sampling to last step (otherwise, can sample outside of final m…
Browse files Browse the repository at this point in the history
…ask)
  • Loading branch information
adamamer20 committed Jul 2, 2024
1 parent 4a8ab48 commit ba7d17b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mesa_frames/concrete/agentset_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ def select(
) -> Self:
obj = self._get_obj(inplace)
bool_mask = obj._get_bool_mask(mask)
if filter_func:
bool_mask = bool_mask & obj._get_bool_mask(filter_func(obj))
if negate:
bool_mask = ~bool_mask
if n is not None:
bool_mask = pd.Series(
obj._agents.index.isin(obj._agents[bool_mask].sample(n).index),
index=obj._agents.index,
)
if filter_func:
bool_mask = bool_mask & obj._get_bool_mask(filter_func(obj))
if negate:
bool_mask = ~bool_mask
obj._mask = bool_mask
return obj

Expand Down

0 comments on commit ba7d17b

Please sign in to comment.