Return a driver function that can advance a sequence of linear values.

    .. code-block:: none

        value = m * i + b

    Args:
        m (float) : a slope for the linear driver
        x (float) : an offset for the linear driver
436358
def linear(m=1, b=0):
    ''' 

    '''
    def f(i):
        return m * i + b
    return partial(force, sequence=_advance(f))
581447
def black(m):
    

    m = float(m)

    def f(x):
        if x <= m:
            return 0.0
        return (x - m) / (1.0 - m)
    return f
1309704
def driveFunction(self):
        

        if self.function == 'HELP':
            # General help for all functions.
            self.printLn("N", "")
            self.printLn("N", "Usage:")
            self.printLn("N", "  python " + self.cmdName + " --help")
            for key in sorted(ReqHandle.funcHandler):
                ReqHandle.funcHandler[key][0](self)
            self.printLn("N", "")
            self.printLn("N", "Operand(s):")
            for key in sorted(ReqHandle.funcHandler):
                ReqHandle.funcHandler[key][1](self)
            self.printLn("N", "")
            self.updateResults({}, reset=1)
        elif self.function == 'VERSION':
            # Version of ReqHandle.
            self.printLn("N", "Version: " + version)
            self.updateResults({}, reset=1)
        else:
            # Some type of function/subfunction invocation.
            if self.function in self.funcHandler:
                # Invoke the functions doIt routine to route to the
                # appropriate subfunction.
                self.funcHandler[self.function][3](self)
            else:
                # Unrecognized function
                msg = msgs.msg['0007'][1] % (modId, self.function)
                self.printLn("ES", msg)
                self.updateResults(msgs.msg['0007'][0])

        return self.results
379131
def linear_scheduler_up(init_value, target_value, duration):
    

    value = init_value
    t = 0
    while True:
        yield value
        t += 1
        if t < duration:
            value = init_value + t * (target_value - init_value) / duration
        else:
            value = target_value
863795
def cmd_velocity(self, args):
        ''''''
        if (len(args) != 3):
            print("Usage: velocity x y z (m/s)")
            return

        if (len(args) == 3):
            x_mps = float(args[0])
            y_mps = float(args[1])
            z_mps = float(args[2])
            #print("x:%f, y:%f, z:%f" % (x_mps, y_mps, z_mps))

            self.master.mav.set_position_target_local_ned_send(
                0,       # time_boot_ms (not used)
                0, 0,    # target system, target component
                mavutil.mavlink.MAV_FRAME_LOCAL_NED, # frame
                0b0000111111000111, # type_mask (only speeds enabled)
                0, 0, 0, # x, y, z positions (not used)
                x_mps, y_mps, -z_mps, # x, y, z velocity in m/s
                0, 0, 0, # x, y, z acceleration (not supported yet, ignored in GCS_Mavlink)
                0, 0)
284425
def _mdens(self,m):
        """"""
        return (self.a/m)**self.alpha/(1.+m/self.a)**(self.betaminusalpha)
1065952
def get_interpolated_value(self, x):
        
        if len(self.ydim) == 1:
            return get_linear_interpolated_value(self.x, self.y, x)
        else:
            return [get_linear_interpolated_value(self.x, self.y[:, k], x)
                    for k in range(self.ydim[1])]
599835
def linear(self, limits=None, k=5):
        """"""
        start, stop = limits or (self.minval, self.maxval)
        return np.linspace(start, stop, k)
386102
def _lmder1_linear_full_rank(n, m, factor, target_fnorm1, target_fnorm2):
    """"""

    def func(params, vec):
        s = params.sum()
        temp = 2. * s / m + 1
        vec[:] = -temp
        vec[:params.size] += params

    def jac(params, jac):
        # jac.shape = (n, m) by LMDER standards
        jac.fill(-2. / m)
        for i in range(n):
            jac[i,i] += 1

    guess = np.ones(n) * factor

    #_lmder1_test(m, func, jac, guess)
    _lmder1_driver(m, func, jac, guess,
                   target_fnorm1, target_fnorm2,
                   [-1] * n)
903302
def _hammer_function_precompute(self,x0, L, Min, model):
        
        if x0 is None: return None, None
        if len(x0.shape)==1: x0 = x0[None,:]
        m = model.predict(x0)[0]
        pred = model.predict(x0)[1].copy()
        pred[pred<1e-16] = 1e-16
        s = np.sqrt(pred)
        r_x0 = (m-Min)/L
        s_x0 = s/L
        r_x0 = r_x0.flatten()
        s_x0 = s_x0.flatten()
        return r_x0, s_x0
340863
def aax(mt, x, m=1):
    
    return mt.Nx[x] / mt.Dx[x] - (float(m - 1) / float(m * 2))
224383
def XstarT_dot(self,M):
        
        if 0:
            #TODO: implement this properly
            pass
        else:
            RV = np.dot(self.Xstar().T,M)
        return RV
820467
def get_Z(x_segment, y_segment, x_int, y_int, slope):
    
    Z = 0
    first_time = True
    for num, x in enumerate(x_segment):
        b_wiggle = get_b_wiggle(x, y_segment[num], y_int)
        z = old_div((x * abs(b_wiggle - abs(slope)) ), abs(x_int))
        Z += z
        first_time = False
    return Z
977177
def defValueFuncs(self):
        '''
        
        '''
        MPCnvrs      = self.MPC**(-self.CRRA/(1.0-self.CRRA))
        vFuncNvrs    = LinearInterp(np.array([self.mNrmMin, self.mNrmMin+1.0]),np.array([0.0, MPCnvrs]))
        self.vFunc   = ValueFunc(vFuncNvrs,self.CRRA)
        self.vPfunc  = MargValueFunc(self.cFunc,self.CRRA)
706755
def admm_linearized_simple(x, f, g, L, tau, sigma, niter, **kwargs):
    
    callback = kwargs.pop('callback', None)
    z = L.range.zero()
    u = L.range.zero()
    for _ in range(niter):
        x[:] = f.proximal(tau)(x - tau / sigma * L.adjoint(L(x) + u - z))
        z = g.proximal(sigma)(L(x) + u)
        u = L(x) + u - z
        if callback is not None:
            callback(x)
1239871
def linear_model(x, y):
        
        x1, x2 = x
        y1, y2 = y
        m = (y2 - y1) / (x2 - x1)
        b = y1 - (m * x1)
        return lambda x: m * x + b
286407
def apply(self, im):
        
        from scipy.ndimage.interpolation import shift
        return shift(im, map(lambda x: -x, self.delta), mode='nearest')