Skip to content

fix: support iterable agents in continuous space distances - #4040

Merged
quaquel merged 1 commit into
mesa:mainfrom
Jenil1905:fix/continuous-space-iterable-agents
Nov 6, 2026
Merged

quaquel merged 1 commit into
mesa:mainfrom
Jenil1905:fix/continuous-space-iterable-agents

Conversation

@Jenil1905

Copy link
Copy Markdown
Contributor

The function was consuming generators and iterators while calculating distances, so the returned agent became an unusable Numpy array. Because of this trying to iterate over the return agents caused a Tyeperror. It should return the agent as normal list in same order with each agent matching its correct distance.

Reproduction:
distances, returned_agents = space.calculate_distances(
[0.0, 0.0],
agents=iter([a, b]),
)

list(returned_agents)

Original implementation raised TypeError:

TypeError: iteration over a 0-d array

@github-actions github-actions Bot added experimental Release notes label testing Release notes label labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.7% [-1.0%, -0.4%] 🔵 +1.2% [+0.9%, +1.4%]
BoltzmannWealth large 🔵 -2.1% [-2.5%, -1.7%] 🔵 +0.3% [-0.4%, +1.1%]
Schelling small 🔵 -0.6% [-0.9%, -0.1%] 🔵 -1.4% [-2.1%, -0.8%]
Schelling large 🔵 -1.4% [-2.1%, -0.9%] 🔵 -2.3% [-2.8%, -1.7%]
WolfSheep small 🔵 +0.4% [+0.1%, +0.8%] 🔵 -0.1% [-4.9%, +4.6%]
WolfSheep large 🔵 +0.0% [-0.6%, +0.7%] 🔵 +0.3% [-0.9%, +1.5%]
SugarscapeG1mt small 🔵 -0.1% [-0.4%, +0.3%] 🔵 -0.4% [-2.1%, +1.4%]
SugarscapeG1mt large 🔵 -1.1% [-1.8%, -0.6%] 🔵 -0.5% [-2.2%, +1.7%]
BoidFlockers small 🔵 +0.7% [+0.5%, +1.1%] 🔵 +0.0% [-0.4%, +0.4%]
BoidFlockers large 🔵 +0.6% [+0.2%, +1.1%] 🔵 +0.2% [+0.0%, +0.4%]
MultiLevelAllianceModel small 🔵 -1.0% [-2.1%, +0.1%] 🔵 +0.5% [+0.2%, +0.7%]
MultiLevelAllianceModel large 🔵 -1.2% [-1.7%, -0.7%] 🔵 +0.9% [+0.3%, +1.5%]

@quaquel quaquel added the bug Release notes label label Nov 6, 2026
@quaquel

quaquel commented Nov 6, 2026

Copy link
Copy Markdown
Member

There is a merge conflict that must be resolved prior to merging this PR

@Jenil1905
Jenil1905 force-pushed the fix/continuous-space-iterable-agents branch from 5d13a9f to fc07241 Compare November 6, 2026 12:31
@Jenil1905

Copy link
Copy Markdown
Contributor Author

The merge conflict has been resolved, and the rebased branch now passes all checks. Thanks for reviewing!

@Jenil1905
Jenil1905 requested a review from quaquel November 6, 2026 12:41
@quaquel
quaquel merged commit fe24c24 into mesa:main Nov 6, 2026
17 checks passed
EwoutH pushed a commit that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label experimental Release notes label testing Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants