shunwang / numexpr

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

where function with implicit booleans #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following edge cases is not correctly handled by the numexpr 'where' 
function. Basically, implicit booleans (using 1 as True) are not handled as 
they are handled in numpy.

import numexpr as ne
import numpy as np

>> np.where(1, 2, 3)
array(2)

>> ne.evaluate('where(1, 2, 3)')
Traceback (most recent call last):
...
ValueError: too many dimensions

>> a = np.array([1])
>> b = 2
>> c = 3
>> np.where(a, b, c)
array([2])

>> ne.evaluate('where(a, b, c)')
Traceback (most recent call last):
...
NotImplementedError: couldn't find matching opcode for 'where_llll'

Original issue reported on code.google.com by hyuki...@gmail.com on 9 Oct 2011 at 3:15