Skip to content

Fix: Handle capacity=None in Cell.is_full property#2981

Merged
EwoutH merged 3 commits intomesa:mainfrom
Nithin9585:fix/cell-is-full-capacity-none
Dec 22, 2025
Merged

Fix: Handle capacity=None in Cell.is_full property#2981
EwoutH merged 3 commits intomesa:mainfrom
Nithin9585:fix/cell-is-full-capacity-none

Conversation

@Nithin9585
Copy link
Copy Markdown
Contributor

Fixes #2980

This PR fixes the type comparison error in Cell.is_full when capacity=None.

Changes

  • Add explicit None check for infinite capacity
  • Change == to >= to handle edge cases where agents exceed capacity
  • Add comprehensive tests covering None capacity, finite capacity, and edge cases

Testing

All new tests pass:

  • test_cell_is_full_with_none_capacity
  • test_cell_is_full_with_finite_capacity
  • test_cell_is_full_with_capacity_exceeded

@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +3.3% [+2.7%, +3.9%] 🔵 +0.3% [+0.1%, +0.4%]
BoltzmannWealth large 🔵 +2.8% [-0.0%, +7.8%] 🔵 +2.4% [+0.4%, +4.4%]
Schelling small 🔵 +0.2% [-1.5%, +1.8%] 🔵 -0.7% [-1.6%, +0.2%]
Schelling large 🔵 +1.6% [-0.0%, +4.8%] 🔵 +2.1% [+0.9%, +3.2%]
WolfSheep small 🔵 -0.4% [-1.5%, +0.4%] 🔵 -0.2% [-0.4%, -0.1%]
WolfSheep large 🔵 -1.5% [-6.8%, +1.6%] 🔵 +3.0% [+2.4%, +3.5%]
BoidFlockers small 🔵 +1.7% [+1.3%, +2.2%] 🔵 +0.0% [-0.1%, +0.1%]
BoidFlockers large 🔵 +1.0% [+0.5%, +1.4%] 🔵 +0.3% [+0.1%, +0.6%]

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.

Thanks!

Copy link
Copy Markdown
Member

@EwoutH EwoutH left a comment

Choose a reason for hiding this comment

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

Thanks!

Code looks good, one comment on the tests

Fixes mesa#2980

- Add explicit None check for infinite capacity
- Change == to >= to handle edge cases
- Add comprehensive tests for None and finite capacity
@Nithin9585 Nithin9585 force-pushed the fix/cell-is-full-capacity-none branch from f52dfa1 to 3b13e98 Compare December 22, 2025 10:23
@Nithin9585 Nithin9585 force-pushed the fix/cell-is-full-capacity-none branch from af5c015 to 7faf712 Compare December 22, 2025 14:58
@quaquel
Copy link
Copy Markdown
Member

quaquel commented Dec 22, 2025

From my perspective, this is ready to be merged. I'll wait for @EwoutH before merging.

@EwoutH EwoutH added bug Release notes label testing Release notes label labels Dec 22, 2025
@EwoutH EwoutH merged commit 951ea24 into mesa:main Dec 22, 2025
11 of 13 checks passed
@Nithin9585 Nithin9585 deleted the fix/cell-is-full-capacity-none branch December 22, 2025 18:23
@EwoutH
Copy link
Copy Markdown
Member

EwoutH commented Dec 22, 2025

Nice clean final diff, thanks!

(we do require docstring for every function, a single line is often enough for tests. See 6420ae2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label testing Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Cell.is_full type comparison error with capacity=None

3 participants