Repository navigation
Fix outdated APIs, errors and typos in the tutorials - #4216
Conversation
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
|
Thanks for updating the tutorial APIs and correcting the explanations, @quaquel. #4127 adds an approved optional locations section to @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
left a comment
There was a problem hiding this comment.
Thanks, LGTM with a minor tweak to the PR description.
| " 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", |
There was a problem hiding this comment.
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.
* 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
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:
Text that contradicted Mesa's behavior:
Consistency:
Plus spelling and grammar fixes throughout.