Skip to content

Commit a39dd31

Browse files
reyan-singhpre-commit-ci[bot]adamamer20
authored
Support NumPy 2.0+ #98 - Initial Commit for toml and example script (#126)
This pull request includes several changes to improve compatibility and update dependencies across multiple files. The most important changes include adding version checks for dependencies, updating deprecation warnings, and modifying dependency versions in the `pyproject.toml` file. ### Dependency Management: * [`examples/boltzmann_wealth/performance_plot.py`](diffhunk://#diff-0cfe707eefb955b4435c5773abfc2634593774e785fe9b83e2d0d94368d273cfR46-R49): Added version checks to ensure the installed version of `mesa` meets the required version before creating agents. ### Deprecation Warnings: * [`mesa_frames/concrete/pandas/agentset.py`](diffhunk://#diff-e72d1839a96ddb5155de9001c1d833e30d9c811a3f2e1ca98ea12fd946f5f8b0L76-R80): Reformatted the deprecation warning for `AgentSetPandas` to improve readability. * [`mesa_frames/concrete/pandas/mixin.py`](diffhunk://#diff-f5cb777b3360f5469015a37672c054eabb7c455d8aeddccd574cefb1e4c8fc72L54-R59): Reformatted the deprecation warning for `PandasMixin` to improve readability. ### Dependency Updates: * [`pyproject.toml`](diffhunk://#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L36-R36): Updated the version requirement for `numpy` to `>=2.0.2`. * [`pyproject.toml`](diffhunk://#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L92-R92): Updated the version requirement for `numba` to `>=0.60`. * Initial Commit for toml and example script This commit includes changes in toml file to update numpy verstion to 2.0.2 and using numba latest along with changes in performance_plot.py to use custom modal and agent for testing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Initial Commit for toml and example script This commit includes changes in toml file to update numpy verstion to 2.0.2 and using numba latest along with changes in performance_plot.py to use custom modal and agent for testing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated performance_plot to fix plots Changes are done to fix performance plot data, default anent cannot set if version >=2.4.0 so removed manual agent additon and added version verification to run defaut agents in case of version >= 2.4.0 Also adding sample performance plots generted with latest changes * Updated performance_plot to fix plots Changes are done to fix performance plot data, default anent cannot set if version >=2.4.0 so removed manual agent additon and added version verification to run defaut agents in case of version >= 2.4.0 Also adding sample performance plots generted with latest changes * Update mesa_frames/concrete/pandas/agentset.py updating suggested code to pass pre-commit check Co-authored-by: Adam Amer <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update pyproject.toml Co-authored-by: Adam Amer <[email protected]> * Update mesa_frames/concrete/pandas/mixin.py updating suggested code to pass pre-commit check Co-authored-by: Adam Amer <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * setting numba to be >= 0.60.0 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Adam Amer <[email protected]>
1 parent c2022dc commit a39dd31

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed
-7.5 KB
Loading
-7.99 KB
Loading

examples/boltzmann_wealth/performance_plot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import perfplot
66
import polars as pl
77
import seaborn as sns
8+
import importlib.metadata
9+
from packaging import version
810

911
from mesa_frames import AgentSetPandas, AgentSetPolars, ModelDF
1012

@@ -41,7 +43,11 @@ def __init__(self, N):
4143
super().__init__()
4244
self.num_agents = N
4345
# Create scheduler and assign it to the model
44-
self.agents = [MoneyAgent(i, self) for i in range(self.num_agents)]
46+
installed_version = version.parse(importlib.metadata.version("mesa"))
47+
required_version = version.parse("2.4.0")
48+
49+
if installed_version < required_version:
50+
self.agents = [MoneyAgent(i, self) for i in range(self.num_agents)]
4551

4652
def step(self):
4753
"""Advance the model by one step."""

mesa_frames/concrete/pandas/agentset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ def step(self):
7373

7474
@copydoc(AgentSetDF)
7575
class AgentSetPandas(AgentSetDF, PandasMixin):
76-
"""WARNING: AgentSetPandas is deprecated and will be removed in the next release of mesa-frames.
76+
"""
77+
WARNING: AgentSetPandas is deprecated and will be removed in the next release of mesa-frames.
7778
7879
pandas-based implementation of AgentSetDF.
80+
7981
"""
8082

8183
_agents: pd.DataFrame

mesa_frames/concrete/pandas/mixin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ def _some_private_method(self):
5151

5252

5353
class PandasMixin(DataFrameMixin):
54-
"""WARNING: PandasMixin is deprecated and will be removed in the next release of mesa-frames.
54+
"""
55+
WARNING: PandasMixin is deprecated and will be removed in the next release of mesa-frames.
56+
5557
pandas-based implementation of DataFrame operations.
56-
""" # noqa: D205
58+
59+
"""
5760

5861
def __init__(self, *args, **kwargs):
5962
warnings.warn(

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ classifiers = [
3333
"Topic :: Scientific/Engineering :: Artificial Life",
3434
]
3535
dependencies = [
36-
"numpy~=1.26",
36+
"numpy>=2.0.2",
3737
"typing-extensions>=4.9", #typing-extensions.Self added in 4.9
3838
## pandas
3939
"pandas>=2.2",
@@ -89,7 +89,7 @@ test = [
8989
dev = [
9090
"mesa_frames[test, docs]",
9191
"mesa~=2.4.0",
92-
"numba",
92+
"numba>=0.60",
9393
]
9494

9595
[tool.hatch.envs.test]

0 commit comments

Comments
 (0)