#NEWLINE# @ np . deprecate ( message = 'mstats.threshold is deprecated in scipy 0.17.0' ) #NEWLINE# def threshold( a , threshmin = None , threshmax = None , newval = 0 ) : #NEWLINE# #INDENT# '\n    Clip array to a given value.\n\n    Similar to numpy.clip(), except that values less than `threshmin` or\n    greater than `threshmax` are replaced by `newval`, instead of by\n    `threshmin` and `threshmax` respectively.\n\n    Parameters\n    ----------\n    a : ndarray\n        Input data\n    threshmin : {None, float}, optional\n        Lower threshold. If None, set to the minimum value.\n    threshmax : {None, float}, optional\n        Upper threshold. If None, set to the maximum value.\n    newval : {0, float}, optional\n        Value outside the thresholds.\n\n    Returns\n    -------\n    threshold : ndarray\n        Returns `a`, with values less then `threshmin` and values greater\n        `threshmax` replaced with `newval`.\n\n    ' #NEWLINE# a = ma . array ( a , copy = True ) #NEWLINE# mask = np . zeros ( a . shape , dtype = bool ) #NEWLINE# if ( threshmin is not None ) : #NEWLINE# #INDENT# mask |= ( a < threshmin ) . filled ( False ) #NEWLINE# #UNINDENT# if ( threshmax is not None ) : #NEWLINE# #INDENT# mask |= ( a > threshmax ) . filled ( False ) #NEWLINE# #UNINDENT# a [ mask ] = newval #NEWLINE# return a