Skip to content

Commit

Permalink
Stabilize AgentSet
Browse files Browse the repository at this point in the history
Removes the experimental warning for the AgentSet.
  • Loading branch information
EwoutH committed Feb 29, 2024
1 parent ca748d7 commit 223e895
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
18 changes: 1 addition & 17 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import contextlib
import copy
import operator
import warnings
import weakref
from collections import defaultdict
from collections.abc import Iterable, Iterator, MutableSet, Sequence
Expand Down Expand Up @@ -81,12 +80,6 @@ def random(self) -> Random:

class AgentSet(MutableSet, Sequence):
"""
.. warning::
The AgentSet is experimental. It may be changed or removed in any and all future releases, including
patch releases.
We would love to hear what you think about this new feature. If you have any thoughts, share them with
us here: https://github.com/projectmesa/mesa/discussions/1919
A collection class that represents an ordered set of agents within an agent-based model (ABM). This class
extends both MutableSet and Sequence, providing set-like functionality with order preservation and
sequence operations.
Expand Down Expand Up @@ -115,17 +108,8 @@ def __init__(self, agents: Iterable[Agent], model: Model):
agents (Iterable[Agent]): An iterable of Agent objects to be included in the set.
model (Model): The ABM model instance to which this AgentSet belongs.
"""
self.model = model

if not self.__class__.agentset_experimental_warning_given:
self.__class__.agentset_experimental_warning_given = True
warnings.warn(
"The AgentSet is experimental. It may be changed or removed in any and all future releases, including patch releases.\n"
"We would love to hear what you think about this new feature. If you have any thoughts, share them with us here: https://github.com/projectmesa/mesa/discussions/1919",
FutureWarning,
stacklevel=2,
)

self.model = model
self._agents = weakref.WeakKeyDictionary({agent: None for agent in agents})

def __len__(self) -> int:
Expand Down
3 changes: 0 additions & 3 deletions mesa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self._steps: int = 0
self._time: TimeT = 0 # the model's clock

# Warning flags for current experimental features. These make sure a warning is only printed once per model.
self.agentset_experimental_warning_given = False

@property
def agents(self) -> AgentSet:
"""Provides an AgentSet of all agents in the model, combining agents from all types."""
Expand Down

0 comments on commit 223e895

Please sign in to comment.