Skip to content

Remove remaining mesa.space usage#333

Merged
quaquel merged 8 commits intomesa:mainfrom
falloficarus22:remove-mesa-space
Feb 20, 2026
Merged

Remove remaining mesa.space usage#333
quaquel merged 8 commits intomesa:mainfrom
falloficarus22:remove-mesa-space

Conversation

@falloficarus22
Copy link
Copy Markdown
Contributor

@falloficarus22 falloficarus22 commented Feb 18, 2026

Summary

This PR removes remaining mesa.space usage in examples so they work with newer Mesa APIs, and updates the Dining Philosophers example to use the new discrete-space API directly

Bug / Issue

Fixes #332
mesa.space has been deprecated, but several examples still referenced it directly.

Implementation

  • Replaced mesa.space imports/usages with supported APIs:

    • model.py
      • PropertyLayer import changed to mesa.discrete_space.PropertyLayer
      • Updated constructor call to the current PropertyLayer signature
  • Updated Conway fast example:

    • PropertyLayer import changed to mesa.discrete_space.PropertyLayer
    • Constructor updated to current signature (dimensions + default_value).
  • Updated Dining Philosophers network space usage:

    • model.py
      • Replaced removed mesa.space.NetworkGrid usage with a small compatibility adapter backed by mesa.discrete_space.Network
      • Preserved required behavior for place_agent, neighbor lookup, and visualization data access
  • Removed mesa.space type annotations in GIS modules and replaced with local or discrete-space-compatible coordinate type aliases

Testing

  • pytest -q test_examples.py
  • Result: 21 passed
  • Verified there are no remaining mesa.space references in examples/ and gis/.

import pytest
from mesa import Model

pytest.importorskip("mesa_geo")
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.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for this change it was meant to be local. The local gis tests fail (likely because incomplete migration in mesa-geo). I will raise a PR there to solve that.

Copy link
Copy Markdown
Member

@quaquel quaquel left a comment

Choose a reason for hiding this comment

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

A few minor remarks remaining

one overarching request: please keep PRs focussed on a specific fix. There are quite a few other changes here that are not strictly related to removing mesa.space. This makes reviewing for us harder.

@quaquel quaquel merged commit c296a83 into mesa:main Feb 20, 2026
6 checks passed
@falloficarus22 falloficarus22 deleted the remove-mesa-space branch February 20, 2026 07:46
Harshini2411 pushed a commit to Harshini2411/mesa-examples that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove mesa.space from all examples

2 participants