Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mstats.ttest_rel axis=None, requires masked array #3047

Closed
josef-pkt opened this issue Nov 8, 2013 · 2 comments
Closed

mstats.ttest_rel axis=None, requires masked array #3047

josef-pkt opened this issue Nov 8, 2013 · 2 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.stats
Milestone

Comments

@josef-pkt
Copy link
Member

mstats.ttest_rel has wrong axis default axis=None instead of axis=0
requires masked array if axis=None

ma.ravel does not convert to masked arrays, at least not with numpy 1.6.1

def _chk2_asarray(a, b, axis):
    if axis is None:
        a = ma.ravel(a)
        b = ma.ravel(b)
>>> outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
>>> stats.mstats.ttest_rel(outcome[:, 0], outcome[:, 1:])
Traceback (most recent call last):
  File "<pyshell#30>", line 1, in <module>
    stats.mstats.ttest_rel(outcome[:, 0], outcome[:, 1:])
  File "C:\Programs\Python27\lib\site-packages\scipy\stats\mstats_basic.py", line 782, in ttest_rel
    raise ValueError('unequal length arrays')
ValueError: unequal length arrays

>>> [stats.mstats.ttest_rel(outcome[:, 0], outcome[:, k]) for k in range(1, 4)]
Traceback (most recent call last):
  File "<pyshell#31>", line 1, in <module>
    [stats.mstats.ttest_rel(outcome[:, 0], outcome[:, k]) for k in range(1, 4)]
  File "C:\Programs\Python27\lib\site-packages\scipy\stats\mstats_basic.py", line 785, in ttest_rel
    n = a.count(axis)
AttributeError: 'numpy.ndarray' object has no attribute 'count'
@rgommers
Copy link
Member

The issue with _chk2_asarray I had already fixed in gh-3008.

@rgommers
Copy link
Member

Other issue now also fixed in gh-3008.

andrenarchy pushed a commit to andrenarchy/scipy that referenced this issue Dec 4, 2013
Change default of axis kw to 0 in ttest_rel.  This is OK without warning
because the function didn't work before anyway.

Also provide basic test coverage (comparison against nonmasked version).
Testing with various masked array inputs to be done.

Closes scipygh-3047.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.stats
Projects
None yet
Development

No branches or pull requests

2 participants