MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / bool_flag

Function bool_flag

utils.py:181–192  ·  view source on GitHub ↗

Parse boolean arguments from the command line.

(s)

Source from the content-addressed store, hash-verified

179
180
181def bool_flag(s):
182 """
183 Parse boolean arguments from the command line.
184 """
185 FALSY_STRINGS = {"off", "false", "0"}
186 TRUTHY_STRINGS = {"on", "true", "1"}
187 if s.lower() in FALSY_STRINGS:
188 return False
189 elif s.lower() in TRUTHY_STRINGS:
190 return True
191 else:
192 raise argparse.ArgumentTypeError("invalid value for a boolean flag")
193
194
195def fix_random_seeds(seed=31):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected