def _float_or_none(x, digits=3):
    """ Helper function to format a variable that can be a float or None"""
    if x is None:
        return str(x)
    fmtstr = "{0:.{digits}g}".format(x, digits=digits)
    return fmtstr.format(x)