Conversation
e488ab1 to
fc943ed
Compare
1. Remove unused model attributes 2. Make `similar` calculation more natural language readable
fc943ed to
68ff95e
Compare
rht
commented
Oct 13, 2024
| def __init__(self, model, agent_type): | ||
| def __init__(self, model: mesa.Model, agent_type: int) -> None: | ||
| """ | ||
| Create a new Schelling agent. |
Contributor
Author
There was a problem hiding this comment.
This docstring is self explanatory for anyone knowing what __init__ does, and should be considered a superfluous documentation.
Contributor
Author
There was a problem hiding this comment.
I have read several articles about superfluous documentation, but couldn't find a good reference that explains it. Maybe this SO thread does it.
EwoutH
approved these changes
Oct 13, 2024
|
|
||
| if self.happy == len(self.agents): | ||
| self.running = False | ||
| self.running = self.happy != len(self.agents) |
Member
There was a problem hiding this comment.
While this is fully correct, I find it less readable. Maybe this could also be resolved with a comment.
Member
There was a problem hiding this comment.
My experience is the other way around. I found this very clear.
Member
quaquel
approved these changes
Oct 14, 2024
rht
added a commit
to rht/mesa
that referenced
this pull request
Oct 14, 2024
quaquel
added a commit
to mesa/mesa
that referenced
this pull request
Oct 18, 2024
* refactor: Simplify Schelling code Ported from mesa/mesa-examples#222. * Update benchmarks/Schelling/schelling.py Co-authored-by: Ewout ter Hoeven <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Jan Kwakkel <[email protected]> Co-authored-by: Ewout ter Hoeven <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quaquel
added a commit
to quaquel/mesa
that referenced
this pull request
Oct 18, 2024
* refactor: Simplify Schelling code Ported from mesa/mesa-examples#222. * Update benchmarks/Schelling/schelling.py Co-authored-by: Ewout ter Hoeven <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Jan Kwakkel <[email protected]> Co-authored-by: Ewout ter Hoeven <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Harshini2411
pushed a commit
to Harshini2411/mesa-examples
that referenced
this pull request
Mar 16, 2026
* refactor: Simplify Schelling code 1. Remove unused model attributes 2. Make `similar` calculation more natural language readable * Remove unused argument doc * Add type hints to agent class * refactor: Simplify self.running expression
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.
similarcalculation more natural language readableWith these changes and
shuffle_do, the Schelling code in https://github.com/JuliaDynamics/ABMFrameworksComparison should go down from 44 to ~33, closer to Agents.jl's 28.