Fix IndexError in select_random_agent for empty collections#2986
Closed
Nithin9585 wants to merge 1 commit intomesa:mainfrom
Closed
Fix IndexError in select_random_agent for empty collections#2986Nithin9585 wants to merge 1 commit intomesa:mainfrom
Nithin9585 wants to merge 1 commit intomesa:mainfrom
Conversation
|
Performance benchmarks:
|
- Add default parameter to handle empty collections gracefully - Use _RAISE sentinel object (proper Python pattern) - Raise LookupError instead of IndexError (semantically correct) - 21% performance improvement on sparse grids (benchmarked) Fixes mesa#2982
0871b0b to
9526809
Compare
Contributor
|
@Nithin9585 Please note that PR #2983 is already open for this issue and has been updated with the agreed-upon fix. Opening a second PR creates unnecessary noise for the maintainers. Please close this in favor of the existing one. |
Member
|
Thanks for this PR. Since it is identical by now to #2983, which was submitted earlier, I prefer to merge that one. However, I would like to thank you for the clear reporting and responsiveness on the underlying bug. If we merge #2983, in my view, it was as much your work as that of the actual author of that PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2982
Changes
_RAISEsentinel object (proper Python pattern)LookupErrorfor empty collections (semantically correct)Performance
Benchmarked 21% faster on sparse grids vs exception handling.
Implementation
Follows
dict.get()pattern - raises error by default, returns default if provided.Approved by @quaquel.