def _lval_add_towards_polarity(x, polarity):
    """Compute the appropriate Lval "kind" for the limit of value `x` towards
    `polarity`. Either 'toinf' or 'pastzero' depending on the sign of `x` and
    the infinity direction of polarity.

    """
    if x < 0:
        if polarity < 0:
            return Lval('toinf', x)
        return Lval('pastzero', x)
    elif polarity > 0:
        return Lval('toinf', x)
    return Lval('pastzero', x)