From 1efc3112c5a9b8e68e92f0f4483c1f30f4d43cf9 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 4 Feb 2024 02:56:55 -0500 Subject: [PATCH] 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. --- mesa/model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mesa/model.py b/mesa/model.py index b2b12340ad9..785ffe0c5a6 100644 --- a/mesa/model.py +++ b/mesa/model.py @@ -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 just before Mesa 3.0 + obj._steps = 0 + obj._time = 0 return obj def __init__(self, *args: Any, **kwargs: Any) -> None: