From 5149b9c09a291653d66fc59a05be07a0ebd79c59 Mon Sep 17 00:00:00 2001 From: PimLeerkes Date: Thu, 14 Nov 2024 20:54:25 +0100 Subject: [PATCH] action dicts now get compared --- stormvogel/model.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/stormvogel/model.py b/stormvogel/model.py index fc4d283..2e4e3b8 100644 --- a/stormvogel/model.py +++ b/stormvogel/model.py @@ -897,16 +897,13 @@ def __str__(self) -> str: def __eq__(self, other) -> bool: if isinstance(other, Model): - # TODO compare action dicts - # if self.supports_actions(): - # actions_equal = sorted(self.actions.values()) == sorted( - # other.actions.values() - # ) - # else: - # actions_equal = True - - # if not actions_equal: - # print(self.actions,'\n', other.actions) + if self.supports_actions(): + assert self.actions is not None and other.actions is not None + for action, other_action in zip( + sorted(self.actions.values()), sorted(other.actions.values()) + ): + if not action == other_action: + return False return ( self.type == other.type and self.states == other.states @@ -914,7 +911,6 @@ def __eq__(self, other) -> bool: and sorted(self.rewards) == sorted(other.rewards) and self.exit_rates == other.exit_rates and self.markovian_states == other.markovian_states - # and actions_equal ) return False