[SciPy-User] nanmedian chokes on size zero arrays

Jonathan Guyer guyer at nist.gov
Wed Mar 2 17:35:26 EST 2011


On Mar 2, 2011, at 1:06 PM, Keith Goodman wrote:

> On Wed, Mar 2, 2011 at 12:27 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>> While fixing Bottleneck functions that can't handle size zero arrays
>> of various shapes, I noticed that scipy.stats.nanmedian chokes on
>> certain size zero arrays and axis combinations:
>> 
>>>> from scipy.stats import nanmedian
>>>> a = np.ones((0,2))
>>>> np.median(a, 1)
>>   array([], dtype=float64)
>>>> nanmedian(a, 1)
>> <snip>
>> IndexError: invalid index
>> 
>> Anyone know a fix? Here's the ticket:
>> http://projects.scipy.org/scipy/ticket/1400
> 
> I guess the bug is in np.apply_along_axis:
> 
>>> np.apply_along_axis(np.sum, 1, np.ones((0,2)))
> <snip>
> IndexError: invalid index


Might be related to 

http://projects.scipy.org/numpy/ticket/1171




More information about the SciPy-User mailing list