MCPcopy Index your code
hub / github.com/huggingface/diffusers / str_to_bool

Function str_to_bool

tests/testing_utils.py:267–278  ·  view source on GitHub ↗

Converts a string representation of truth to `True` (1) or `False` (0). True values are `y`, `yes`, `t`, `true`, `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;

(value)

Source from the content-addressed store, hash-verified

265# Taken from the following PR:
266# https://github.com/huggingface/accelerate/pull/1964
267def str_to_bool(value) -> int:
268 """
269 Converts a string representation of truth to `True` (1) or `False` (0). True values are `y`, `yes`, `t`, `true`,
270 `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
271 """
272 value = value.lower()
273 if value in ("y", "yes", "t", "true", "on", "1"):
274 return 1
275 elif value in ("n", "no", "f", "false", "off", "0"):
276 return 0
277 else:
278 raise ValueError(f"invalid truth value {value}")
279
280
281def parse_flag_from_env(key, default=False):

Callers 2

parse_flag_from_envFunction · 0.70
parse_flag_from_envFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…