Changeset 5181e9b in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Sep 8, 2018 5:34:11 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- f3e5956
- Parents:
- 254199c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/ModelThread.py
r9ba91b7 r5181e9b 164 164 index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 165 165 166 intermediate_results = None 167 166 168 # If we use a smearer, also return the unsmeared model 167 169 unsmeared_output = None … … 174 176 mask = self.data.x[first_bin:last_bin+1] 175 177 unsmeared_output = numpy.zeros((len(self.data.x))) 176 unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 178 179 return_data = self.model.calculate_Iq(mask) 180 if isinstance(return_data, tuple): 181 # see sasmodels beta_approx: SasviewModel.calculate_Iq 182 # TODO: implement intermediate results in smearers 183 return_data, _ = return_data 184 unsmeared_output[first_bin:last_bin+1] = return_data 177 185 output = self.smearer(unsmeared_output, first_bin, last_bin) 178 186 … … 193 201 unsmeared_error=unsmeared_error 194 202 else: 195 output[index] = self.model.evalDistribution(self.data.x[index]) 196 197 results_eval = {} 198 intermediate_results = getattr(self.model, "_intermediate_results", None) 199 if callable(intermediate_results): 200 # support for future sasmodels (beta approx support) - it returns a dict of intermediate results, keyed by 201 # name 202 results_eval = intermediate_results() 203 else: 203 return_data = self.model.calculate_Iq(self.data.x[index]) 204 if isinstance(return_data, tuple): 205 # see sasmodels beta_approx: SasviewModel.calculate_Iq 206 return_data, intermediate_results = return_data 207 output[index] = return_data 208 209 if intermediate_results: 210 # the model returns a callable which is then used to retrieve the data 211 intermediate_results = intermediate_results() 212 else: 213 # TODO: this conditional branch needs refactoring 204 214 sq_values = None 205 215 pq_values = None 206 216 s_model = None 207 217 p_model = None 218 208 219 if isinstance(self.model, MultiplicationModel): 209 220 s_model = self.model.s_model 210 221 p_model = self.model.p_model 222 211 223 elif hasattr(self.model, "calc_composition_models"): 212 224 results = self.model.calc_composition_models(self.data.x[index]) … … 222 234 223 235 if pq_values is not None and sq_values is not None: 224 results_eval= {236 intermediate_results = { 225 237 "P(Q)": pq_values, 226 238 "S(Q)": sq_values 227 239 } 240 else: 241 intermediate_results = {} 228 242 229 243 elapsed = time.time() - self.starttime … … 236 250 source = self.source, unsmeared_output = unsmeared_output, 237 251 unsmeared_data = unsmeared_data, unsmeared_error = unsmeared_error, 238 intermediate_results = results_eval)252 intermediate_results = intermediate_results) 239 253 240 254 if LocalConfig.USING_TWISTED:
Note: See TracChangeset
for help on using the changeset viewer.