diff --git a/dso/dso/utils.py b/dso/dso/utils.py index e33bcb7..bbbb012 100644 --- a/dso/dso/utils.py +++ b/dso/dso/utils.py @@ -1,6 +1,5 @@ """Utility functions used in deep symbolic optimization.""" -import collections import copy import functools import numpy as np @@ -10,6 +9,11 @@ import os import pandas as pd +try: + from collections.abc import Mapping +except ImportError: + from collections import Mapping + def is_float(s): """Determine whether the input variable can be cast to float.""" @@ -154,7 +158,7 @@ def safe_merge_dicts(base_dict, update_dict): return update_dict base_dict = copy.deepcopy(base_dict) for key, value in update_dict.items(): - if isinstance(value, collections.Mapping): + if isinstance(value, Mapping): base_dict[key] = safe_merge_dicts(base_dict.get(key, {}), value) else: base_dict[key] = value