MCPcopy Create free account
hub / github.com/DIVE128/DMVSNet / make_recursive_func

Function make_recursive_func

tools.py:61–72  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

59
60# convert a function into recursive style to handle nested dict/list/tuple variables
61def make_recursive_func(func):
62 def wrapper(vars):
63 if isinstance(vars, list):
64 return [wrapper(x) for x in vars]
65 elif isinstance(vars, tuple):
66 return tuple([wrapper(x) for x in vars])
67 elif isinstance(vars, dict):
68 return {k: wrapper(v) for k, v in vars.items()}
69 else:
70 return func(vars)
71
72 return wrapper
73
74
75def save_scalars(logger, mode, scalar_dict, global_step):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected