def f(self, X):
        x = X.flatten()
        y = x.copy()

        #first adjus the points below the first value
        y[x<self.sorted_breaks[0]]  = x[x<self.sorted_breaks[0]] + self.sorted_values[0] - self.sorted_breaks[0]

        #now all the points pas the last break
        y[x>self.sorted_breaks[-1]]  = x[x>self.sorted_breaks[-1]] + self.sorted_values[-1] - self.sorted_breaks[-1]

        #loop throught the pairs of points
        for low, up, g, v in zip(self. sorted_breaks[:-1], self.sorted_breaks[1:], self.grads, self.sorted_values[:-1]):
            i = np.logical_and(x>low, x<up)
            y[i] = v + (x[i]-low)*g

        return y.reshape(-1,1)
dataset/ETHPy150Open SheffieldML/GPy/GPy/mappings/piecewise_linear.py/PiecewiseLinear.f/original