
Hello all, As part of the ongoing scipy.stats improvements we are pondering the deprecation of `stats.threshold` (and its masked array counterpart: `mstats.threshold`) for the following reasons. - The functionality it provides is nearly identical to `np.clip`. - Its usage does not seem to be common (Ralf made a search with searchcode <https://searchcode.com/>; it is not used in scipy as a helper function either). Of course, before we deprecate anything, we would like to know if anyone in the community is a regular user of this function and/or if you guys may have a use case where it may be preferable to use `stats.threshold` over `np.clip`. Please reply if you have any objections to this deprecation. You can find the corresponding PR here: gh-4976 <https://github.com/scipy/scipy/pull/4976> Regards, Abraham. PS. For reference, both `np.clip` and `stats.threshold` replace the values outside a threshold from an array_like input. The difference is that `stats.threshold` replaces all values below the minimum or above the maximum with the same new value whereas `np.clip` uses the minimum to replace those below and the maximum for those above. Example:
a = np.arange(10)
a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
np.clip(a, 3, 7)
array([3, 3, 3, 3, 4, 5, 6, 7, 7, 7])
stats.threshold(a, 3, 7, -1)
array([-1, -1, -1, 3, 4, 5, 6, 7, -1, -1])