Skip to content

Resolve FIXME in sugarscape_g1mt/agents.py#3062

Merged
quaquel merged 4 commits intomesa:mainfrom
Sonu0305:fixme
Jan 5, 2026
Merged

Resolve FIXME in sugarscape_g1mt/agents.py#3062
quaquel merged 4 commits intomesa:mainfrom
Sonu0305:fixme

Conversation

@Sonu0305
Copy link
Copy Markdown
Contributor

@Sonu0305 Sonu0305 commented Jan 3, 2026

Summary

This PR refactors a small portion of the move method in the Sugarscape example's agent to be more efficient.

Bug / Issue

The existing code used two separate steps to identify the best cells for an agent to move to, which was slightly inefficient. The expectation was to refactor this into a more concise, single operation.

Implementation

The code was refactored to use a single list comprehension with enumerate.

Testing

I have tested it locally, all the tests pass.
Summary of the particular tests which are related:

collected 19 items                                                              

tests/examples/test_examples.py ..........                                [ 52%]
tests/examples/test_examples_viz.py .........                             [100%]

============================== 19 passed in 43.76s ==============================

Additional Notes

This is a minor refactoring that improves code quality. No functional changes are intended or expected.

@quaquel quaquel added the example Changes the examples or adds to them. label Jan 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 3, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +2.1% [+1.0%, +3.3%] 🔵 -0.3% [-0.5%, -0.2%]
BoltzmannWealth large 🔵 +0.5% [+0.2%, +1.0%] 🔵 +3.0% [+0.3%, +5.7%]
Schelling small 🔵 +0.8% [-0.2%, +1.8%] 🔵 +2.0% [+1.4%, +2.5%]
Schelling large 🔵 +1.8% [+1.2%, +2.5%] 🔵 +2.1% [+0.5%, +3.9%]
WolfSheep small 🔵 +0.2% [-0.1%, +0.5%] 🔵 +0.1% [+0.0%, +0.3%]
WolfSheep large 🔵 -0.2% [-4.9%, +5.5%] 🔵 -1.4% [-3.5%, +0.8%]
BoidFlockers small 🔵 +2.7% [+2.1%, +3.2%] 🔵 +0.7% [+0.5%, +0.8%]
BoidFlockers large 🔵 +2.1% [+1.7%, +2.6%] 🔵 +0.2% [-0.0%, +0.5%]

@Sonu0305 Sonu0305 requested a review from quaquel January 5, 2026 13:22
@Sonu0305
Copy link
Copy Markdown
Contributor Author

Sonu0305 commented Jan 5, 2026

Should I rebase my pr or can be merged as it is?
thanks.

@quaquel quaquel merged commit 6ffee80 into mesa:main Jan 5, 2026
14 checks passed
@Sonu0305 Sonu0305 deleted the fixme branch January 5, 2026 14:04
@Sonu0305
Copy link
Copy Markdown
Contributor Author

Sonu0305 commented Jan 5, 2026

Big thanks @quaquel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

example Changes the examples or adds to them.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants