Changeset 5251ec6 in sasview for src/sas/sasgui/perspectives/fitting/fitting.py
- Timestamp:
- Oct 11, 2018 12:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitting.py
raba4559 r5251ec6 147 147 Given an ID create a fitproblem container 148 148 """ 149 if page_id in self.page_finder .iterkeys():149 if page_id in self.page_finder: 150 150 del self.page_finder[page_id] 151 151 … … 356 356 # categories, the updated plugin may be in either the form factor 357 357 # or the structure factor combo boxes 358 for uid, page in self.fit_panel.opened_pages.ite ritems():358 for uid, page in self.fit_panel.opened_pages.items(): 359 359 pbox = getattr(page, "formfactorbox", None) 360 360 sbox = getattr(page, "structurebox", None) … … 417 417 self.fit_panel.SetSelection(current_page_index) 418 418 419 except Exception :420 logger.error("update_custom_combo: %s", sys.exc_value)419 except Exception as exc: 420 logger.error("update_custom_combo: %s", exc) 421 421 422 422 def set_edit_menu(self, owner): … … 642 642 data.list_group_id.append(group_id) 643 643 self.add_fit_page(data=[data]) 644 except :645 msg = "Fitting set_data: " + str( sys.exc_value)644 except Exception as exc: 645 msg = "Fitting set_data: " + str(exc) 646 646 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 647 647 … … 654 654 _, theory_state = item 655 655 self.fit_panel.set_model_state(theory_state) 656 except Exception :656 except Exception as exc: 657 657 msg = "Fitting: cannot deal with the theory received" 658 658 evt = StatusEvent(status=msg, info="error") 659 logger.error("set_theory " + msg + "\n" + str( sys.exc_value))659 logger.error("set_theory " + msg + "\n" + str(exc)) 660 660 wx.PostEvent(self.parent, evt) 661 661 … … 780 780 if fid is None: 781 781 return 782 if uid in self.page_finder .keys():782 if uid in self.page_finder: 783 783 self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 784 784 … … 793 793 :param qmax: maximum value of the fit range 794 794 """ 795 if uid in self.page_finder .keys():795 if uid in self.page_finder: 796 796 self.page_finder[uid].set_range(qmin=qmin, qmax=qmax, fid=fid) 797 797 … … 804 804 :param uid: the id related to a page containing fitting information 805 805 """ 806 if uid in self.page_finder .keys():806 if uid in self.page_finder: 807 807 self.page_finder[uid].schedule_tofit(value) 808 808 … … 823 823 """ 824 824 sim_page_id = self.sim_page.uid 825 for uid, value in self.page_finder.ite ritems():825 for uid, value in self.page_finder.items(): 826 826 if uid != sim_page_id and uid != self.batch_page.uid: 827 827 model_list = value.get_model() … … 888 888 Stop the fit 889 889 """ 890 if uid in self.fit_thread_list .keys():890 if uid in self.fit_thread_list: 891 891 calc_fit = self.fit_thread_list[uid] 892 892 if calc_fit is not None and calc_fit.isrunning(): … … 900 900 batch_flag = self.batch_page is not None and uid == self.batch_page.uid 901 901 if sim_flag or batch_flag: 902 for uid, value in self.page_finder.ite ritems():902 for uid, value in self.page_finder.items(): 903 903 if value.get_scheduled() == 1: 904 if uid in self.fit_panel.opened_pages .keys():904 if uid in self.fit_panel.opened_pages: 905 905 panel = self.fit_panel.opened_pages[uid] 906 906 panel._on_fit_complete() … … 919 919 :param draw: Determine if the theory needs to be plot 920 920 """ 921 if uid not in self.page_finder .keys():921 if uid not in self.page_finder: 922 922 return 923 923 self.page_finder[uid].enable_smearing(flag=enable_smearer) … … 930 930 msg += "Got data = %s .\n" % str(data) 931 931 return 932 #raise ValueError , msg932 #raise ValueError(msg) 933 933 model = self.page_finder[uid].get_model(fid=fid) 934 934 if model is None: … … 1032 1032 list_page_id = [] 1033 1033 fit_id = 0 1034 for page_id, page_info in self.page_finder.ite ritems():1034 for page_id, page_info in self.page_finder.items(): 1035 1035 # For simulfit (uid give with None), do for-loop 1036 1036 # if uid is specified (singlefit), do it only on the page. … … 1059 1059 1060 1060 pars = [str(element[1]) for element in page.param_toFit] 1061 fitproblem_list = page_info.values() 1062 for fitproblem in fitproblem_list: 1061 for fitproblem in page_info.values(): 1063 1062 if sim_fitter is None: 1064 1063 fitter = Fit() … … 1079 1078 wx.PostEvent(self.parent, evt) 1080 1079 return True 1081 except :1080 except Exception as exc: 1082 1081 raise 1083 msg = "Fitting error: %s" % str(sys.exc_value)1082 msg = "Fitting error: %s" % exc 1084 1083 evt = StatusEvent(status=msg, info="error", type="stop") 1085 1084 wx.PostEvent(self.parent, evt) … … 1138 1137 :param fid: the id of the fitproblem(data, model, range,etc) 1139 1138 """ 1140 if uid not in self.page_finder .keys():1139 if uid not in self.page_finder: 1141 1140 return 1142 1141 fitproblemList = self.page_finder[uid].get_fit_problem(fid) … … 1183 1182 evt = StatusEvent(status=msg, info="warning") 1184 1183 wx.PostEvent(self.parent, evt) 1185 except Exception :1186 msg = "Creating Fit page: %s" % sys.exc_value1184 except Exception as exc: 1185 msg = "Creating Fit page: %s" % exc 1187 1186 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 1188 1187 … … 1264 1263 # case that uid is not specified 1265 1264 if uid is None: 1266 for page_id in self.page_finder .keys():1265 for page_id in self.page_finder: 1267 1266 self.page_finder[page_id].schedule_tofit(value) 1268 1267 # when uid is given 1269 1268 else: 1270 if uid in self.page_finder .keys():1269 if uid in self.page_finder: 1271 1270 self.page_finder[uid].schedule_tofit(value) 1272 1271 … … 1302 1301 panel = self.plot_panel 1303 1302 if panel is None: 1304 raise ValueError , "Fitting:_onSelect: NonType panel"1303 raise ValueError("Fitting:_onSelect: NonType panel") 1305 1304 Plugin.on_perspective(self, event=event) 1306 1305 self.select_data(panel) … … 1335 1334 """ 1336 1335 uid = page_id[0] 1337 if uid in self.fit_thread_list .keys():1336 if uid in self.fit_thread_list: 1338 1337 del self.fit_thread_list[uid] 1339 1338 … … 1361 1360 #get all fittable parameters of the current model 1362 1361 for param in model.getParamList(): 1363 if param not in batch_outputs .keys():1362 if param not in batch_outputs: 1364 1363 batch_outputs[param] = [] 1365 1364 for param in model.getDispParamList(): 1366 1365 if not model.is_fittable(param) and \ 1367 param in batch_outputs .keys():1366 param in batch_outputs: 1368 1367 del batch_outputs[param] 1369 1368 # Add fitted parameters and their error 1370 1369 for param in res.param_list: 1371 if param not in batch_outputs .keys():1370 if param not in batch_outputs: 1372 1371 batch_outputs[param] = [] 1373 1372 err_param = "error on %s" % str(param) 1374 if err_param not in batch_inputs .keys():1373 if err_param not in batch_inputs: 1375 1374 batch_inputs[err_param] = [] 1376 1375 msg = "" … … 1526 1525 model = fitproblem.get_model() 1527 1526 #fill batch result information 1528 if "Data" not in batch_outputs .keys():1527 if "Data" not in batch_outputs: 1529 1528 batch_outputs["Data"] = [] 1530 1529 cell = BatchCell() … … 1555 1554 cell.object = [data, theory_data] 1556 1555 batch_outputs["Data"].append(cell) 1557 for key, value in data.meta_data.ite ritems():1558 if key not in batch_inputs .keys():1556 for key, value in data.meta_data.items(): 1557 if key not in batch_inputs: 1559 1558 batch_inputs[key] = [] 1560 1559 #if key.lower().strip() != "loader": … … 1562 1561 param = "temperature" 1563 1562 if hasattr(data.sample, param): 1564 if param not in batch_inputs .keys():1563 if param not in batch_inputs: 1565 1564 batch_inputs[param] = [] 1566 1565 batch_inputs[param].append(data.sample.temperature) … … 1633 1632 wx.PostEvent(self.parent, evt) 1634 1633 1635 except Exception: 1636 msg = ("Fit completed but the following error occurred: %s" 1637 % sys.exc_value) 1634 except Exception as exc: 1635 msg = "Fit completed but the following error occurred: %s" % exc 1638 1636 #msg = "\n".join((traceback.format_exc(), msg)) 1639 1637 evt = StatusEvent(status=msg, info="warning", type="stop") … … 1723 1721 if model is None: 1724 1722 return 1725 if uid not in self.page_finder .keys():1723 if uid not in self.page_finder: 1726 1724 return 1727 1725 # save the name containing the data name with the appropriate model … … 2080 2078 source=source) 2081 2079 self.calc_1D.queue() 2082 except :2080 except Exception as exc: 2083 2081 msg = " Error occurred when drawing %s Model 1D: " % model.name 2084 msg += " %s" % sys.exc_value2082 msg += " %s" % exc 2085 2083 wx.PostEvent(self.parent, StatusEvent(status=msg)) 2086 2084
Note: See TracChangeset
for help on using the changeset viewer.