shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

sum and prod incorrect results #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by duhct...@gmail.com on 11 Apr 2012 at 9:20