Skip to content

Conversation

@quaquel
Copy link
Member

@quaquel quaquel commented Jan 28, 2026

Sequence behavior on AgentSet is being deprecated. So we call self.agent.to_list() before random.sample in model.step. This also gives a substantial performance boost for this model.

Same fix in warehouse model, which still fails because sequence behavior is used in mesa.experimental's meta_agent stuff. The code in the example is now correct.

@quaquel quaquel changed the title Fix for DeprecationWarning on Deffluant model Fix for DeprecationWarning from AgentSet.__getitem__ Jan 28, 2026
Copy link
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.

Looks good, thanks

quaquel and others added 4 commits January 28, 2026 21:51
Co-authored-by: Ewout ter Hoeven <15776622+EwoutH@users.noreply.github.com>
Co-authored-by: Ewout ter Hoeven <15776622+EwoutH@users.noreply.github.com>
Co-authored-by: Ewout ter Hoeven <15776622+EwoutH@users.noreply.github.com>
Co-authored-by: Ewout ter Hoeven <15776622+EwoutH@users.noreply.github.com>
@quaquel quaquel merged commit 86f1521 into mesa:main Jan 28, 2026
2 of 4 checks passed
@EwoutH
Copy link
Member

EwoutH commented Jan 28, 2026

Seems like it's still present? Or was this another warning?

        .. deprecated::
            Sequence behavior (indexing/slicing) is deprecated and will be removed in Mesa 4.0.
            Use :meth:`to_list` instead: ``agentset.to_list()[index]`` or ``agentset.to_list()[start:stop]``.
        """
>       warnings.warn(
            "AgentSet.__getitem__ is deprecated and will be removed in Mesa 4.0. "
            "Use AgentSet.to_list()[index] instead. "
            "See https://mesa.readthedocs.io/latest/migration_guide.html#AgentSet-sequence-behavior",
            PendingDeprecationWarning,
            stacklevel=2,
        )
E       PendingDeprecationWarning: AgentSet.__getitem__ is deprecated and will be removed in Mesa 4.0. Use AgentSet.to_list()[index] instead. See https://mesa.readthedocs.io/latest/migration_guide.html#AgentSet-sequence-behavior

@quaquel
Copy link
Member Author

quaquel commented Jan 28, 2026

as indicated in the PR, this is an error in meta agent on mesa itself

@EwoutH
Copy link
Member

EwoutH commented Jan 28, 2026

Right, thanks. Is that problem written up somewhere in the Mesa repo?

Also a PendingDeprecationWarning shouldn't fail the CI. I opened a PR to fix that in #315.

@quaquel
Copy link
Member Author

quaquel commented Jan 28, 2026

Right, thanks. Is that problem written up somewhere in the Mesa repo?

will do tomorrow

Also a PendingDeprecationWarning shouldn't fail the CI. I opened a PR to fix that in #315.

this fix was triggered by build/examples on the mesa side. But the CI here uses mesa from pip, so neither works right now.

I guess this CI here should pip install mesa from github not from pip.

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.

2 participants