def try_float(s, default=None, minimum=None):
    """ Try parsing a string into a float.
        If None is passed, default is returned.
        On failure, InvalidFloat is raised.
    """
    if not s:
        return default
    try:
        val = float(s)
    except (TypeError, ValueError):
        raise InvalidNumber(s, label='Invalid float value')
    if (minimum is not None) and (val < minimum):
        val = minimum
    return val
Try parsing a string into a float.
        If None is passed, default is returned.
        On failure, InvalidFloat is raised.