8000 bug in apply_along_axis with empty arrays · Issue #6927 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
bug in apply_along_axis with empty arrays #6927
Closed
@rgommers

Description

@rgommers

Still present in numpy 1.10.2:

In [47]: a = np.ones((0, 2))

In [48]: np.sum(a, axis=0)
Out[48]: array([ 0.,  0.])

In [49]: np.sum(a, axis=1)
Out[49]: array([], dtype=float64)

In [50]: np.apply_along_axis(np.sum, axis=0, arr=a)
Out[50]: array([ 0.,  0.])

In [51]: np.apply_along_axis(np.sum, axis=1, arr=a)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-51-c8275650df94> in <module>()
----> 1 np.apply_along_axis(np.sum, axis=1, arr=a)

/home/rgommers/.local/lib/python2.7/site-packages/numpy/lib/shape_base.pyc in apply_along_axis(func1d, axis, arr, *args, **kwargs)
     89     outshape = asarray(arr.shape).take(indlist)
     90     i.put(indlist, ind)
---> 91     res = func1d(arr[tuple(i.tolist())], *args, **kwargs)
     92     #  if res is a number, then we have a smaller output array
     93     if isscalar(res):

IndexError: index 0 is out of bounds for ax

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0