-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
numpy/scipy cause syntax errors in python model builder (Trac #1218) #1247
Comments
Trac update at
should be trivial enough to fix so would be nice to do.
|
Trac update at
|
Trac update at It appears I already had "\n" added to relevant lines in the Qt version. |
Trac update at
Added the newline characters. Pull request #348 |
Trac update at The namespace is documented in the sasmodels manual. I suggest renaming the ticket: "Make the opencl special function library available to python models". Maybe add that the template builder should be moved to sascalc rather than living in the GUI tree, or maybe make that a new ticket. |
Trac update at In changeset 33d3a74:
|
Trac update at Could this not be fixed by just adding a comment line before the import statement explaining what is being imported? The user writing a plugin doesn't see any of this anyway so should not matter? Replying to [comment:3 piotr]:
|
Trac update at |
Addressed in ESS_GUI |
If the code in your simple python model contains numpy, np or scipy then it will cause a syntax error when you try to run the model. This is because the model builder does not include
\n
when it inserts the numpy import line.Better would be to place the imports at the top of the template for all models instead of including it dynamically in the function definition. The model reload problems should be fixed, so this should now work. This will make the code simpler, and we are relying on this fix already for the trig and exponential functions.
Instead of
from math import *
, we should usefrom sasmodels.special import *
at the top of the template. This will define the same set of functions that are available to C models, including functions such as sas_erf, etc, constants such as M_PI and the gaussian quadrature weights for 20, 76 and 150 point quadrature. It also defines thenp
symbol in case any thing else is needed.Migrated from http://trac.sasview.org/ticket/1218
The text was updated successfully, but these errors were encountered: