def hard_sigmoid(x, zero_bound, one_bound):
    """
    Apply a piecewise linear sigmoid function.

    Parameters
    ----------
    x : array-like
        Array containing elements to clip
    zero_bound, one_bound : scalar, array-like, or None
        Inflection points of the piecewise linear sigmoid
        function.

    Returns
    -------
    clipped_array : array-like
    """
    if zero_bound < one_bound:
        if x <= zero_bound:
            return 0.0
        if x >= one_bound:
            return 1.0
        return (x - zero_bound) / (one_bound - zero_bound)
    else:
        if x >= zero_bound:
            return 0.0
        if x <= one_bound:
            return 1.0
        return (zero_bound - x) / (zero_bound - one_bound)