numexpr
numexpr copied to clipboard
Can evalute expersions with record arrays
From [email protected] on May 31, 2012 13:51:33
What steps will reproduce the problem? 1. create a record array img = numpy.zeros([10], dtype=[('r',float),('g',float),('b',float)]) img['r'] = numpy.arange(10) 2. call numexpr numexpr.evaluate("img['r'] * 2") 3. What is the expected output? What do you see instead? expect the expression to be evaluate on the 'r' column of img. instead i get
numexpr.evaluate("img['r'] * 2") Traceback (most recent call last): File "
", line 1, in File "/usr/lib/python2.7/site-packages/numexpr/necompiler.py", line 687, in evaluate _names_cache[expr_key] = getExprNames(ex, context) File "/usr/lib/python2.7/site-packages/numexpr/necompiler.py", line 608, in getExprNames ex = stringToExpression(text, {}, context) File "/usr/lib/python2.7/site-packages/numexpr/necompiler.py", line 231, in stringToExpression ex = eval(c, names) File " ", line 1, in TypeError: 'VariableNode' object has no attribute 'getitem' What version of the product are you using? On what operating system? Numexpr version: 2.0.1 NumPy version: 1.6.1 Python version: 2.7.3 (default, Apr 30 2012, 21:18:10) [GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] Platform: linux2-i686 AMD/Intel CPU? True VML available? False Detected cores: 2 Please provide any additional information below. i can sort of work around this using the local_dict, but it is a bit messy. numexpr.evaluate("r * 2", local_dict={'r':img['r']}) array([ 0., 2., 4., 6., 8., 10., 12., 14., 16., 18.])
Original issue: http://code.google.com/p/numexpr/issues/detail?id=83
From [email protected] on August 15, 2013 13:51:34
This is affecting me too. Doesn't local_dict={'r':img['r']} allocate additional memory? As much of the numexpr functionality is centered around numpy arrays, I feel that record access notation is important.
Message to comment on stale issues. If none provided, will not mark issues stale