MCPcopy Create free account
hub / github.com/JuliaWolleb/diffusion-anomaly / str2bool

Function str2bool

guided_diffusion/script_util.py:464–475  ·  view source on GitHub ↗

https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse

(v)

Source from the content-addressed store, hash-verified

462
463
464def str2bool(v):
465 """
466 https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
467 """
468 if isinstance(v, bool):
469 return v
470 if v.lower() in ("yes", "true", "t", "y", "1"):
471 return True
472 elif v.lower() in ("no", "false", "f", "n", "0"):
473 return False
474 else:
475 raise argparse.ArgumentTypeError("boolean value expected")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected