diff --git a/mesa/agent.py b/mesa/agent.py index 5504e1be06b..044b40acecf 100644 --- a/mesa/agent.py +++ b/mesa/agent.py @@ -155,7 +155,6 @@ def select( at_most: int | float = float("inf"), inplace: bool = False, agent_type: type[Agent] | None = None, - n: int | None = None, ) -> AgentSet: """Select a subset of agents from the AgentSet based on a filter function and/or quantity limit. @@ -167,7 +166,6 @@ def select( - If a float between 0 and 1, at most that fraction of original the agents are selected. inplace (bool, optional): If True, modifies the current AgentSet; otherwise, returns a new AgentSet. Defaults to False. agent_type (type[Agent], optional): The class type of the agents to select. Defaults to None, meaning no type filtering is applied. - n (int): deprecated, use at_most instead Returns: AgentSet: A new AgentSet containing the selected agents, unless inplace is True, in which case the current AgentSet is updated. @@ -176,14 +174,6 @@ def select( - at_most just return the first n or fraction of agents. To take a random sample, shuffle() beforehand. - at_most is an upper limit. When specifying other criteria, the number of agents returned can be smaller. """ - if n is not None: - warnings.warn( - "The parameter 'n' is deprecated and will be removed in Mesa 3.1. Use 'at_most' instead.", - DeprecationWarning, - stacklevel=2, - ) - at_most = n - inf = float("inf") if filter_func is None and agent_type is None and at_most == inf: return self if inplace else copy.copy(self) @@ -281,21 +271,6 @@ def do(self, method: str | Callable, *args, **kwargs) -> AgentSet: Returns: AgentSet | list[Any]: The results of the callable calls if return_results is True, otherwise the AgentSet itself. """ - try: - return_results = kwargs.pop("return_results") - except KeyError: - return_results = False - else: - warnings.warn( - "Using return_results is deprecated and will be removed in Mesa 3.1." - "Use AgenSet.do in case of return_results=False, and AgentSet.map in case of return_results=True", - DeprecationWarning, - stacklevel=2, - ) - - if return_results: - return self.map(method, *args, **kwargs) - # we iterate over the actual weakref keys and check if weakref is alive before calling the method if isinstance(method, str): for agentref in self._agents.keyrefs(): diff --git a/mesa/model.py b/mesa/model.py index 57af030e4b4..f89be92e7f6 100644 --- a/mesa/model.py +++ b/mesa/model.py @@ -18,7 +18,6 @@ import numpy as np from mesa.agent import Agent, AgentSet -from mesa.datacollection import DataCollector SeedLike = int | np.integer | Sequence[int] | np.random.SeedSequence RNGLike = np.random.Generator | np.random.BitGenerator @@ -112,14 +111,6 @@ def _wrapped_step(self, *args: Any, **kwargs: Any) -> None: # Call the original user-defined step method self._user_step(*args, **kwargs) - def next_id(self) -> int: # noqa: D102 - warnings.warn( - "using model.next_id() is deprecated and will be removed in Mesa 3.1. Agents track their unique ID automatically", - DeprecationWarning, - stacklevel=2, - ) - return 0 - @property def agents(self) -> AgentSet: """Provides an AgentSet of all agents in the model, combining agents from all types.""" @@ -143,16 +134,6 @@ def agents_by_type(self) -> dict[type[Agent], AgentSet]: """A dictionary where the keys are agent types and the values are the corresponding AgentSets.""" return self._agents_by_type - def get_agents_of_type(self, agenttype: type[Agent]) -> AgentSet: - """Deprecated: Retrieves an AgentSet containing all agents of the specified type.""" - warnings.warn( - f"Model.get_agents_of_type() is deprecated and will be removed in Mesa 3.1." - f"Please replace get_agents_of_type({agenttype}) with the property agents_by_type[{agenttype}].", - DeprecationWarning, - stacklevel=2, - ) - return self.agents_by_type[agenttype] - def _setup_agent_registration(self): """Helper method to initialize the agent registration datastructures.""" self._agents = {} # the hard references to all agents in the model @@ -245,38 +226,6 @@ def reset_rng(self, rng: RNGLike | SeedLike | None = None) -> None: self.rng = np.random.default_rng(rng) self._rng = self.rng.bit_generator.state - def initialize_data_collector( - self, - model_reporters=None, - agent_reporters=None, - agenttype_reporters=None, - tables=None, - ) -> None: - """Initialize the data collector for the model. - - Args: - model_reporters: model reporters to collect - agent_reporters: agent reporters to collect - agenttype_reporters: agent type reporters to collect - tables: tables to collect - - """ - warnings.warn( - "initialize_data_collector() is deprecated and will be removed in Mesa 3.1. Please use the DataCollector class directly. " - "by using `self.datacollector = DataCollector(...)`.", - DeprecationWarning, - stacklevel=2, - ) - - self.datacollector = DataCollector( - model_reporters=model_reporters, - agent_reporters=agent_reporters, - agenttype_reporters=agenttype_reporters, - tables=tables, - ) - # Collect data for the first time during initialization. - self.datacollector.collect(self) - def remove_all_agents(self): """Remove all agents from the model.