def minmax_scale(array, ranges=(0., 1.)):
    """
    normalize to [min, max], default is [0., 1.]
    :param array: ndarray
    :param ranges: tuple, (min, max)
    :return:
    """
    _min = ranges[0]
    _max = ranges[1]
    return (_max - _min) * (array - array.min()) / (array.max() - array.min()) + _min