is_str_float¶
- pyrcs.utils.is_str_float(x, finite_only=False)[source]¶
Checks if a string represents and can be converted to a finite float value.
This function attempts to convert the input to a float. It returns
Falsefor non-numeric strings,Noneinputs, or special floating point values likeNaNorInfinity(optional).- Parameters:
x (str | Any) – String-type data or any object that can be converted to float.
finite_only (bool) – Whether to return
Falsefor special values such asNaNandInfinity; defaults toFalse.
- Returns:
Trueif the string represents a valid finite number,Falseotherwise.- Return type:
bool
Examples:
>>> from pyrcs.utils import is_str_float >>> is_str_float('') False >>> is_str_float('a') False >>> is_str_float('1') True >>> is_str_float('1.1') True >>> is_str_float('nan', finite_only=True) False >>> is_str_float('inf') True