diff --git a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py index f2af02ac5253b6fb722bf9dba87dcc6c756de6ee..16a50dde8e9d4fb73bf4ccaabb919bf34dce9e60 100644 --- a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py +++ b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py @@ -58,6 +58,20 @@ class HolographyDataset(): # ('flag', numpy.bool)] # ) + @staticmethod + def compare_dicts(dict1, dict2): + result = True + for key in dict1.keys(): + if key in dict2.keys(): + if isinstance(dict1[key], dict) and isinstance(dict2[key], dict): + result = result and HolographyDataset.compare_dicts(dict1[key], dict2[key]) + else: + return dict1[key] == dict2[key] + else: + print(key, dict1.keys(), dict2.keys()) + return False + return result + def __eq__(self, hds = None): equality = False if hds is not None and isinstance(hds, HolographyDataset) is True: @@ -68,6 +82,8 @@ class HolographyDataset(): try: if isinstance(attribute_value, numpy.ndarray) is True and isinstance(other_value, numpy.ndarray) is True: this_equality = numpy.array_equal(attribute_value, other_value) + elif isinstance(attribute_value, dict) is True and isinstance(other_value, dict) is True: + this_equality = HolographyDataset.compare_dicts(attribute_value, other_value) elif attribute_value != other_value: this_equality = False except Exception as e: