Fill result for unknown parent in sum_tree

The parent of a record may not be in the list of instances computed.
This commit is contained in:
Cédric Krier
2023-06-05 12:55:00 +02:00
parent 0bffc1c384
commit 01727ac772
+4 -1
View File
@@ -160,7 +160,10 @@ def sum_tree(records, values, parent='parent'):
records.remove(leaf)
parent = parents.get(leaf)
if parent:
result[parent] += result[leaf]
try:
result[parent] += result[leaf]
except KeyError:
result[parent] = result[leaf]
next_leafs = set(records)
for record in records:
parent = parents.get(record)