Skip to content

Commit f6d9feb

Browse files
spjuhelpeanutfun
andauthored
Improves dict comparison
Co-authored-by: Lukas Riedel <[email protected]>
1 parent 3776228 commit f6d9feb

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

climada/entity/impact_funcs/impact_func_set.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,10 @@ def __init__(self, impact_funcs: Optional[Iterable[ImpactFunc]] = None):
110110
self.append(impf)
111111

112112
def __eq__(self, value: object, /) -> bool:
113-
if not isinstance(value, ImpactFuncSet):
114-
return False
115-
116-
if self._data.keys() != value._data.keys():
117-
return False
118-
119-
for haz_type1, id_map1 in self._data.items():
120-
id_map2 = value._data[haz_type1]
121-
if id_map1.keys() != id_map2.keys():
122-
return False
123-
for fid, func1 in id_map1.items():
124-
if not func1 == id_map2[fid]:
125-
return False
126-
127-
return True
113+
if isinstance(value, ImpactFuncSet):
114+
return self._data == value._data
115+
116+
return False
128117

129118
def clear(self):
130119
"""Reinitialize attributes."""

0 commit comments

Comments
 (0)