Changeset fa81e94 in sasview for src/sas/sasgui/perspectives/fitting/fitting.py
- Timestamp:
- Nov 15, 2017 4:33:09 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- d4881f6a
- Parents:
- 7c487846
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/fitting.py
- Property mode changed from 100644 to 100755
rc416a17 rfa81e94 11 11 #copyright 2009, University of Tennessee 12 12 ################################################################################ 13 from __future__ import print_function 13 14 14 15 15 import re … … 142 142 Given an ID create a fitproblem container 143 143 """ 144 if page_id in self.page_finder.iterkeys():144 if page_id in iter(self.page_finder.keys()): 145 145 del self.page_finder[page_id] 146 146 … … 335 335 if temp: 336 336 # Set the new plugin model list for all fit pages 337 for uid, page in self.fit_panel.opened_pages.ite ritems():337 for uid, page in self.fit_panel.opened_pages.items(): 338 338 if hasattr(page, "formfactorbox"): 339 339 page.model_list_box = temp … … 350 350 page.formfactorbox.SetLabel(current_val) 351 351 except: 352 logger.error("update_custom_combo: %s", sys.exc_ value)352 logger.error("update_custom_combo: %s", sys.exc_info()[1]) 353 353 354 354 def set_edit_menu(self, owner): … … 556 556 else: 557 557 if len(data_list) > MAX_NBR_DATA: 558 from fitting_widgets import DataDialog558 from .fitting_widgets import DataDialog 559 559 dlg = DataDialog(data_list=data_list, nb_data=MAX_NBR_DATA) 560 560 if dlg.ShowModal() == wx.ID_OK: … … 576 576 self.add_fit_page(data=[data]) 577 577 except: 578 msg = "Fitting set_data: " + str(sys.exc_ value)578 msg = "Fitting set_data: " + str(sys.exc_info()[1]) 579 579 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 580 580 … … 590 590 msg = "Fitting: cannot deal with the theory received" 591 591 evt = StatusEvent(status=msg, info="error") 592 logger.error("set_theory " + msg + "\n" + str(sys.exc_ value))592 logger.error("set_theory " + msg + "\n" + str(sys.exc_info()[1])) 593 593 wx.PostEvent(self.parent, evt) 594 594 … … 602 602 """ 603 603 from pagestate import PageState 604 from simfitpage import SimFitPageState604 from .simfitpage import SimFitPageState 605 605 if isinstance(state, PageState): 606 606 state = state.clone() … … 713 713 if fid is None: 714 714 return 715 if uid in self.page_finder.keys():715 if uid in list(self.page_finder.keys()): 716 716 self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 717 717 … … 726 726 :param qmax: maximum value of the fit range 727 727 """ 728 if uid in self.page_finder.keys():728 if uid in list(self.page_finder.keys()): 729 729 self.page_finder[uid].set_range(qmin=qmin, qmax=qmax, fid=fid) 730 730 … … 737 737 :param uid: the id related to a page contaning fitting information 738 738 """ 739 if uid in self.page_finder.keys():739 if uid in list(self.page_finder.keys()): 740 740 self.page_finder[uid].schedule_tofit(value) 741 741 … … 756 756 """ 757 757 sim_page_id = self.sim_page.uid 758 for uid, value in self.page_finder.ite ritems():758 for uid, value in self.page_finder.items(): 759 759 if uid != sim_page_id and uid != self.batch_page.uid: 760 760 model_list = value.get_model() … … 821 821 Stop the fit 822 822 """ 823 if uid in self.fit_thread_list.keys():823 if uid in list(self.fit_thread_list.keys()): 824 824 calc_fit = self.fit_thread_list[uid] 825 825 if calc_fit is not None and calc_fit.isrunning(): … … 833 833 batch_flag = self.batch_page is not None and uid == self.batch_page.uid 834 834 if sim_flag or batch_flag: 835 for uid, value in self.page_finder.ite ritems():835 for uid, value in self.page_finder.items(): 836 836 if value.get_scheduled() == 1: 837 if uid in self.fit_panel.opened_pages.keys():837 if uid in list(self.fit_panel.opened_pages.keys()): 838 838 panel = self.fit_panel.opened_pages[uid] 839 839 panel._on_fit_complete() … … 852 852 :param draw: Determine if the theory needs to be plot 853 853 """ 854 if uid not in self.page_finder.keys():854 if uid not in list(self.page_finder.keys()): 855 855 return 856 856 self.page_finder[uid].enable_smearing(flag=enable_smearer) … … 964 964 list_page_id = [] 965 965 fit_id = 0 966 for page_id, page_info in self.page_finder.ite ritems():966 for page_id, page_info in self.page_finder.items(): 967 967 # For simulfit (uid give with None), do for-loop 968 968 # if uid is specified (singlefit), do it only on the page. … … 991 991 992 992 pars = [str(element[1]) for element in page.param_toFit] 993 fitproblem_list = page_info.values()993 fitproblem_list = list(page_info.values()) 994 994 for fitproblem in fitproblem_list: 995 995 if sim_fitter is None: … … 1013 1013 except: 1014 1014 raise 1015 msg = "Fitting error: %s" % str(sys.exc_ value)1015 msg = "Fitting error: %s" % str(sys.exc_info()[1]) 1016 1016 evt = StatusEvent(status=msg, info="error", type="stop") 1017 1017 wx.PostEvent(self.parent, evt) … … 1070 1070 :param fid: the id of the fitproblem(data, model, range,etc) 1071 1071 """ 1072 if uid not in self.page_finder.keys():1072 if uid not in list(self.page_finder.keys()): 1073 1073 return 1074 1074 fitproblemList = self.page_finder[uid].get_fit_problem(fid) … … 1116 1116 wx.PostEvent(self.parent, evt) 1117 1117 except: 1118 msg = "Creating Fit page: %s" % sys.exc_ value1118 msg = "Creating Fit page: %s" % sys.exc_info()[1] 1119 1119 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 1120 1120 … … 1196 1196 # case that uid is not specified 1197 1197 if uid is None: 1198 for page_id in self.page_finder.keys():1198 for page_id in list(self.page_finder.keys()): 1199 1199 self.page_finder[page_id].schedule_tofit(value) 1200 1200 # when uid is given 1201 1201 else: 1202 if uid in self.page_finder.keys():1202 if uid in list(self.page_finder.keys()): 1203 1203 self.page_finder[uid].schedule_tofit(value) 1204 1204 … … 1234 1234 panel = self.plot_panel 1235 1235 if panel is None: 1236 raise ValueError , "Fitting:_onSelect: NonType panel"1236 raise ValueError("Fitting:_onSelect: NonType panel") 1237 1237 Plugin.on_perspective(self, event=event) 1238 1238 self.select_data(panel) … … 1267 1267 """ 1268 1268 uid = page_id[0] 1269 if uid in self.fit_thread_list.keys():1269 if uid in list(self.fit_thread_list.keys()): 1270 1270 del self.fit_thread_list[uid] 1271 1271 … … 1293 1293 #get all fittable parameters of the current model 1294 1294 for param in model.getParamList(): 1295 if param not in batch_outputs.keys():1295 if param not in list(batch_outputs.keys()): 1296 1296 batch_outputs[param] = [] 1297 1297 for param in model.getDispParamList(): 1298 1298 if not model.is_fittable(param) and \ 1299 param in batch_outputs.keys():1299 param in list(batch_outputs.keys()): 1300 1300 del batch_outputs[param] 1301 1301 # Add fitted parameters and their error 1302 1302 for param in res.param_list: 1303 if param not in batch_outputs.keys():1303 if param not in list(batch_outputs.keys()): 1304 1304 batch_outputs[param] = [] 1305 1305 err_param = "error on %s" % str(param) 1306 if err_param not in batch_inputs.keys():1306 if err_param not in list(batch_inputs.keys()): 1307 1307 batch_inputs[err_param] = [] 1308 1308 msg = "" … … 1389 1389 #model 1390 1390 EMPTY = "-" 1391 for key in batch_outputs.keys():1391 for key in list(batch_outputs.keys()): 1392 1392 if key not in param_list and key not in ["Chi2", "Data"]: 1393 1393 batch_outputs[key].append(EMPTY) … … 1432 1432 tbatch_outputs = {} 1433 1433 shownkeystr = cpage.get_copy_params() 1434 for key in batch_outputs.keys():1434 for key in list(batch_outputs.keys()): 1435 1435 if key in ["Chi2", "Data"] or shownkeystr.count(key) > 0: 1436 1436 tbatch_outputs[key] = batch_outputs[key] … … 1452 1452 model = fitproblem.get_model() 1453 1453 #fill batch result information 1454 if "Data" not in batch_outputs.keys():1454 if "Data" not in list(batch_outputs.keys()): 1455 1455 batch_outputs["Data"] = [] 1456 1456 from sas.sasgui.guiframe.data_processor import BatchCell … … 1482 1482 cell.object = [data, theory_data] 1483 1483 batch_outputs["Data"].append(cell) 1484 for key, value in data.meta_data.ite ritems():1485 if key not in batch_inputs.keys():1484 for key, value in data.meta_data.items(): 1485 if key not in list(batch_inputs.keys()): 1486 1486 batch_inputs[key] = [] 1487 1487 #if key.lower().strip() != "loader": … … 1489 1489 param = "temperature" 1490 1490 if hasattr(data.sample, param): 1491 if param not in batch_inputs.keys():1491 if param not in list(batch_inputs.keys()): 1492 1492 batch_inputs[param] = [] 1493 1493 batch_inputs[param].append(data.sample.temperature) … … 1562 1562 except: 1563 1563 msg = ("Fit completed but the following error occurred: %s" 1564 % sys.exc_ value)1564 % sys.exc_info()[1]) 1565 1565 #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 1566 1566 evt = StatusEvent(status=msg, info="warning", type="stop") … … 1650 1650 if model is None: 1651 1651 return 1652 if uid not in self.page_finder.keys():1652 if uid not in list(self.page_finder.keys()): 1653 1653 return 1654 1654 # save the name containing the data name with the appropriate model … … 1903 1903 return None 1904 1904 try: 1905 from model_thread import Calc2D1905 from .model_thread import Calc2D 1906 1906 ## If a thread is already started, stop it 1907 1907 if (self.calc_2D is not None) and self.calc_2D.isrunning(): … … 1950 1950 return 1951 1951 try: 1952 from model_thread import Calc1D1952 from .model_thread import Calc1D 1953 1953 ## If a thread is already started, stop it 1954 1954 if (self.calc_1D is not None) and self.calc_1D.isrunning(): … … 1989 1989 except: 1990 1990 msg = " Error occurred when drawing %s Model 1D: " % model.name 1991 msg += " %s" % sys.exc_ value1991 msg += " %s" % sys.exc_info()[1] 1992 1992 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1993 1993
Note: See TracChangeset
for help on using the changeset viewer.