Open
Description
When passed an object that isn't array-like, numpy.sum returns that object. This is surprising behavior. Maybe it is consistent with interpreting the input as a scalar, but it is surprising when the input is iterable. E.g.
class A(object):
pass
a = A()
np.sum(a) # returns `a`
Note that this occurs even for iterables, e.g.
class A(object):
def __getitem__(self, index):
if index > 3:
raise IndexError("that's enough!")
return index
a = A()
np.sum(a) # returns `a`
Metadata
Metadata
Assignees
Labels
No labels