sherpa.utils.bool_cast(val)[source] [edit on github]

Convert a string to a boolean.


val (bool, str or sequence) – The input value to decode.


flag – True or False if val is considered to be a true or false term. If val is a sequence then the return value is an ndarray of the same size.

Return type:

bool or ndarray


The string is compared in a case-insensitive manner to the following: ‘true’, ‘on’, ‘yes’, ‘1’, ‘t’, and ‘y’ for True and ‘false’, ‘off’, ‘no’, ‘0’, ‘f’, and ‘n’ for False.

If there is no match to the above then the default conversion provided by the bool routine is used.