mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-10-03 12:50:15 +08:00
* fixed distutil parsing * fixed distutil parsing * Apply suggestions from code review * log * fixed distutil parsing * fixed distutil parsing * fixed distutil parsing * fixed distutil parsing * doctest * fixed hparams section * fixed hparams section * fixed hparams section * formatting Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> Co-authored-by: J. Borovec <jirka.borovec@seznam.cz>
21 lines
636 B
Python
21 lines
636 B
Python
def strtobool(val):
|
|
"""Convert a string representation of truth to true (1) or false (0).
|
|
Copied from the python implementation distutils.utils.strtobool
|
|
|
|
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.
|
|
|
|
>>> strtobool('YES')
|
|
1
|
|
>>> strtobool('FALSE')
|
|
0
|
|
"""
|
|
val = val.lower()
|
|
if val in ('y', 'yes', 't', 'true', 'on', '1'):
|
|
return 1
|
|
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
|
return 0
|
|
else:
|
|
raise ValueError(f'invalid truth value {val}')
|