We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 868895e commit bcaa4a7Copy full SHA for bcaa4a7
ecg_bench/utils/dir_file_utils.py
@@ -21,8 +21,18 @@ def open_json(path: Union[str, Path]) -> dict:
21
@staticmethod
22
def save_json(data: dict, path: Union[str, Path]):
23
"""Save a dictionary to a JSON file."""
24
+ def convert_numpy(obj):
25
+ if isinstance(obj, np.ndarray):
26
+ return obj.tolist()
27
+ elif isinstance(obj, dict):
28
+ return {key: convert_numpy(value) for key, value in obj.items()}
29
+ elif isinstance(obj, list):
30
+ return [convert_numpy(item) for item in obj]
31
+ else:
32
+ return obj
33
+
34
with open(path, 'w') as f:
- json.dump(data, f)
35
+ json.dump(convert_numpy(data), f)
36
37
38
def get_system_prompt(system_prompt_path: Union[str, Path]):
0 commit comments