#NEWLINE# def threshold_arr( cmat , threshold = 0.0 , threshold2 = None ) : #NEWLINE# #INDENT# 'Threshold values from the input array.\n\n    Parameters\n    ----------\n    cmat : array\n\n    threshold : float, optional.\n      First threshold.\n\n    threshold2 : float, optional.\n      Second threshold.\n\n    Returns\n    -------\n    indices, values: a tuple with ndim+1\n\n    Examples\n    --------\n    >>> np.set_printoptions(precision=4)  # For doctesting\n    >>> a = np.linspace(0,0.2,5)\n    >>> a\n    array([ 0.  ,  0.05,  0.1 ,  0.15,  0.2 ])\n    >>> threshold_arr(a,0.1)\n    (array([3, 4]), array([ 0.15,  0.2 ]))\n\n    With two thresholds:\n    >>> threshold_arr(a,0.1,0.2)\n    (array([0, 1]), array([ 0.  ,  0.05]))\n    ' #NEWLINE# if ( threshold2 is None ) : #NEWLINE# #INDENT# th_low = ( - np . inf ) #NEWLINE# th_hi = th_low #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# th_low = threshold #NEWLINE# th_hi = threshold2 #NEWLINE# #UNINDENT# idx = np . where ( ( ( cmat < th_low ) | ( cmat > th_hi ) ) ) #NEWLINE# vals = cmat [ idx ] #NEWLINE# return ( idx + ( vals , ) )