Repository navigation
Add get_group to GroupBy - #3713
Conversation
|
Performance benchmarks:
|
quaquel
left a comment
There was a problem hiding this comment.
Thanks for this. Looks good to me.
|
was there a reasons this was a draft or can it be merged? |
|
Performance benchmarks:
|
this reflects the actually agreed upon code
|
Thanks for catching this. I updated the branch to follow the final I also normalized Validation run locally:
|
|
This is ready for review/merge from my side now. I updated the branch to the final |
codebreaker32
left a comment
There was a problem hiding this comment.
LGTM! Thanks @pragnyanramtha
|
@quaquel ready to merge ! |
Add get_group to GroupBy (mesa#3713)
(cherry picked from commit 62f83fb)
Important
This implements the
get_groupAPI discussed in #3680 after maintainer agreement in #3680 (comment) and follow-up confirmation in #3680 (comment).Pre-PR Checklist
Approval Link
#3680 (comment)
#3680 (comment)
Summary
Add
GroupBy.get_group(name, default=_MISSING)for explicit group lookup.Motive
GroupBycurrently requires users to reach into.groupsdirectly to retrieve a group. Issue #3680 settled on an explicitget_groupmethod instead of makingGroupBylook like a full mapping.Implementation
_MISSINGsentinel so callers can passdefault=Nonewithout it being treated as an omitted default.GroupBy.get_group()to return an existing group, return a supplied default for a missing group, or raiseKeyErrorwhen no default is supplied.defaultdict(list)groups created byresult_type="list".Usage Examples
Additional Notes
Closes #3680
Validation:
uv run --no-project --with scipy --with pytest --with numpy --with pandas --with tqdm python -m pytest tests/test_agentset.py -q-> 26 passedruff check --no-cache mesa/agentset.py tests/test_agentset.py-> passedruff format --check --no-cache mesa/agentset.py tests/test_agentset.py-> passedgit diff --check-> passed