def applyLookupTable(data, lut):
 if (data.dtype.kind not in ('i', 'u')):
  data = data.astype(int)
 return np.take(lut, data, axis=0, mode='clip')

def applyLookupTable ( data , lut ) : if ( data . dtype . kind not in ( 'i' , 'u' ) ) : data = data . astype ( int ) return np . take ( lut , data , axis = 0 , mode = 'clip' )
uses values in *data* as indexes to select values from *lut* .