Skip to content

Remove unused assignments in test_copying_discrete_spaces - #3744

Merged
quaquel merged 1 commit into
mesa:mainfrom
Devansh-567:fix-3737-remove-dead-code
Jun 15, 2026
Merged

quaquel merged 1 commit into
mesa:mainfrom
Devansh-567:fix-3737-remove-dead-code

Conversation

@Devansh-567

Copy link
Copy Markdown
Contributor

Description

Fixes #3737

The variables c1 and c2 in test_copying_discrete_spaces were assigned before the loop but immediately shadowed by the loop variables:

c1 = grid[(5, 5)].connections
c2 = grid_copy[(5, 5)].connections

for c1, c2 in zip(grid.all_cells, grid_copy.all_cells):

As noted in the issue discussion, these assignments were never used because the loop iterates over all cells, including (5, 5).

This PR removes the unused assignments from the OrthogonalMooreGrid and HexGrid test blocks, eliminating dead code without changing test behavior.

Kindly have a look at this, and if anything has to be changed do let me know, after the merging I will close #3737

@github-actions

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔴 +6.0% [+5.4%, +6.6%] 🔵 +0.1% [-0.1%, +0.3%]
BoltzmannWealth large 🔵 +3.6% [+2.6%, +4.7%] 🔴 +16.1% [+14.5%, +17.5%]
Schelling small 🔵 +2.7% [+2.0%, +3.4%] 🔵 +0.0% [-0.7%, +0.7%]
Schelling large 🔵 +0.8% [-0.3%, +1.8%] 🔵 +3.9% [+2.3%, +5.6%]
WolfSheep small 🔵 -0.7% [-1.2%, -0.2%] 🔵 -1.4% [-4.9%, +2.2%]
WolfSheep large 🔵 -2.9% [-4.3%, -1.4%] 🔵 -3.7% [-5.8%, -1.2%]
SugarscapeG1mt small 🔵 -3.0% [-3.8%, -2.2%] 🔵 +0.1% [-1.1%, +1.3%]
SugarscapeG1mt large 🔵 -1.1% [-3.4%, +0.8%] 🔵 -0.8% [-3.7%, +1.8%]
BoidFlockers small 🔵 -3.3% [-3.8%, -2.9%] 🔵 -0.7% [-1.0%, -0.4%]
BoidFlockers large 🔵 -1.0% [-1.7%, -0.5%] 🔵 -0.3% [-0.6%, -0.1%]

@codebreaker32 codebreaker32 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @Devansh-567

@codebreaker32 codebreaker32 added the ignore-for-release PRs that aren't included in the release notes label Jun 12, 2026
@Devansh-567

Copy link
Copy Markdown
Contributor Author

The failing check (build / build (ubuntu, 3.14, --pre)) is unrelated to this PR. It's caused by nest_asyncio not being available in the solara/ipyvuetify dependency chain on Python 3.14 pre-release. This is an environment/dependency issue that exists on main independently of this change.

@quaquel
quaquel merged commit 8269845 into mesa:main Jun 15, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release PRs that aren't included in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable shadowing in test_copying_discrete_spaces makes pre-loop assertions dead code

4 participants