Skip to content

Commit

Permalink
DEP: deprecate scipy.stats.signaltonoise
Browse files Browse the repository at this point in the history
See issue #609
  • Loading branch information
aeklant committed Mar 23, 2015
1 parent f2023bc commit 8a6e358
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions doc/release/0.16.0-notes.rst
Expand Up @@ -101,6 +101,11 @@ with ``statsmodels.distributions.ExpandedNormal``.
``scipy.stats.fastsort`` is deprecated. This function is unnecessary,
``numpy.argsort`` can be used instead.

``scipy.stats.signaltonoise`` is deprecated. This function did not belong in
``scipy.stats`` and is rarely used. See issue #609 for details.

``scipy.stats.histogram2`` is deprecated. This function is unnecessary,
``numpy.histogram2d`` can be used instead.

Backwards incompatible changes
==============================
Expand Down
5 changes: 3 additions & 2 deletions scipy/stats/stats.py
Expand Up @@ -953,14 +953,14 @@ def moment(a, moment=1, axis=0):
else:
current_n /= 2
n_list.append(current_n)

# Starting point for exponentiation by squares
a_zero_mean = a - np.expand_dims(np.mean(a, axis), axis)
if n_list[-1] == 1:
s = a_zero_mean.copy()
else:
s = a_zero_mean**2

# Perform multiplications
for n in n_list[-2::-1]:
s = s**2
Expand Down Expand Up @@ -1928,6 +1928,7 @@ def obrientransform(*args):
return np.array(arrays, dtype=dt)


@np.deprecate(message="scipy.stats.signaltonoise is deprecated in scipy 0.16.0")
def signaltonoise(a, axis=0, ddof=0):
"""
The signal-to-noise ratio of the input data.
Expand Down
10 changes: 6 additions & 4 deletions scipy/stats/tests/test_stats.py
Expand Up @@ -1263,8 +1263,10 @@ def test_signaltonoise(self):

# y = stats.signaltonoise(self.shoes[0])
# assert_approx_equal(y,4.5709967)
y = stats.signaltonoise(self.testcase)
assert_approx_equal(y,2.236067977)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
y = stats.signaltonoise(self.testcase)
assert_approx_equal(y, 2.236067977)

def test_sem(self):
# This is not in R, so used:
Expand Down Expand Up @@ -1427,13 +1429,13 @@ def test_kurtosis(self):

def test_kurtosis_array_scalar(self):
assert_equal(type(stats.kurtosis([1,2,3])), float)

def test_moment_accuracy(self):
# 'moment' must have a small enough error compared to the slower
# but very accurate numpy.power() implementation.
tc_no_mean = self.testcase_moment_accuracy - \
np.mean(self.testcase_moment_accuracy)
assert_allclose(np.power(tc_no_mean, 42).mean(),
assert_allclose(np.power(tc_no_mean, 42).mean(),
stats.moment(self.testcase_moment_accuracy, 42))


Expand Down

0 comments on commit 8a6e358

Please sign in to comment.