| 61 | |
| 62 | |
| 63 | class CustomJSONEncoder(json.JSONEncoder): |
| 64 | def default(self, obj): |
| 65 | if isinstance(obj, FunctionType): |
| 66 | return f"<function {obj.__name__}>" |
| 67 | if isinstance(obj, type): |
| 68 | return f"<class '{obj.__name__}'>" |
| 69 | if isinstance(obj, torch.dtype): |
| 70 | return str(obj) |
| 71 | if isinstance(obj, Path): |
| 72 | return str(obj) |
| 73 | if isinstance(obj, ConfigNode): |
| 74 | return config_to_plain_dict(obj) |
| 75 | if isinstance(obj, (Namespace, SimpleNamespace)): |
| 76 | return vars(obj) |
| 77 | return super().default(obj) |
| 78 | |
| 79 | |
| 80 | def _parse_scalar(value): |
nothing calls this directly
no outgoing calls
no test coverage detected