Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update some DeprecationWarnings to note they are removed in Mesa 3.1 #2481

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ You can access it by `Model.steps`, and it's internally in the datacollector, ba
- The `Model._advance_time()` method is removed. This now happens automatically.

#### Replacing Schedulers with AgentSet functionality
The whole Time module in Mesa is deprecated, and all schedulers are being replaced with AgentSet functionality and the internal `Model.steps` counter. This allows much more flexibility in how to activate Agents and makes it explicit what's done exactly.
The whole Time module in Mesa is deprecated and will be removed in Mesa 3.1. All schedulers should be replaced with AgentSet functionality and the internal `Model.steps` counter. This allows much more flexibility in how to activate Agents and makes it explicit what's done exactly.

Here's how to replace each scheduler:

Expand Down
7 changes: 4 additions & 3 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def select(
"""
if n is not None:
warnings.warn(
"The parameter 'n' is deprecated. Use 'at_most' instead.",
"The parameter 'n' is deprecated and will be removed in Mesa 3.1. Use 'at_most' instead.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -276,8 +276,9 @@ def do(self, method: str | Callable, *args, **kwargs) -> AgentSet:
return_results = False
else:
warnings.warn(
"Using return_results is deprecated. Use AgenSet.do in case of return_results=False, and "
"AgentSet.map in case of return_results=True",
"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,
)

Expand Down
8 changes: 4 additions & 4 deletions mesa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _wrapped_step(self, *args: Any, **kwargs: Any) -> None:

def next_id(self) -> int: # noqa: D102
warnings.warn(
"using model.next_id() is deprecated. Agents track their unique ID automatically",
"using model.next_id() is deprecated and will be removed in Mesa 3.1. Agents track their unique ID automatically",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -146,8 +146,8 @@ def agents_by_type(self) -> dict[type[Agent], AgentSet]:
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, please replace get_agents_of_type({agenttype})"
f"with the property agents_by_type[{agenttype}].",
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,
)
Expand Down Expand Up @@ -262,7 +262,7 @@ def initialize_data_collector(

"""
warnings.warn(
"initialize_data_collector() is deprecated. Please use the DataCollector class directly. "
"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,
Expand Down
8 changes: 4 additions & 4 deletions mesa/time.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Mesa Time Module.

.. warning::
The time module and all its Schedulers are deprecated and will be removed in a future version.
The time module and all its Schedulers are deprecated and will be removed in Mesa 3.1.
They can be replaced with AgentSet functionality. See the migration guide for details:
https://mesa.readthedocs.io/latest/migration_guide.html#time-and-schedulers

Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, model: Model, agents: Iterable[Agent] | None = None) -> None:

"""
warnings.warn(
"The time module and all its Schedulers are deprecated and will be removed in a future version. "
"The time module and all its Schedulers are deprecated and will be removed in Mesa 3.1. "
"They can be replaced with AgentSet functionality. See the migration guide for details. "
"https://mesa.readthedocs.io/latest/migration_guide.html#time-and-schedulers",
DeprecationWarning,
Expand Down Expand Up @@ -375,7 +375,7 @@ def get_type_count(self, agenttype: type[Agent]) -> int:


class DiscreteEventScheduler(BaseScheduler):
"""This class has been deprecated and replaced by the functionality provided by experimental.devs."""
"""This class has been removed and replaced by the functionality provided by experimental.devs."""

def __init__(self, model: Model, time_step: TimeT = 1) -> None:
"""Initialize DiscreteEventScheduler.
Expand All @@ -387,5 +387,5 @@ def __init__(self, model: Model, time_step: TimeT = 1) -> None:
"""
super().__init__(model)
raise Exception(
"DiscreteEventScheduler is deprecated in favor of the functionality provided by experimental.devs"
"DiscreteEventScheduler is removed in favor of the functionality provided by experimental.devs"
)
Loading