[SciPy-Dev] scipy.stats.signaltonoise docstring
Robert Kern
robert.kern@gmail....
Tue Jun 15 00:52:36 CDT 2010
On Tue, Jun 15, 2010 at 00:47, David Goldsmith <d.l.goldsmith@gmail.com> wrote:
> Hi, folks! The docstring for scipy.stats.stats.signaltonoise says that if
> axis == None, the input is first ravel'd, but I see no code that does this;
> here's the code:
>
> def signaltonoise(a, axis=0, ddof=0):
>
> """..."""
> a = np.asanyarray(a)
> m = a.mean(axis)
> sd = a.std(axis=axis, ddof=ddof)
> return np.where(sd == 0, 0, m/sd)
>
>
> Even though it's not surrounded by an "if axis is None:", I checked the
> docstring for asanyarray anyway, and there's nothing there about
> raveling. So, what gives?
axis=None also ravels for the .mean() and .std() methods. Since the
rest of the function doesn't touch the input except through the
results of those methods, the function as a whole treats axis=None as
raveling.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-Dev
mailing list