-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speedup of Agentset.shuffle #2010
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
bc1718c
Make RandomActivationByType.agents_by_type backward compatible
quaquel a7ddad5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1f9af49
updated warning
quaquel 59885b6
Merge remote-tracking branch 'upstream/main'
quaquel b9fe806
Merge remote-tracking branch 'upstream/main'
quaquel 2076b6d
Update .gitignore
quaquel 600c372
Merge remote-tracking branch 'upstream/main'
quaquel c83179d
Update global_benchmark.py
quaquel 4c8cb8b
pep8 rename
quaquel 7bccdd1
Update schelling.py
quaquel 64d8c46
Update schelling.py
quaquel 1e794d3
Update schelling.py
quaquel 4bc5fac
Update schelling.py
quaquel 9485087
Squashed commit of the following:
quaquel 5cd0e74
Revert "Squashed commit of the following:"
quaquel 63eec5e
Update .gitignore
quaquel 2a4459c
further updates
quaquel 1b5661e
Update benchmarks/WolfSheep/__init__.py
quaquel 2be6424
Merge remote-tracking branch 'upstream/main'
quaquel c2e9313
Merge remote-tracking branch 'upstream/main'
quaquel 7b8b7ea
Merge remote-tracking branch 'upstream/main'
quaquel dcf1e50
shuffle update
quaquel c40a324
Merge remote-tracking branch 'upstream/main'
quaquel fefe684
Merge branch 'main' into agentset_speed
quaquel d196386
switch to walrus operator in do
quaquel 4ef66de
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f910106
revert inplace to False
quaquel f7072ab
Merge branch 'agentset_speed' of https://github.com/quaquel/mesa into…
quaquel 9710914
remove old code
quaquel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come in this line there is no need for
(agent := ref()) is not None)
, but it is needed in L204?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you create a new AgentSet, it has its own internal WeakkeyDict. Each WeakkeyDict creates its own weakrefs.
As can be seen in the docs,
weakref.ref
takes an optional callback. In the case of WeakkeyDict, this callback is a method on the dict itself (i.e.,self.remove
). So, when not shuffling in place, I have to unpack the weakrefs to ensure the new WeakkeyDict behaves correctly.Moreover, AgentSet takes an iteratable of agents as an argument. Not an iterable of weakref. ref instances.
Hope this clarifies.