From 9d688e4a9662823baaff4cb1a1f2d684d0588be0 Mon Sep 17 00:00:00 2001 From: SongshGeo Date: Mon, 10 Nov 2025 20:27:06 +0100 Subject: [PATCH] fix(model): :bug: Enhance steps calculation in MainModel class This commit improves the calculation of the `delta` value in the `MainModel` class by explicitly retrieving the previous `_steps` value from the instance's dictionary. This change enhances clarity and ensures that the logic for advancing time is based on the correct previous state, thereby improving the integrity of the model's state management. --- abses/core/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/abses/core/model.py b/abses/core/model.py index 3206e597..6691e47d 100644 --- a/abses/core/model.py +++ b/abses/core/model.py @@ -181,7 +181,8 @@ def steps(self, steps: int) -> None: Parameters: steps: Number of steps. If > 0, automatically advances time. """ - delta = steps - getattr(self, "_steps", 0) + old_steps = self.__dict__.get("_steps", 0) + delta = steps - old_steps if not isinstance(delta, int): raise TypeError(f"Steps must be an integer, got {type(steps)}") if delta > 0: