From 91e81b8a99120f8ce448a5cdf9720b482a197f06 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Wed, 30 Jun 2021 01:34:13 +0100
Subject: [PATCH] Fixed merge_dict for ordererddicts

---
 binarycpython/utils/functions.py | 5 +++++
 binarycpython/utils/grid.py      | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py
index 9691f1f55..039d36c23 100644
--- a/binarycpython/utils/functions.py
+++ b/binarycpython/utils/functions.py
@@ -1497,6 +1497,11 @@ def merge_dicts(dict_1: dict, dict_2: dict) -> dict:
                 type(dict_2[key]) in [int, float, np.float64]
             ):
                 new_dict[key] = dict_1[key] + dict_2[key]
+            # Exceptions:
+            elif (type(dict_1[key]) in [dict, OrderedDict]) and (
+                type(dict_2[key]) in [dict, OrderedDict]
+            ):
+                new_dict[key] = merge_dicts(dict_1[key], dict_2[key])
 
             else:
                 print(
diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 8271604cb..eae019acd 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -943,7 +943,6 @@ class Population:
         # Put back in the dictionary
         return reformatted_ensemble_results
 
-
     def _evolve_population_grid(self):
         """
         Function to evolve the population with multiprocessing approach.
-- 
GitLab