Skip to content

Fix stale time-tracking guidance in event scheduling tutorial - #3681

Merged
EwoutH merged 2 commits into
mesa:mainfrom
falloficaruss:fix-tutorial
Apr 9, 2026
Merged

EwoutH merged 2 commits into
mesa:mainfrom
falloficaruss:fix-tutorial

Conversation

@falloficaruss

@falloficaruss falloficaruss commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Note

Use this template for bug fixes only. For enhancements/new features, use the feature template and get maintainer approval in an issue/discussion before opening a PR.

Pre-PR Checklist

  • This PR is a bug fix, not a new feature or enhancement.

Summary

Fixes stale guidance in docs/tutorials/3_event_scheduling.ipynb after the removal of model.steps.

The tutorial was still describing model.steps as a built-in Mesa time-tracking attribute, which no longer matches current Mesa behavior. It also had a commented-out Colab install cell and a sample exchange method whose docstring said "random other agent" while the code could still select self.

Bug / Issue

Related issue: #3679

The event scheduling tutorial had a few documentation bugs:

  • It described model.steps and model.time as Mesa's two time-tracking attributes, even though model.steps has been removed.
  • The example only worked because it manually defined its own steps counter, which could mislead readers into thinking this was framework behavior.
  • The Colab install cell was commented out, so the "run the next cell" instruction did not actually install Mesa.
  • The Citizen.exchange() example said it gives money to a "random other agent", but the implementation could choose the current agent.

Expected behavior:

  • The tutorial should describe model.time accurately and present any step counter as user-defined example state.
  • The Colab setup cell should run as written.
  • The exchange example should match its own docstring.

Actual behavior:

  • The notebook mixed removed API guidance with working example code, which made the tutorial misleading.

Implementation

Updated docs/tutorials/3_event_scheduling.ipynb to align the tutorial with the current Mesa API and tutorial behavior:

  • Replaced the tutorial overview and summary text that treated model.steps as a built-in attribute.
  • Reworded the time section to focus on model.time.
  • Changed the sample model's counter from steps to step_count to make it explicit that this is user-defined example state.
  • Updated the explanatory text around the sample output to refer to the example counter rather than a Mesa-provided attribute.
  • Uncommented the Colab %pip install --quiet mesa[rec] cell.
  • Updated the Citizen.exchange() example to exclude self so it truly selects another agent.

Testing

  • Verified the notebook JSON is still valid with python3 -m json.tool docs/tutorials/3_event_scheduling.ipynb.
  • Reviewed the resulting notebook diff to confirm the updated tutorial text and code are consistent.

Additional Notes

This is a documentation bug fix only; no library runtime behavior was changed.
Closes #3679


GSoC contributor checklist

Context & motivation

I came across this while reviewing the event scheduling tutorial and comparing it with the current Mesa API. The notebook still referred to model.steps as if it were a built-in time-tracking attribute, which confused me because the codebase and recent changes are clearly centered around model.time. I wanted to fix it because tutorials are often the first thing new contributors and users rely on, so even small inconsistencies can create a lot of unnecessary confusion. What interested me here was that this looked like a small documentation issue at first, but it actually required understanding how the event system currently works and how the tutorial examples were communicating that behavior.

What I learned

While working on this, I learned more about how Mesa's event-based time progression is implemented and how run_for() / run_until() relate to the model's step() method. I also learned that documentation fixes can be a little trickier than they seem, because the goal is not just to make the text technically correct, but to make sure the examples, explanations, and code all stay aligned with each other. One thing that stood out to me was how easy it is for an example to keep "working" even when the explanation around it has become outdated, like with the manually defined step counter in the notebook.

Learning repo

🔗 My learning repo: https://github.com/falloficarus22/GSoC-learning-spac.git
🔗 Relevant model(s):

Readiness checks

  • This PR addresses an agreed-upon problem (linked issue or discussion with maintainer approval), or is a small/trivial fix
  • I have read the contributing guide and deprecation policy
  • I have performed a self-review: I reviewed my own PR as if I were a reviewer and left comments on anything that needs explanation
  • Another GSoC contributor has reviewed this PR: @
  • Tests pass locally (pytest --cov=mesa tests/)
  • Code is formatted (ruff check . --fix)
  • If applicable: documentation, examples, and/or migration guide are updated

@EwoutH EwoutH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, nice cleanup.

PS: For such small PRs one or two paragraphs of PR description is fine. We're over the GSoC peak it seems.

@EwoutH EwoutH added the docs Release notes label label Apr 9, 2026
@EwoutH
EwoutH merged commit f758d36 into mesa:main Apr 9, 2026
9 of 10 checks passed
@falloficaruss
falloficaruss deleted the fix-tutorial branch April 10, 2026 03:34
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.

docs/tutorials/3_event_scheduling.ipynb still refers to removed model.steps API

2 participants