On Thu, Jun 18, 2015 at 3:04 PM, Todd <toddrjen@gmail.com> wrote:
On Wed, Jun 17, 2015 at 10:44 PM, Abraham Escalante <aeklant@gmail.com> wrote:
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; 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

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.


Would it be possible to add an optional argument to `np.clip` to allow it to support the `stats.threshold` use-case?

Adding a keyword after out=None in np.clip would be slightly ugly, but it's possible and may make sense.

Ralf