numexpr
numexpr copied to clipboard
sum and prod incorrect results
From [email protected] on April 11, 2012 11:20:44
What steps will reproduce the problem? sum and prod produce different results from numpy.sum and numpy.prod when reducing a dimension with a length of 1.
In [639]: c = np.array([[1],[2]])
In [640]: ne.evaluate('sum(c,axis=1)')
Out[640]:
array([[3],
[0]])
In [641]: ne.evaluate('prod(c,axis=1)')
Out[641]:
array([[2],
[1]]) What is the expected output? What do you see instead? I expect the output to match numpy, by eliminating the length 1 dimension but not operating on the data.
In [642]: np.sum(c,axis=1)
Out[642]: array([1, 2])
In [643]: np.prod(c,axis=1)
Out[643]: array([1, 2]) What version of the product are you using? On what operating system? In [644]: ne.version
Out[644]: '2.0.1'
Running on redhat 2.6.18-194.32.1.el5 #1 SMP x86_64.
Original issue: http://code.google.com/p/numexpr/issues/detail?id=79