wrapcauchy _cdf IndexError (Trac #1185) #1712

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


None yet
3 participants

Original ticket http://projects.scipy.org/scipy/ticket/1185 on 2010-05-29 by @josef-pkt, assigned to unknown.

wrapcauchy._cdf is the only _cdf _pdf function that cannot handle a array x and a scalar shape parameter

valp = extract(c1,val) c1 has shape of x, val has shape of c

handling this case is not a requirement, but since it is the only function for which this doesn't work, it should be fixed

e.g. broadcast val or c to shape of x,

val = np.ones_like(x) * val #if this works;

common trick in distributions is (x==x)*val

>>> stats.wrapcauchy._cdf(np.array([1,2,3.]), np.array(0.031))
Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    stats.wrapcauchy._cdf(np.array([1,2,3.]), np.array(0.031))
  File "C:\Josef\_progs\Subversion\scipy-trunk_after\trunk\dist\scipy-0.8.0.dev6416.win32\Programs\Python25\Lib\site-packages\scipy\stats\distributions.py", line 3801, in _cdf
    valp = extract(c1,val)
  File "C:\Programs\Python25\lib\site-packages\numpy\lib\function_base.py", line 1288, in extract
    return _nx.take(ravel(arr), nonzero(ravel(condition))[0])
  File "C:\Programs\Python25\lib\site-packages\numpy\core\fromnumeric.py", line 103, in take
    return take(indices, axis, out, mode)
IndexError: index out of range for array

>>> stats.wrapcauchy._cdf(np.array([1,2,3.]), np.array([0.031]*3))
array([ 0.16759771,  0.32716591,  0.47881587])

ev-br commented Sep 9, 2013

Seems to work in the current master:

In [67]: stats.wrapcauchy._cdf(np.array([1,2,3.]), 0.31)
Out[67]: array([ 0.2558092 ,  0.39619105,  0.48811598])

In [68]: stats.wrapcauchy.cdf(np.array([1,2,3.]), 0.31)
Out[68]: array([ 0.2558092 ,  0.39619105,  0.48811598])

In [69]: scipy.__version__
Out[69]: '0.14.0.dev-efbde60'

argriffing commented Sep 9, 2013

Works for me too.

@argriffing argriffing closed this Sep 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment