Repository navigation
Backport fixes and enhancements for Mesa 3.5.2 - #4016
Merged
Merged
Conversation
(cherry picked from commit aa3787e)
(cherry picked from commit ffe5f2f)
* Optimise _remove_agent * Remove _agent_to_index (cherry picked from commit 4140369)
(cherry picked from commit 62afb50)
(cherry picked from commit 9871ac8)
(cherry picked from commit d4fb6b2)
(cherry picked from commit 71cfd39)
(cherry picked from commit c8b833e)
(cherry picked from commit b813d90)
Fixed minor typos and grammar issues in the Boltzmann Wealth Model tutorial. (cherry picked from commit 2b23c16)
(cherry picked from commit 1dbdb37)
* docs: add clear run instructions for alliance_formation example * docs: add clear run instructions for boid_flockers example * docs: remove redundant mesa install and update run instructions * docs: remove redundant install steps and standardize run instructions for boid_flockers example * docs: standardize run instructions across Mesa examples * docs: include recommended dependencies for running examples --------- Co-authored-by: Tom Pike <[email protected]> (cherry picked from commit 410c99a)
Co-authored-by: Sahil Chhoker <[email protected]> (cherry picked from commit 06a3e8d)
(cherry picked from commit 43d3680)
…zation (mesa#3670) Co-authored-by: Jan Kwakkel <[email protected]> (cherry picked from commit 7b53255)
(cherry picked from commit 5312e71)
(cherry picked from commit 26e775d)
for more information, see https://pre-commit.ci (cherry picked from commit 7a64a95)
(cherry picked from commit 62f83fb)
Fixes mesa#3454 SolaraViz now validates upfront that model is an initialized instance, not a class. The check fires before Solara's reactive system can swallow the bad input, producing a clear, actionable error message. Two cases are handled: - SolaraViz(MyModel, ...) — bare class passed directly - SolaraViz(solara.reactive(MyModel), ...) — class wrapped in reactive Error message includes the concrete fix: 'Did you mean SolaraViz(MyModel(), ...)?' This is a common migration mistake from ModularServer, which took a class. Added tests in tests/visualization/test_solara_viz_class_validation.py. (cherry picked from commit 74c3c79)
(cherry picked from commit be1e8f0)
(cherry picked from commit 7bb0f7d)
…sa#3671) * Fix run_model_test capturing initial image instead of updated visualization * Fix ValueError in get_k_nearest_agents when k >= number of agents * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix k>=n and empty space handling in ContinuousSpace * Address review feedback: add warning for k>n, fix test setup, remove unrelated viz change --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jan Kwakkel <[email protected]> (cherry picked from commit 9780c9f)
(cherry picked from commit a69b18b)
…empty_cell() when grid is full (mesa#3500) * fix: prevent IndexError and add clear error message in select_random_empty_cell() when grid is full * fix: improve error handling using try catch in select_random_empty_cell() for full grids * a small fix --------- Co-authored-by: Jan Kwakkel <[email protected]> (cherry picked from commit 0eaf588)
(cherry picked from commit 598efe5)
(cherry picked from commit 19eff50)
(cherry picked from commit e5245c8)
* Fix network crash error in matplotlib backend network drawing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix remaining IndentationError and edgecolors length bug in matplotlib backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit 8503a32)
(cherry picked from commit 6d55c55)
…tasets (mesa#3892) When a NumpyAgentDataSet was converted to a DataFrame or written to Parquet, stacking agent_ids onto float data upcast agent_ids to float64 (e.g. 1.0, 2.0). Now DataRecorder and ParquetDataRecorder explicitly preserve agent_id as an integer. Fixes mesa#3871 (cherry picked from commit 786fcde)
…esa#3902) * Raise IndexError for out-of-range negative indices in SignalingList SignalingList.__setitem__ and __delitem__ normalize a negative integer index by adding len(self.data) once, but never check the result. An index below -len therefore stays negative after normalization and Python's own wrap-around kicks in, so lst[-4] = x on a three-element list overwrites the last element and del lst[-4] deletes it, instead of raising IndexError like a plain list. A REPLACED/REMOVED signal is emitted for the wrong element as well. Bounds-check the normalized index and raise IndexError, matching list. Fixes mesa#3901 * Match built-in list message for out-of-range del in SignalingList Co-Authored-By: Claude Opus 5.5 <[email protected]> * Revert "Match built-in list message for out-of-range del in SignalingList" The built-in list raises "list assignment index out of range" for del as well, so the original message already matched. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 9175791)
(cherry picked from commit 093e967)
Some backported tests were written against main (4.0) or picked up neighbouring 4.0-only tests when resolving conflicts: - use HasObservables instead of HasEmitters (renamed in 4.0) - use agent.pos instead of agent.position in backend test stubs - add the missing pytest import in test_components_matplotlib.py - drop tests for 4.0-only features (RUN_ENDED signal, AgentDataSet dirty flag) and a duplicated draw_property_layers call
The FutureWarning for returning a dict from agent_portrayal was raised inside the per-agent loop in collect_agent_data, so a model with a few thousand agents produced a few thousand identical warnings on every render. Under Solara that is once per step, which buries anything else in the console and slows the render down. Hoist it with a local flag in each of the three loops (both backends and mpl_space_drawing) so it fires on the first dict portrayal seen and not again for that call. The dict to AgentPortrayalStyle conversion is untouched, and the per-agent UserWarning about ignored keys is left as is since it can differ between agents. Closes mesa#3455 (cherry picked from commit eed8b2a)
* mixed-face-colors patch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update assertion for uniform result shape --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tom Pike <[email protected]> (cherry picked from commit f376606)
…tion.py Backport of mesa#3434, adapted for 3.5.x (which has no mesa.exceptions module): - DataCollector.get_model_vars_dataframe() and get_agent_vars_dataframe() raised UserWarning as an exception although the message says an empty DataFrame is returned. They now warn and return an empty DataFrame. - Missing tables and missing columns raise ValueError (a subclass of the bare Exception used before) with the table/column name in the message. - Fix the inverted 'is larger than' messages in Model.run_until() and Model._advance_time().
(cherry picked from commit a7502b6)
(cherry picked from commit bfea659)
(cherry picked from commit 3b7bfdc)
Update version and release notes for the next patch release, Mesa 3.5.2.
quaquel
approved these changes
Oct 28, 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.
Backports 85 PRs from
mainto3.5.x-maintenanceand bumps the version to 3.5.2, with release notes inHISTORY.md.Scope is the same as 3.5.1: bug fixes, performance, docs fixes and small additive enhancements. 4.0-only work (Actions, meta-agents rewrite, scenario storage,
ContinuousState,on_idle,select_random, …) is not included. Fixes that change results were included only when the 3.5.1 behaviour was clearly wrong (#3797, #3918, #3544, #3986).Most commits are plain
git cherry-pick -x. Test-only conflicts were resolved by keeping both sides.Adapted for 3.5.x
capacityis no longer overwritten. On main this PR also removed thecapacity_functionkeyword and changed the default to unlimited capacity. Both are breaking, so they're not included.spring_layoutas the default andlayout=Noneas "topological". The default is now a small wrapper that imports networkx when called. Verified thatimport mesafails without networkx on 3.5.1 and works here.model.pyanddatacollection.py#3434 exception types: there is nomesa.exceptionsin 3.5, so missing tables and columns raiseValueError(a subclass of the bareExceptionused before). The no-reporter dataframe getters now warn and return an empty DataFrame instead of raisingUserWarning.SignalingList#3486, Return descriptor on class-level Observable access #3733, Fix signal docstring examples and add doctest coverage #3819: applied withHasObservablesinstead ofHasEmitters.self.empty.dataand its existing exception type.mesa.space"has been removed" now says it's in maintenance-only mode and will be removed in 4.0.HasObservables,agent.pos) and drops tests for 4.0-only features that came in while resolving conflicts.Not backported
AgentSet.select_randomis 4.0-only).AgentSet.setsemantics for list values).Testing
pytest tests/ -Werror -Wdefault::PendingDeprecationWarning -W "ignore:websockets.legacy is deprecated:DeprecationWarning": 765 passed, 1 skipped (local, Python 3.13). The Playwright browser tests intests/examples/test_examples_viz.pywere not run locally.ruff check/ruff format --check: same results as the3.5.x-maintenancebase. One existing lint warning and 6 existing format diffs, none introduced here.After merging, publish the v3.5.2 draft release.
AI use: the backport selection, cherry-picks, conflict resolution, adapted commits and release notes were prepared with Claude Code.
🤖 Generated with Claude Code