Saves dict of floats in json file Args: d: (dict) of float-castable values (np.float, int, float, etc.) json_path: (string) path to json file
(d, json_path)
| 65 | |
| 66 | |
| 67 | def save_dict_to_json(d, json_path): |
| 68 | """Saves dict of floats in json file |
| 69 | |
| 70 | Args: |
| 71 | d: (dict) of float-castable values (np.float, int, float, etc.) |
| 72 | json_path: (string) path to json file |
| 73 | """ |
| 74 | with open(json_path, 'w') as f: |
| 75 | # We need to convert the values to float for json (it doesn't accept np.array, np.float, ) |
| 76 | d = {k: float(v) for k, v in d.items()} |
| 77 | json.dump(d, f, indent=4) |
no outgoing calls
no test coverage detected