Skip to content

Commit 2b86672

Browse files
committed
fix: Initialize model _steps and _time during __new__
This is to retain backward compatibility with Mesa 2.1.x behavior where a model `super().__init__()` is not necessary.
1 parent 7cadddb commit 2b86672

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mesa/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Any:
5757
# advance.
5858
obj._seed = random.random() # noqa: S311
5959
obj.random = random.Random(obj._seed)
60+
# TODO: Remove these 2 lines after 2.3
61+
obj._steps = 0
62+
obj._time = 0
6063
return obj
6164

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

0 commit comments

Comments
 (0)