def scale_to_unit_interval(ndar, eps=1e-08):
 ndar = ndar.copy()
 ndar -= ndar.min()
 ndar *= (1.0 / (ndar.max() + eps))
 return ndar

def scale_to_unit_interval ( ndar , eps = 1e-08 ) : ndar = ndar . copy ( ) ndar -= ndar . min ( ) ndar *= ( 1.0 / ( ndar . max ( ) + eps ) ) return ndar
scales all values in the ndarray ndar to be between 0 and 1 .