MantisBT - ParaView
View Issue Details
0009208ParaViewBugpublic2009-06-26 04:372010-03-10 13:05
Paul Edwards 
Zhanping Liu 
normalminoralways
closedno change required 
 
3.83.8 
0009208: Calculator parsing issue
There is a problem with the Python parser where it will not recognise a variable that begins with the letters of a mathematical function, e.g. a variable called "absolute" with cause an error because "abs" is a function and it will expect a bracket.

Here is a test case:

8<---------------------------------------
from paraview.simple import *
cone = Cone()
calc = Calculator(cone)
calc.Function = "17"
calc.ResultArrayName = "absolute"
calc2 = Calculator(calc)
calc2.ScalarVariable = ["abs", "abs", "0"]
calc2.Function = "absolute - 15"
calc2.UpdatePipeline()
--------------------------------------->8

Here is a patch to fix:

8<---------------------------------------
Index: ./VTK/Common/vtkFunctionParser.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Common/vtkFunctionParser.cxx,v
retrieving revision 1.44
diff -r1.44 vtkFunctionParser.cxx
1455,1457c1455,1460
< index += this->GetMathFunctionStringLength(functionNumber);
< currentChar = this->Function[index];
< if ( currentChar != '(' )
---
> currentChar = this->Function[index+this->GetMathFunctionStringLength(functionNumber)];
> if ( currentChar == '(' )
> {
> index += this->GetMathFunctionStringLength(functionNumber);
> }
> else
1459,1460d1461
< vtkErrorMacro("Syntax error: input to math function not in "
< << "parentheses; see position " << index);
1463c1464
< return 0;
---
> return 1;
--------------------------------------->8


No tags attached.
has duplicate 0010536closed Robert Maynard array name with string "norm" in it will cause error in calculator 
has duplicate 0009438closed Robert Maynard Calculator input to calculator is junk 
Issue History
2009-06-26 04:37Paul EdwardsNew Issue
2009-12-09 14:49Berk GeveciProject@3@ => ParaView
2009-12-29 11:22Utkarsh AyachitStatusbacklog => tabled
2009-12-29 11:22Utkarsh AyachitAssigned To => Zhanping Liu
2010-03-04 13:10Zhanping LiuNote Added: 0019712
2010-03-04 13:10Zhanping LiuStatustabled => @80@
2010-03-04 13:10Zhanping LiuCategory => Bug
2010-03-09 22:05Alan ScottNote Added: 0019791
2010-03-09 22:05Alan ScottStatus@80@ => @20@
2010-03-09 22:05Alan ScottResolutionopen => reopened
2010-03-10 09:38Utkarsh AyachitNote Added: 0019799
2010-03-10 09:38Utkarsh AyachitStatus@20@ => @80@
2010-03-10 09:38Utkarsh AyachitResolutionreopened => no change required
2010-03-10 09:38Utkarsh AyachitFixed in Version => 3.8
2010-03-10 09:38Utkarsh AyachitTarget Version => 3.8
2010-03-10 13:05Alan ScottNote Added: 0019811
2010-03-10 13:05Alan ScottStatus@80@ => closed
2010-05-06 14:11Robert MaynardRelationship addedhas duplicate 0010536
2010-05-06 14:26Robert MaynardRelationship addedhas duplicate 0009438

Notes
(0019712)
Zhanping Liu   
2010-03-04 13:10   
This problem was fixed by making changes to VTK/Common/vtkFunctionParser.h/cxx. Now the name of an array/variable is allowed to contain a standard math function name, e.g., 'absolute' vs 'abs'.
(0019791)
Alan Scott   
2010-03-09 22:05   
I get the following errors:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
>>> from paraview.simple import *
paraview version 3.7.0, Date: 2010-03-09
>>> from paraview.simple import *
>>> cone=Cone()
>>> calc=Calculator(cone)
>>> calc.Function = "17"
>>> calc.ResultArrayName = "absolute"
>>> calc2=Calculator(calc)
>>> calc2.ScalarVariable = ["abs", "abs", "0"]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "F:/alan/paraviewTrunkVisual/bld/ParaView3/Utilities/VTKPythonWrapping/paraview\servermanager.py", line 201, in __setattr__
    "to add this attribute.")
AttributeError: Attribute ScalarVariable does not exist. This class does not allow addition of new attributes to avoid mistakes due to typos. Use add_attribute() if you really want to add this attribute.
>>>
(0019799)
Utkarsh Ayachit   
2010-03-10 09:38   
The ScalarVariable property has been removed since it's not longer applicable. Just remove that line from the python script.
(0019811)
Alan Scott   
2010-03-10 13:05   
Closed, as per Zhanping. His e-mail thread to me is as follows:


   The bug reporter intended to type
   ===
   calc2.ScalarVariable = ["absolute", "absolute", "0"]
   ===
   (though he actually typed "abs") and this line (referencing "absolute" as a variable) caused a problem (before the fix) because the array calculator was expecting "(" right after 'abs' (since 'abs' is a math function) to make "abs(...)". The fix just allows the calculator to take "absolute" as a valid variable to be distinguishable from 'abs(...)'.