scipy.stats.mstats.kurtosistest crashes on 1d input (Trac #1661) #2186

Closed
scipy-gitbot opened this Issue Apr 25, 2013 · 2 comments

Projects

None yet

2 participants

@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1661 on 2012-05-21 by @dougalsutherland, assigned to unknown.

For example,

>>> stats.mstats.kurtosistest(np.random.normal(size=(100,)))
Traceback (most recent call last):
  File "<ipython-input-11-570df841a764>", line 1, in <module>
    stats.mstats.kurtosistest(np.random.normal(size=(100,)))
  File "/Library/Python/2.7/site-packages/scipy-0.10.1-py2.7-macosx-10.7-x86_64.egg/scipy/stats/mstats_basic.py", line 1628, in kurtosistest
    n = a.count(axis=axis).astype(float)
AttributeError: 'int' object has no attribute 'astype'

This is because ma.count sometimes returns an integer. One possible fix would be to change that line to:

    n = np.asanyarray(a.count(axis=axis), dtype=float)
@scipy-gitbot

trac user bdieseldorff wrote on 2012-07-26

After the fix suggested by dougal, the line that reads
denom[denom < 0] = masked
also needs to be changed. In particular, it should be skipped entirely if you have a single float value instead of an array (or maybe give a warning if the only value would get masked?).

@rgommers
SciPy member

Fixed by gh-3008.

@rgommers rgommers closed this Nov 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment