From a733f1559e5ed9236d0f0f6e29e1fd10a4fe3ed2 Mon Sep 17 00:00:00 2001 From: "Hammond, Rob" <13874373+RHammond2@users.noreply.github.com> Date: Thu, 7 May 2026 13:21:13 -0700 Subject: [PATCH] fix bug in converting benedict objects to pure python dicts --- ORBIT/config.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ORBIT/config.py b/ORBIT/config.py index 6119df95..bb6523a3 100644 --- a/ORBIT/config.py +++ b/ORBIT/config.py @@ -33,7 +33,7 @@ def load_config(filepath): def prepare_config_for_save(config: dict | benedict) -> dict: - """Prepare the configuration file for compatbility with the YAML + """Prepare the configuration file for compatibility with the YAML ``SafeDump`` class used for saving configurations to file. Parameters @@ -47,6 +47,7 @@ def prepare_config_for_save(config: dict | benedict) -> dict: ORBIT configuration dictionary where all NumPy data types are converted to standard Python data types, e.g. ``np.float64`` -> ``float``. """ + config = dict(config) for k, v in config.items(): match v: case np.ndarray(): @@ -56,7 +57,7 @@ def prepare_config_for_save(config: dict | benedict) -> dict: case np.integer(): config[k] = int(v) case benedict(): - config[k] = prepare_config_for_save(v.dict()) + config[k] = prepare_config_for_save(dict(v)) case dict(): config[k] = prepare_config_for_save(v) case _: @@ -90,8 +91,6 @@ def save_config( raise FileExistsError(f"File already exists at '{filepath}'.") config = prepare_config_for_save(config) - if isinstance(config, benedict): - config = config.dict() with filepath.open("w") as f: yaml.dump(config, f, Dumper=Dumper, default_flow_style=False)