def validate_dpi(s):
    """confirm s is string 'figure' or convert s to float or raise"""
    if s == 'figure':
        return s
    try:
        return float(s)
    except ValueError:
        raise ValueError('"%s" is not string "figure" or'
            ' could not convert "%s" to float' % (s, s))