def normFeatures( naFeatures, fMin, fMax, bAbsolute, bIgnoreLast=True ):
    
    fNewRange = fMax - fMin
    
    lUseCols = naFeatures.shape[1]
    if bIgnoreLast:
        lUseCols -= 1
    
    ltRet = []
    ''' Loop through all features '''
    for i in range(lUseCols):
        
        ''' If absolutely scaled use exact min and max '''
        if bAbsolute:
            fFeatMin = np.min( naFeatures[:,i] )
            fFeatMax = np.max( naFeatures[:,i] )
        else:
            ''' Otherwise use mean +-1 std deviations for min/max (~94% of data) '''
            fMean = np.average( naFeatures[:,i] )
            fStd = np.std( naFeatures[:,i] ) 
            fFeatMin = fMean - fStd
            fFeatMax = fMean + fStd
            
        ''' Calculate multiplier and shift variable so that new data fits in specified range '''
        fRange = fFeatMax - fFeatMin
        
        if fRange == 0:
            print 'Warning, bad query data range'
            fMult = 1.
            fShigt = 0.
        else:
            fMult = fNewRange / fRange
            fShift = fMin - (fFeatMin * fMult)
        
        ''' scale and shift, save in return array '''
        naFeatures[:,i] *= fMult
        naFeatures[:,i] += fShift
        ltRet.append( (fMult, fShift) )
    
    return ltRet
Removes comments (#...) from python code.
dataset/ETHPy150Open QuantSoftware/QuantSoftwareToolkit/QSTK/qstkfeat/featutil.py/normFeatures--crossover with--dataset/ETHPy150Open adampresley/bottlepy-bootstrap/app/bottle.py/SimpleTemplate.split_comment