Skip to content

Commit

Permalink
fix: Initialize model _steps and _time during __new__
Browse files Browse the repository at this point in the history
This is to retain backward compatibility with Mesa 2.1.x behavior where
a model `super().__init__()` is not necessary.
  • Loading branch information
rht committed Feb 4, 2024
1 parent 7cadddb commit 8625570
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Any:
# advance.
obj._seed = random.random() # noqa: S311
obj.random = random.Random(obj._seed)
# TODO: Remove these 2 lines after Mesa 2.3
obj._steps = 0
obj._time = 0
return obj

def __init__(self, *args: Any, **kwargs: Any) -> None:
Expand Down

0 comments on commit 8625570

Please sign in to comment.