MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / str_to_bool

Function str_to_bool

diffusers/src/diffusers/utils/testing_utils.py:158–169  ·  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

156# Taken from the following PR:
157# https://github.com/huggingface/accelerate/pull/1964
158def str_to_bool(value) -> int:
159 """
160 Converts a string representation of truth to `True` (1) or `False` (0). True values are `y`, `yes`, `t`, `true`,
161 `on`, and `1`; False value are `n`, `no`, `f`, `false`, `off`, and `0`;
162 """
163 value = value.lower()
164 if value in ("y", "yes", "t", "true", "on", "1"):
165 return 1
166 elif value in ("n", "no", "f", "false", "off", "0"):
167 return 0
168 else:
169 raise ValueError(f"invalid truth value {value}")
170
171
172def parse_flag_from_env(key, default=False):

Callers 2

parse_flag_from_envFunction · 0.90
parse_flag_from_envFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected