shunwang / numexpr

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

floats without decimals are evaluted as integers #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In [10]: i = np.array([1, 2, 3])

In [12]: ne.evaluate('i / 5.0')
Out[12]: array([0, 0, 0])

In [15]: ne.evaluate('5.0')
Out[15]: array(5)

In [16]: ne.evaluate('i / (5.1 - 0.1)')
Out[16]: array([0, 0, 0])

In [17]: ne.evaluate('i / 5.1')
Out[17]: array([ 0.19607843,  0.39215686,  0.58823529])

see issue 58

Original issue reported on code.google.com by gdemen...@gmail.com on 14 Sep 2011 at 7:54

GoogleCodeExporter commented 9 years ago
Fixed in revision e6e1ed96bc2b.

Original comment by fal...@gmail.com on 1 Nov 2011 at 12:48

GoogleCodeExporter commented 9 years ago
A related issue happens when ' a ** -1 ' gets optimized to ' 1 / a '
while the correct form would be ' 1. / a ' and likewise for the optimization ' 
a ** -2 '
The code
  OpNode('div', [ConstantNode(1), r]
and
  OpNode('div', [ConstantNode(1), r]

in expressions.py seems to cause the problem.

Original comment by ka...@ucw.cz on 24 Jan 2012 at 1:28