MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _strtobool

Function _strtobool

monai/utils/misc.py:81–96  ·  view source on GitHub ↗

Replaces deprecated (pre python 3.12) distutils strtobool function. True values are y, yes, t, true, on and 1; False values are n, no, f, false, off and 0. Raises ValueError if val is anything else.

(val: str)

Source from the content-addressed store, hash-verified

79
80
81def _strtobool(val: str) -> bool:
82 """
83 Replaces deprecated (pre python 3.12)
84 distutils strtobool function.
85
86 True values are y, yes, t, true, on and 1;
87 False values are n, no, f, false, off and 0.
88 Raises ValueError if val is anything else.
89 """
90 val = val.lower()
91 if val in ("y", "yes", "t", "true", "on", "1"):
92 return True
93 elif val in ("n", "no", "f", "false", "off", "0"):
94 return False
95 else:
96 raise ValueError(f"invalid truth value {val}")
97
98
99_seed = None

Callers 1

list_to_dictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…