#583 closed defect (fixed)
Sum|Multi(p1,p2) does not work
Reported by: | gonzalezm | Owned by: | ajj |
---|---|---|---|
Priority: | blocker | Milestone: | SasView 4.0.0 |
Component: | SasView | Keywords: | |
Cc: | Work Package: | SasView Bug Fixing |
Description (last modified by butler)
Sum (multiplication) of two models does not work (known bug, reported also by thomas.cleveland@…)
When trying to create a model as the sum of two standard models, the following error message appears:
“Running model 'MySumFunction.py'…
Error occurred:
Traceback (most recent call last):
File "sas\sasgui\perspectives\calculator\pyconsole.pyc", line 55, in show_model_output
File "sas\sasgui\perspectives\calculator\pyconsole.pyc", line 30, in check_model
ImportError: cannot import name make_class”
This happens because the function make_class (in sasmodels/sasview_model.py) does not exist anymore, as it was replaced by _make_standard_model in 4d76711 on Apr 5 (Paul Kienzle adjust interface to sasview). Note: The comment at the beginning of sasview_model.py should be changed accordingly, as it still mentions make_class.
The obvious change that I tried is to replace make_class by _make_standard_model in the python file generated by “Sum|Multi(p1,p2)”, but then a different problem happens and the fitting perspective is broken, so it is even worse than the original bug.
This is what I could follow about the program execution:
- I start SasView 4.0 having the file MG_sum1.py in the .sasview\plugin_models folder. This is just the file created by the template of “Sum|Multi(p1,p2)” for a model consisting of an sphere + a cylinder, but replacing make_class by _make_standard_model.
- In sasview\src\sas\sasgui\perspectives\fitting\models.py it is added to the plugins by the command plugins[name] = module.Model, returning a class MG_sum1.model. As a reference, a simple python model present in the plugin_models is loaded using plugins[name] = load_custom_model(filename) and we generate a class sasmodels.sasview_model.MG_simple1
- In the call to _get_multifunc_models, an error is generated because the class Model has no attribute ‘is_multiplicitiy_model’
Change History (5)
comment:1 Changed 9 years ago by ajj
- Owner set to ajj
- Status changed from new to assigned
comment:2 Changed 9 years ago by ajj
comment:3 Changed 9 years ago by butler
- Priority changed from critical to blocker
comment:4 Changed 8 years ago by pkienzle
- Resolution set to fixed
- Status changed from assigned to closed
I made the current approach work again for alpha, but still want to refactor it for beta, time permitting, so that sum and multiply are more compact. I'll open this as a new ticket.
comment:5 Changed 8 years ago by butler
- Description modified (diff)
There is a cascading set of changes in the model interface that means that I don't think we can make a sum/multi model the way we do now.
I tried changing the call to make_class to load_standard_models which seems to allow the model to get further, but fails on pyconsole.check_model()
This is because of the way that load_model_info now works - it attempts to handle + and * models by parsing the model name.
Thus a sum/multi model does not exist anymore as a separate entity - not clear how we can change the infrastructure to support these "virtual" models and have them be persistent.
Should probably be encouraging users to write models that re-parameterise and then call underlying model kernels but again it is not clear (to me) how to do this with the current approach.