numexpr icon indicating copy to clipboard operation
numexpr copied to clipboard

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

Open FrancescAlted opened this issue 11 years ago • 0 comments

From [email protected] on August 09, 2012 16:39:36

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: http://code.google.com/p/numexpr/issues/detail?id=92

FrancescAlted avatar Jan 22 '14 10:01 FrancescAlted