Conversation
…ity is combined with a structure factor
|
I also noticed that when selecting an S(Q), there is the following RuntimeError message in my terminal: This appears only the first time, also for standard models (e.g. sphere + hardsphere), and it does not seem to have consequences, but I suppose it would be good to get rid of it if possible. |
butlerpd
left a comment
There was a problem hiding this comment.
Unless I am missing something I think new lines 212 and 213 seem redundant with 214? In fact currently line 214 can never be reached can it? Not sure which is more pythonic: remove 212 and 213 or remove 214? Maybe Paul K. knows?
Once this is sorted I think this should be pullable though I should check the functionality first I guess
|
You're right Paul. I forgot to remove the initial return. I did it now, removing line 214 because I liked it more this way, but I don't know either which is the prefered way in python. I let Paul K to decide on this, and in particular to check if other attributes need to be added to the ConstructedModel or if my changes may have unexpected consequences in some cases (everything seems to work, but I just made a few standard tests combining form factors and structure models and without fitting). |
|
You should be able to do just the following: If not, then make_product_info isn't describing the multiplicity variables correctly, or make_model_from_info isn't processing them correctly. |
|
It clearly has not bee working! Are you saying the error was ONLY on line 207 which should ALWAYS return ConstructedModel(form_factor.multiplicity) regardless if the form factor has multiplicity or not? if so why doesn't the API just do that without needing to pass (form_factor.multiplicity)? Seems very odd. |
|
The multiplicity attribute is always set in the model, even if it happens to be None. You can see this from the definition of SasviewModel in sasview_model.py: Within the GUI, the multiplicity models have a drop-down box at the top of the form in which to select the multiplicity value. Since this is only for multiplicity models, it is put in a separate branch, passing the multiplicity to the form_factor constructor, then updating the form with any fields that may have appeared as a result of the multiplicity. The other branch could call the constructor with multiplicity=None, but that is the default so it doesn't bother. The point is that when adding a structure factor, the multiplication model shouldn't care whether or not there is multiplicity on the form factor, it should just pass whatever multiplicity P has along to the S*P product model so that it is set correctly during model evaluation (the _get_weights function attaches the value of multiplicity to the parameter set). Furthermore, at this point only the multiplicity value is needed; the additional fields would only be needed by the GUI, but it is using the multiplicity info from the underlying form_factor model. |
|
Using 'return ConstructedModel(form_factor.multiplicity)' improves things, but it is not enough as the parameter 'n' continues to appear in the list of model parameters. The reason is that ConstructedModel.non_fittable is not getting the info from the form_factor and remains empty. Similarly ConstructedModel.is_multiplicity_model returns False and the multiplicity_info is empty (number=0, control='', etc.), but I guess this does not matter much if they are not used. I will try to check make_product_info and make_model_from_info to set properly the non_fittable attribute. |
|
Hopefully, this is the right solution. I added model_info.control into make_product_info in order to pass the information about the controlling and non_fittable parameters (e.g. n in the core_multi_shell model). Note that I assumed that only the form factor has control parameters. |
|
Looking at This will also be a problem in Other parameters in |
pkienzle
left a comment
There was a problem hiding this comment.
Code looks fine. Haven't tested. I'll turn my comment re: mixture models into a ticket.
|
will test functionality this morning and merge if passes |
butlerpd
left a comment
There was a problem hiding this comment.
Have tested on windows and now works so am calling functionality fixed
The problem in the interface when combining a form factor that has multiplicity with a structure factor was due to the fact that the MultiplicationModel function did not propagate to the new model the information about the multiplicity and the non_fittable (n) parameters. With these changes, my test with the core_multi_shell model x the hard sphere S(Q) works well. But probably Paul K should check if there are some other attributes that need to be passed or if this should be done in a different way.