Skip to content

Fix inaccurate references and examples in core docstrings - #3818

Merged
quaquel merged 1 commit into
mesa:mainfrom
AshNicolus:fix-core-docstrings
Aug 26, 2026
Merged

quaquel merged 1 commit into
mesa:mainfrom
AshNicolus:fix-core-docstrings

Conversation

@AshNicolus

Copy link
Copy Markdown
Contributor

Four docstring inaccuracies in core modules, all verified against the code:

  • mesa/experimental/mesa_signals/signal_types.py: the ObservableSignals.CHANGED
    and ListSignals.INSERTED examples accessed s.new and m.kwargs, which do not
    exist on the Message dataclass (its payload lives in additional_kwargs).
    Running the examples raised AttributeError. Fixed to s.additional_kwargs["new"]
    and m.additional_kwargs["new"], which run and print the documented output.

  • mesa/agent.py: Agent.init_subclass was documented as "Called when
    DatasetTrackedAgent is subclassed." DatasetTrackedAgent does not exist anywhere
    in the codebase. Updated to describe what the method actually does (gives each
    Agent subclass its own dataset set).

  • mesa/discrete_space/grid.py: the cells_with_capacity docstring referred to the
    property as available_cells, which is not a real attribute. Corrected to
    cells_with_capacity.

  • mesa/discrete_space/cell.py: Cell.get_neighborhood is annotated as and returns
    a CellCollection, but the docstring described the return as "a list". Corrected
    to CellCollection.

Docstrings only, no behavior change. Verified locally: full suite passes (739
tests), ruff check and format clean, and both corrected signal examples now run
and produce the documented output.

@AshNicolus
AshNicolus marked this pull request as ready for review August 25, 2026 14:14
@github-actions

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -3.0% [-3.4%, -2.5%] 🔵 -2.8% [-3.1%, -2.6%]
BoltzmannWealth large 🔵 -1.3% [-1.9%, -0.7%] 🔵 -2.5% [-2.8%, -2.2%]
Schelling small 🔵 -1.5% [-2.0%, -1.0%] 🔵 -0.1% [-0.9%, +0.8%]
Schelling large 🔵 +0.3% [-0.1%, +0.6%] 🔵 +0.9% [+0.1%, +1.8%]
WolfSheep small 🔵 +0.7% [+0.3%, +1.0%] 🔵 -0.2% [-3.6%, +3.7%]
WolfSheep large 🔵 -0.9% [-1.4%, -0.4%] 🔵 -1.1% [-3.5%, +0.8%]
SugarscapeG1mt small 🔵 -2.5% [-2.9%, -2.0%] 🔵 +1.3% [-0.7%, +3.4%]
SugarscapeG1mt large 🔵 -0.6% [-2.0%, +1.1%] 🔵 +0.4% [-1.2%, +2.0%]
BoidFlockers small 🔵 +0.5% [+0.0%, +0.9%] 🔵 +0.9% [+0.5%, +1.3%]
BoidFlockers large 🔵 -0.3% [-1.0%, +0.3%] 🔵 +1.6% [+1.3%, +1.9%]

@github-actions

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🟢 -4.4% [-5.7%, -3.0%] 🔵 +0.8% [+0.7%, +1.0%]
BoltzmannWealth large 🔵 -1.5% [-2.4%, -0.6%] 🔵 -2.1% [-5.1%, +1.2%]
Schelling small 🔵 +2.4% [+1.7%, +3.1%] 🔵 +0.4% [-0.4%, +1.1%]
Schelling large 🔵 +0.2% [-0.5%, +0.7%] 🔵 +4.7% [+2.5%, +6.5%]
WolfSheep small 🔵 -3.1% [-3.8%, -2.3%] 🔵 +4.5% [+0.2%, +9.4%]
WolfSheep large 🔵 +0.1% [-1.9%, +1.9%] 🔵 +1.6% [-0.2%, +3.5%]
SugarscapeG1mt small 🔵 -3.0% [-4.0%, -1.9%] 🔵 +2.1% [+0.5%, +3.8%]
SugarscapeG1mt large 🔵 +2.9% [-0.2%, +5.7%] 🔵 +4.7% [+2.5%, +7.0%]
BoidFlockers small 🔵 +3.3% [+1.5%, +4.9%] 🔵 +3.0% [+2.5%, +3.4%]
BoidFlockers large 🔵 +3.7% [+2.2%, +5.1%] 🔵 +1.8% [+1.5%, +2.1%]

@quaquel quaquel added the docs Release notes label label Aug 26, 2026
@quaquel
quaquel merged commit 3b7bfdc into mesa:main Aug 26, 2026
14 checks passed
@falloficaruss

Copy link
Copy Markdown
Contributor

The API reference corrections are valid, but the signal examples still fail as executable doctests:

  • ObservableSignals is not imported in the first example.
  • Inline lambdas are weakly referenced by observe(), so both examples produce no output.
  • The compatibility examples reference an undefined handler.

doctest.testmod(signal_types) reports four failures

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.

3 participants