Open mdoucet opened 5 years ago
Trac update at 2015/06/11 01:44:50
: pkienzle changed workpackage from "SasView Bug Fixing" to "SasView QA and testing"
Pretty sure they're all gone now, will double check
There are some eval()
calls that don't need to be:
$ grep "\We\(xec\|val\) *(" sasview/src/**/*.py
sasview/src/sas/qtgui/Calculators/DataOperationUtilityPanel.py: output = eval("data1 %s data2" % operator)
sasview/src/sas/qtgui/Perspectives/Fitting/ComplexConstraint.py: eval(expression_to_evaluate)
sasview/src/sas/qtgui/Perspectives/Fitting/FittingOptions.py: widget_to_activate = eval(widget_name)
sasview/src/sas/qtgui/Perspectives/Fitting/FittingOptions.py: line_edit = eval(widget_name)
sasview/src/sas/qtgui/Perspectives/Fitting/FittingOptions.py: return eval('self.' + option)
sasview/src/sas/qtgui/Perspectives/Fitting/FittingOptions.py: control = eval(widget_name)
sasview/src/sas/qtgui/Perspectives/Fitting/FittingOptions.py: eval(widget_name).setText(str(options[option]))
sasview/src/sas/qtgui/Perspectives/Fitting/MultiConstraint.py: eval(expression_to_evaluate)
sasview/src/sas/qtgui/Utilities/TabbedModelEditor.py: return msg_box.exec()
sasview/src/sas/qtgui/sasview/sasview.py: exec(sys.argv[2])
sasview/src/sas/sascalc/fit/AbstractFitEngine.py: def eval(self, x):
sasview/src/sas/sascalc/fit/AbstractFitEngine.py: return self.eval(x)
sasview/src/sas/sascalc/fit/BumpsFitting.py: pvec.append(eval(err_exp).n)
sasview/src/sas/sascalc/fit/BumpsFitting.py: stderr.append(eval(err_exp).s)
sasview/src/sas/sascalc/fit/expression.py: #exec(functiondef, global_context, local_context)
sasview/src/sas/sascalc/fit/expression.py: eval(compile(source, location, 'exec'), global_context, local_context)
DataOperationUtilityPanel could use operator.add
, etc.
FittingOptions could be using self.get(attribute_name)
instead of eval("self."+attribute_name)
for attribute lookup.
This still leaves eval
for constraint expressions.
Yuck.
For DataOperationUtilityPanel, other possibilities are:
1) Write classes representing basic algebraic operations. This is pretty simple and I've done similar things in a lot of contexts. Parsing strings representing them is a bit annoying, but not too hard as long as one sticks to basic operations, +-*/^ and ().
2) Use sympy
. It's heavy duty, but it's an option for this kind of thing.
Constraint expressions need a better data structure anyway as I'm told there are issues with multiple constraints.
I noticed that there are a lot of 'exec' calls peppered in the UI code. We should go through and get rid of them.
Migrated from http://trac.sasview.org/ticket/371