From 47e8da353273fbf1216ed825f2543809b2ab0552 Mon Sep 17 00:00:00 2001 From: muelleram Date: Wed, 18 Sep 2024 11:58:21 +0200 Subject: [PATCH] add check for user-provided unique_id in TimeMappingDict already exists --- bw_timex/helper_classes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bw_timex/helper_classes.py b/bw_timex/helper_classes.py index 564b2f7..36cc8b6 100644 --- a/bw_timex/helper_classes.py +++ b/bw_timex/helper_classes.py @@ -129,6 +129,10 @@ def add(self, process_time_tuple, unique_id=None): return self[process_time_tuple] if unique_id is not None: + if unique_id in self.values(): + raise ValueError( + f"Unique ID {unique_id} is already assigned to another process_time_tuple." + ) self[process_time_tuple] = unique_id return unique_id