Repository navigation
fix(examples): fix inverted grid dimensions in Conway Streamlit app - #4037
Merged
quaquel merged 1 commit intoNov 12, 2026
Merged
Conversation
|
Performance benchmarks:
|
Contributor
Author
|
Note:The codecov/patch failure is because |
quaquel
reviewed
Nov 10, 2026
| step = 0 | ||
| # init grid | ||
| df_grid = pd.DataFrame() | ||
| agent_counts = np.zeros((model.grid.width, model.grid.height)) |
Contributor
Author
There was a problem hiding this comment.
agent_counts is never used anywhere in the script. The app only uses df_grid to update and display the simulation, so I removed it along with the unused numpy import.
Contributor
There was a problem hiding this comment.
Confirmed locally: the old call swaps width/height, so 75 of 300 cells never update on the default sliders. The fix is correct, and agent_counts also has no use in the script
quaquel
approved these changes
Nov 12, 2026
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.
Pre-PR Checklist
Summary
Fixes an argument inversion bug in Conway's Game of Life Streamlit app (
mesa/examples/basic/conways_game_of_life/st_app.py) whereheightandwidthwere swapped during model instantiation, causing cells outside square bounds to be silently dropped and never rendered on the heatmap.Bug / Issue
In
st_app.py:14:Because the signature of
ConwaysGameOfLife.__init__is(width=50, height=50), passing(height, width)inverted the dimensions:width=15, height=20.df_gridwas constructed withrange(width)(0..19) andrange(height)(0..14).df_grid.loc[...]for cell coordinates withy >= 15matched no rows indf_grid, which Pandas silently ignored.Additionally:
model = st.title(...)before model creation.agent_countsarray and unusednumpyimport.Implementation
ConwaysGameOfLife(width=width, height=height).model = st.title(...)withst.title(...).agent_countsvariable and unusednumpyimport.Testing
tests/examples/test_examples.py -k "conway"(passed).ruff checkandruff format.before:

even through width=10,height=20 , only bottom 10 layer are changing
After:

all layers are changing properly