def makeCoefNameTerm(s, coef, name):
    """ generate a string representation of the (coef, name) pair with an
        appropriate sign connecting the term to preceding terms

    Keyword arguments:

    s    -- string containing the preceding terms (may be empty)
    coef -- coefficient (positive or negative floating-point value)
    name -- name string to be displayed next to coefficient
    """
    if coef == 0.0:
        return ''
    absCoef = abs(coef)
    if absCoef == 1.0:
        absCoefTerm = '%s' % name
    else:
        absCoefTerm = '%r %s' % (absCoef, name)
    if s == '':
        if coef < 0:
            sign = '-'
        else:
            sign = ''
    elif coef < 0:
        sign = ' - '
    else:
        sign = ' + '
    return sign + absCoefTerm
