#NEWLINE# def rescale_arr( arr , amin , amax ) : #NEWLINE# #INDENT# 'Rescale an array to a new range.\n\n    Return a new array whose range of values is (amin,amax).\n\n    Parameters\n    ----------\n    arr : array-like\n\n    amin : float\n      new minimum value\n\n    amax : float\n      new maximum value\n\n    Examples\n    --------\n    >>> a = np.arange(5)\n\n    >>> rescale_arr(a,3,6)\n    array([ 3.  ,  3.75,  4.5 ,  5.25,  6.  ])\n    ' #NEWLINE# m = arr . min ( ) #NEWLINE# M = arr . max ( ) #NEWLINE# s = ( float ( ( amax - amin ) ) / ( M - m ) ) #NEWLINE# d = ( amin - ( s * m ) ) #NEWLINE# return np . clip ( ( ( s * arr ) + d ) , amin , amax )