Skip to content

Fix outdated APIs, errors and typos in the tutorials - #4216

Merged
quaquel merged 2 commits into
mesa:mainfrom
quaquel:docs/tutorial-fixes
Nov 30, 2026
Merged

quaquel merged 2 commits into
mesa:mainfrom
quaquel:docs/tutorial-fixes

Conversation

@quaquel

@quaquel quaquel commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Over the last few days, there were various PRs that fixed a single typo or sentence in one of the tutorials. Instead, here I collect a whole bunch of changes which cleans up the docs in one go. I used Claude to identify the issues.

Code:

  • Tutorial 0: the "say_wealth" exercise now says to update MoneyModel.step, which otherwise fails with AttributeError.
  • Tutorial 12: Exercise 3 starter code used the removed mesa.space API (grid.get_neighbors, agent.pos); use self.cell.neighborhood.agents.
  • Tutorial 12: replace the removed mesa.batch_run with Scenario and run_scenarios() from mesa.experimental.scenarios.
  • Tutorials 0, 1, 2, 4: call random.choice on agentset.to_list() instead of relying on implicit AgentSet indexing.
  • Tutorial 9: create the property layer with the model's rng, so runs are reproducible.
  • Tutorials 6-10: remove the outdated Mesa 3.3 version check.

Text that contradicted Mesa's behavior:

  • Tutorial 3: same-priority events run in scheduling order, so a custom HIGH event can run before the step; interval defaults to 1.0.
  • Tutorial 5: without collect() nothing is collected; correct the method name get_agent_vars_dataframe().
  • Tutorial 6, 8: post_process is set as a renderer property (passing it to render() is deprecated).
  • Tutorial 7: match the described colors to the code, and fix the direction of the marker-name conversion (Matplotlib to Altair).
  • Tutorial 9: the property layer portrayal receives the layer's name.
  • Tutorials 0, 1, 2, 4: model.agents is an AgentSet, shuffle_do is an AgentSet method, continuous space is n-dimensional, class names.

Consistency:

  • Fix outdated cross-references between tutorials (model origin, number of visualization tutorials, where custom components and the extra controls are covered) and copied tutorial descriptions in 7 and 10.
  • Unify the banner at the top of every tutorial; drop tutorial 9's install cell; quote "mesa[rec]" for zsh.
  • Remove the uncited reference lists from tutorials 4-10; cite Dragulescu2002 by its key in tutorial 0.
  • Link to Discord instead of Matrix in tutorial 11.

Plus spelling and grammar fixes throughout.

Code:
- Tutorial 0: the "say_wealth" exercise now says to update MoneyModel.step,
  which otherwise fails with AttributeError.
- Tutorial 12: Exercise 3 starter code used the removed mesa.space API
  (grid.get_neighbors, agent.pos); use self.cell.neighborhood.agents.
- Tutorial 12: replace the removed mesa.batch_run with Scenario and
  run_scenarios() from mesa.experimental.scenarios.
- Tutorials 0, 1, 2, 4: call random.choice on agentset.to_list() instead
  of relying on deprecated AgentSet indexing.
- Tutorial 9: create the property layer with the model's rng, so runs are
  reproducible.
- Tutorials 6-10: remove the outdated Mesa 3.3 version check.

Text that contradicted Mesa's behavior:
- Tutorial 3: same-priority events run in scheduling order, so a custom
  HIGH event can run before the step; interval defaults to 1.0.
- Tutorial 5: without collect() nothing is collected; correct the method
  name get_agent_vars_dataframe().
- Tutorial 6, 8: post_process is set as a renderer property (passing it to
  render() is deprecated).
- Tutorial 7: match the described colors to the code, and fix the
  direction of the marker-name conversion (Matplotlib to Altair).
- Tutorial 9: the property layer portrayal receives the layer's name.
- Tutorials 0, 1, 2, 4: model.agents is an AgentSet, shuffle_do is an
  AgentSet method, continuous space is n-dimensional, class names.

Consistency:
- Fix outdated cross-references between tutorials (model origin, number of
  visualization tutorials, where custom components and the extra controls
  are covered) and copied tutorial descriptions in 7 and 10.
- Unify the banner at the top of every tutorial; drop tutorial 9's
  install cell; quote "mesa[rec]" for zsh.
- Remove the uncited reference lists from tutorials 4-10; cite
  Dragulescu2002 by its key in tutorial 0.
- Link to Discord instead of Matrix in tutorial 11.

Plus spelling and grammar fixes throughout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbrUQUQAArrpH7rYQFt6KW
@quaquel
quaquel requested a review from tpike3 November 29, 2026 19:07
@mesa-triage-bot

Copy link
Copy Markdown

Thanks for updating the tutorial APIs and correcting the explanations, @quaquel. #4127 adds an approved optional locations section to 4_adding_space.ipynb, which this PR also edits.

@tpike3, please review this tutorial cleanup alongside #4127. I'd merge the cleanup first, then check the combined space notebook so the corrections and optional section are both preserved.

Automated note by an AI model; it can be wrong, and maintainers make the decisions. About this bot.

@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.

Thanks, LGTM with a minor tweak to the PR description.

Comment on lines 405 to 411
" def exchange(self):\n",
" # Verify agent has some wealth\n",
" if self.wealth > 0:\n",
" other_agent = self.random.choice(self.model.agents)\n",
" other_agent = self.random.choice(self.model.agents.to_list())\n",
" if other_agent is not None:\n",
" other_agent.wealth += 1\n",
" self.wealth -= 1\n",

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.

Tutorials 0, 1, 2, 4: call random.choice on agentset.to_list() instead of relying on deprecated AgentSet indexing.

model.agents indexing doesn't warn, only an AgentSet from select() does. So without to_list() these calls still work today: model.agents and agents_by_type[...] index silently through to_list()[item], and only select() gives a PendingDeprecationWarning.

However I agree to_list() is still the right call, since it's explicit, costs the same and won't break if AgentSet indexing is removed.

@quaquel
quaquel merged commit 4783b0d into mesa:main Nov 30, 2026
19 checks passed
@quaquel
quaquel deleted the docs/tutorial-fixes branch November 30, 2026 07:28
EwoutH added a commit to EwoutH/mesa that referenced this pull request Nov 30, 2026
Seven PRs were merged after the notes were drafted: mesa#4284, mesa#3960,
mesa#4261, mesa#3979, mesa#4286, mesa#4216 and mesa#4301. Also moves the release date to
2026-11-30.

Assisted-by: Claude Code
EwoutH added a commit that referenced this pull request Nov 30, 2026
* Update release notes and version for 4.0.0a1

Add the 4.0.0a1 release notes to HISTORY.md, leaving out changes
already released in Mesa 3.5.1 to 3.5.4, and bump the version to
4.0.0a1. Move the #4182 replication id fix, which was added under
4.0.0a0, into the 4.0.0a1 notes where it was released.

Assisted-by: Claude Opus 5.5

* Leave dependabot and pre-commit.ci bumps out of the 4.0.0a1 notes

Assisted-by: Claude Opus 5.5

* Add PRs merged on 2026-11-30 to the 4.0.0a1 notes

Seven PRs were merged after the notes were drafted: #4284, #3960,
#4261, #3979, #4286, #4216 and #4301. Also moves the release date to
2026-11-30.

Assisted-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants