numexpr
numexpr copied to clipboard
sum returns wrong shape for arrays with a zero dimension
When summing over an array that contains a dimension with length zero, numexpr.sum
fails to reduce the dimensions and instead returns a result with the same shape as the input. This behaviour is inconsistent with core Python:
In [142]: z = empty(shape=(0, 10))
In [143]: numpy.sum(z, 1).shape
Out[143]: (0,)
In [144]: numexpr.evaluate("sum(z, 1)").shape
Out[144]: (0, 10)