Convert a string to a boolean. Supported true values: 'yes', 'true', 't', 'y', '1' Supported false values: 'no', 'false', 'f', 'n', '0' Args: v (str): String to convert. Returns: bool: Converted boolean value. Raises: argparse.ArgumentTypeError: I
(v)
| 92 | |
| 93 | |
| 94 | def str2bool(v): |
| 95 | """ |
| 96 | Convert a string to a boolean. |
| 97 | |
| 98 | Supported true values: 'yes', 'true', 't', 'y', '1' |
| 99 | Supported false values: 'no', 'false', 'f', 'n', '0' |
| 100 | |
| 101 | Args: |
| 102 | v (str): String to convert. |
| 103 | |
| 104 | Returns: |
| 105 | bool: Converted boolean value. |
| 106 | |
| 107 | Raises: |
| 108 | argparse.ArgumentTypeError: If the value cannot be converted to boolean. |
| 109 | """ |
| 110 | if isinstance(v, bool): |
| 111 | return v |
| 112 | v_lower = v.lower() |
| 113 | if v_lower in ('yes', 'true', 't', 'y', '1'): |
| 114 | return True |
| 115 | elif v_lower in ('no', 'false', 'f', 'n', '0'): |
| 116 | return False |
| 117 | else: |
| 118 | raise argparse.ArgumentTypeError('Boolean value expected (True/False)') |
| 119 | |
| 120 | import safetensors.torch |
| 121 | import logging |
nothing calls this directly
no outgoing calls
no test coverage detected