From d728e32424037804bb2ceeaad44174dd6714f9da Mon Sep 17 00:00:00 2001 From: Nicholas Gao Date: Thu, 17 Oct 2024 11:06:40 +0200 Subject: [PATCH] add shape check and default to True if an exception is raised (#933) --- sacred/config/custom_containers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sacred/config/custom_containers.py b/sacred/config/custom_containers.py index dd10a19e..cf2642f0 100644 --- a/sacred/config/custom_containers.py +++ b/sacred/config/custom_containers.py @@ -306,13 +306,14 @@ def is_different(old_value, new_value): try: old_value = opt.np.asarray(old_value) new_value = opt.np.asarray(new_value) - except: - return True - else: + if old_value.shape != new_value.shape: + return True result = old_value != new_value if isinstance(result, bool): return result else: return result.all() + except: # if anything goes wrong, it is not equal + return True return old_value != new_value