shunwang / numexpr

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

where() does not work with booleans and strings due to check in numexpr.expressions.commonKind #92

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

    a,b,c,d = True, False, "C", "D"
    numexpr.evaluate("where(a>b,c,d)")

What is the expected output? What do you see instead?

Expected:

    c

A TypeError is raised because int the function `numexpr.expressions.commonKind` 
it is checked whether all nodes are type(str) but of course the first node a>b 
will always be of type(bool).

I have created a custom dtype and have in the variables c and d a view on these 
with the dtype=(str,nbytes). I would expect that it just returns the strings of 
length nbytes.

I am guessing this is not implementable right now due to the fact that you 
always expect all kinds to be of type str. I have not looked detailed enough 
into the code to see if there is a solution.

What version of the product are you using? On what operating system?

Using numexpr.__version__ = 2.0.1 from pip install in Ubuntu 11.10.

Original issue reported on code.google.com by roder...@gmail.com on 9 Aug 2012 at 2:39