From 0ceef798c0c52e61f5556903c2b615219662df74 Mon Sep 17 00:00:00 2001 From: dh00601 <dh00601@surrey.ac.uk> Date: Sat, 5 Mar 2022 12:53:00 +0000 Subject: [PATCH] minor chances --- binarycpython/utils/ensemble.py | 10 ++++++++-- binarycpython/utils/grid.py | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/binarycpython/utils/ensemble.py b/binarycpython/utils/ensemble.py index 72a0ced7d..590907d4f 100644 --- a/binarycpython/utils/ensemble.py +++ b/binarycpython/utils/ensemble.py @@ -282,8 +282,14 @@ def binaryc_json_serializer(obj: Any) -> Any: if inspect.isfunction(obj) or isinstance(obj, py_rinterpolate.Rinterpolate): return str(obj) - return obj - + else: + try: + string_version = str(obj) + return string_version + except: + raise TypeError( + "Unserializable object {} of type {}. Attempted to convert to string but that failed.".format(obj, type(obj)) + ) class binarycDecoder(json.JSONDecoder): """ diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index d4f2f830f..7ec47378d 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -1364,9 +1364,10 @@ class Population: include_binary_c_version_info=True, include_binary_c_help_all=True, ) - self.grid_ensemble_results["metadata"]["settings"] = json.loads( - json.dumps(all_info, default=binaryc_json_serializer) - ) + # self.grid_ensemble_results["metadata"]["settings"] = json.loads( + # json.dumps(all_info, default=binaryc_json_serializer) + # ) + self.grid_ensemble_results['metadata']['settings'] = all_info ############################## # Update grid options -- GitLab