MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / ParamGroup

Class ParamGroup

arguments/__init__.py:19–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 pass
18
19class ParamGroup:
20 def __init__(self, parser: ArgumentParser, name : str, fill_none = False):
21 group = parser.add_argument_group(name)
22 for key, value in vars(self).items():
23 shorthand = False
24 if key.startswith("_"):
25 shorthand = True
26 key = key[1:]
27 t = type(value)
28 value = value if not fill_none else None
29 if shorthand:
30 if t == bool:
31 group.add_argument("--" + key, ("-" + key[0:1]), default=value, action="store_true")
32 else:
33 group.add_argument("--" + key, ("-" + key[0:1]), default=value, type=t)
34 else:
35 if t == bool:
36 group.add_argument("--" + key, default=value, action="store_true")
37 else:
38 group.add_argument("--" + key, default=value, type=t)
39
40 def extract(self, args):
41 group = GroupParams()
42 for arg in vars(args).items():
43 if arg[0] in vars(self) or ("_" + arg[0]) in vars(self):
44 setattr(group, arg[0], arg[1])
45 return group
46
47class ModelParams(ParamGroup):
48 def __init__(self, parser, sentinel=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected