netrd/utilities/threshold.py
def threshold_in_range(mat, cutoffs=[(-1, 1)]):
    """
    Threshold a numpy array by setting values not within a list of ranges to zero.

    Params
    ------
    mat: (np.ndarray): A numpy array.
    cutoffs (list of tuples): When thresholding, include only edges whose
    correlations fall within a given range or set of ranges. The lower
    value must come first in each tuple. For example, to keep those values whose absolute
    value is between 0.5 and 1, pass `cutoffs=[(-1, -0.5), (0.5, 1)]`

    Returns
    -------
    thresholded_mat: the thresholded numpy array

    """

    mask_function = np.vectorize(lambda x: any([x>=cutoff[0] and x<=cutoff[1] for cutoff in cutoffs]))
    mask = mask_function(mat)

    thresholded_mat = mat * mask
    return thresholded_mat

    Threshold a numpy array by setting values not within a list of ranges to zero.

    Params
    ------
    mat: (np.ndarray): A numpy array.
    cutoffs (list of tuples): When thresholding, include only edges whose
    correlations fall within a given range or set of ranges. The lower
    value must come first in each tuple. For example, to keep those values whose absolute
    value is between 0.5 and 1, pass `cutoffs=[(-1, -0.5), (0.5, 1)]`

    Returns
    -------
    thresholded_mat: the thresholded numpy array

    
Threshold a numpy array by setting values not within a list of ranges to zero.
Params



Returns

the thresholded numpy array
Threshold a numpy array by setting values not within a list of ranges to zero . Params Returns the thresholded numpy array
def threshold_in_range(mat, cutoffs=[(-1, 1)]):
    mask_function = np.vectorize(lambda x: any([x>=cutoff[0] and x<=cutoff[1] for cutoff in cutoffs]))
    mask = mask_function(mat)
    thresholded_mat = mat * mask
    return thresholded_mat
def threshold_in_range ( mat , cutoffs = [ ( - 1 , 1 ) ] ) : mask_function = np . vectorize ( lambda x : any ( [ x >= cutoff [ 0 ] and x <= cutoff [ 1 ] for cutoff in cutoffs ] ) ) mask = mask_function ( mat ) thresholded_mat = mat * mask return thresholded_mat
Threshold a numpy array by setting values not within a list of ranges to zero.
Threshold a numpy array by setting values not within a list of ranges to zero .
"""
    Threshold a numpy array by setting values not within a list of ranges to zero.

    Params
    ------
    mat: (np.ndarray): A numpy array.
    cutoffs (list of tuples): When thresholding, include only edges whose
    correlations fall within a given range or set of ranges. The lower
    value must come first in each tuple. For example, to keep those values whose absolute
    value is between 0.5 and 1, pass `cutoffs=[(-1, -0.5), (0.5, 1)]`

    Returns
    -------
    thresholded_mat: the thresholded numpy array

    """
mat
cutoffs