Skip to content

a possible MA regression #7509

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

Closed
ev-br opened this issue Apr 5, 2016 · 4 comments
Closed

a possible MA regression #7509

ev-br opened this issue Apr 5, 2016 · 4 comments

Comments

@ev-br
Copy link
Contributor

ev-br commented Apr 5, 2016

scipy tests started failing today with numpy from travis-dev-wheels.
The failure is in mstats: https://travis-ci.org/scipy/scipy/builds/120882377

The failing test does this:

In [1]: from scipy.stats import mstats

In [2]: %paste
        x = [1, 3, 5, 7, 9]
        y = [2, 4, 6, 8, 10]
## -- End pasted text --

In [3]: mstats.kruskal(x, y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-5edb46bc91da> in <module>()
----> 1 mstats.kruskal(x, y)

/home/br/virtualenvs/np/local/lib/python2.7/site-packages/scipy/stats/mstats_basic.pyc in kruskal(*args)
   1047     ngrp = ranks.count(-1)
   1048     ntot = ranks.count()
-> 1049     H = 12./(ntot*(ntot+1)) * (sumrk**2/ngrp).sum() - 3*(ntot+1)
   1050     # Tie correction
   1051     ties = count_tied_groups(ranks)

/home/br/repos/numpy/build/testenv/lib/python2.7/site-packages/numpy/ma/core.pyc in __truediv__(self, other)
   3983         if self._delegate_binop(other):
   3984             return NotImplemented
-> 3985         return true_divide(self, other)
   3986 
   3987     def __rtruediv__(self, other):

/home/br/repos/numpy/build/testenv/lib/python2.7/site-packages/numpy/ma/core.pyc in __call__(self, a, b, *args, **kwargs)
   1126         # Get the result
   1127         with np.errstate(divide='ignore', invalid='ignore'):
-> 1128             result = self.f(da, db, *args, **kwargs)
   1129         # Get the mask as a combination of the source masks and invalid
   1130         m = ~umath.isfinite(result)

ValueError: operands could not be broadcast together with shapes (2,) (2,5) 

and bisecting indicates

$ git bisect bad
36f76ea2e6e91062df12d3a46ccaed7822bc82f2 is the first bad commit
commit 36f76ea2e6e91062df12d3a46ccaed7822bc82f2
Author: Allan Haldane <allan.haldane@gmail.com>
Date:   Sun Feb 14 02:49:19 2016 -0500

    ENH: add extra kwargs and update doc of many MA methods

    Updated any, all, sum, prod, cumsum, cumprod, min, max, argmin, argmax,
    mean, var

:040000 040000 e41cfd58bb4bbabc11471a0bd443b24be91b45d0 7f99716492632508bc4d664d424c7cf22d6cd5cb M  numpy

which is, it seems, gh-5706?

@seberg
Copy link
Member

seberg commented Apr 5, 2016

@ahaldane can you have a look?

EDIT: I could even imagine that it is a scipy bug working around a not working keepdims, in which case we would have to see what the best solution is.

@seberg
Copy link
Member

seberg commented Apr 5, 2016

But this is cool that we now notice this stuff very soon :).

@ahaldane
Copy link
Member

ahaldane commented Apr 5, 2016

I see the bug, it's because my code for count doesn't handle negative axes properly. Eg

>>> a = np.ma.array([[1,2,3], [4,5,6]])
>>> a .count(-1)
array([[3, 3, 3],
       [3, 3, 3]])

@seberg
Copy link
Member

seberg commented Apr 5, 2016

Impressive that we and the test suit missed that ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants