返回索引小于numpy数组中的阈值?

时间:2012-05-24 14:58:48

标签: python numpy indexing threshold

numpy中有这些功能的相应方法吗?

def arg_less(inarray,threshold):
    return np.nonzero(inarray<threshold)

def arg_greater(inarray,threshold):
    return np.nonzero(inarray>threshold)

def arg_between(inarray,lowerbound,upperbound):
    if lowerbound>=upperbound:
        raise ValueError('the first argument is lower bound, lower bound bigger than upper bound!')
    else:
        return np.nonzero((inarray>lowerbound)|(inarray<upperbound))

def arg_outside(inarray,lowerbound,upperbound):
    if lowerbound>=upperbound:
        raise ValueError('the first argument is lower bound, lower bound bigger than upper bound!')
    else:
        return np.nonzero((inarray<lowerbound)&(inarray>upperbound))

感谢所有人。

0 个答案:

没有答案