Changeset fa81e94 in sasview for src/sas/sasgui/perspectives/fitting
- 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
- Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/__init__.py
- Property mode changed from 100644 to 100755
r12d3e0e rfa81e94 1 1 PLUGIN_ID = "Fitting plug-in 1.0" 2 2 import os 3 from fitting import *3 from .fitting import * 4 4 from distutils.filelist import findall 5 5 def get_data_path(media): -
src/sas/sasgui/perspectives/fitting/basepage.py
- Property mode changed from 100644 to 100755
rf4a1433 rfa81e94 2 2 Base Page for fitting 3 3 """ 4 from __future__ import print_function 4 5 5 6 6 import sys … … 12 12 import logging 13 13 import traceback 14 from Queue import Queue14 from queue import Queue 15 15 from threading import Thread 16 16 from collections import defaultdict … … 223 223 self.popUpMenu = wx.Menu() 224 224 225 wx_id = self._ids.next()225 wx_id = next(self._ids) 226 226 self._keep = wx.MenuItem(self.popUpMenu, wx_id, "Add bookmark", 227 227 " Keep the panel status to recall it later") … … 623 623 if self.model is not None: 624 624 self.m_name = self.model.name 625 if name in self.saved_states.keys():625 if name in list(self.saved_states.keys()): 626 626 previous_state = self.saved_states[name] 627 627 # reset state of checkbox,textcrtl and regular parameters value … … 918 918 919 919 if len(self._disp_obj_dict) > 0: 920 for k, v in self._disp_obj_dict.ite ritems():920 for k, v in self._disp_obj_dict.items(): 921 921 self.state.disp_obj_dict[k] = v.type 922 922 … … 985 985 986 986 if len(self.disp_cb_dict) > 0: 987 for k, v in self.disp_cb_dict.ite ritems():987 for k, v in self.disp_cb_dict.items(): 988 988 if v is None: 989 989 self.state.disp_cb_dict[k] = v … … 994 994 self.state.disp_cb_dict[k] = None 995 995 if len(self._disp_obj_dict) > 0: 996 for k, v in self._disp_obj_dict.ite ritems():996 for k, v in self._disp_obj_dict.items(): 997 997 self.state.disp_obj_dict[k] = v.type 998 998 … … 1096 1096 if name == "ArrayDispersion": 1097 1097 1098 for item in self.disp_cb_dict.keys():1098 for item in list(self.disp_cb_dict.keys()): 1099 1099 1100 1100 if hasattr(self.disp_cb_dict[item], "SetValue"): … … 1167 1167 :return: combo_box_position 1168 1168 """ 1169 for key, value in self.master_category_dict.ite ritems():1169 for key, value in self.master_category_dict.items(): 1170 1170 formfactor = state.formfactorcombobox.split(":") 1171 1171 if isinstance(formfactor, list): … … 1219 1219 # select the current model 1220 1220 state._convert_to_sasmodels() 1221 state.categorycombobox = unicode(state.categorycombobox)1221 state.categorycombobox = str(state.categorycombobox) 1222 1222 if state.categorycombobox in self.categorybox.Items: 1223 1223 category_pos = self.categorybox.Items.index( … … 1244 1244 structfactor_pos = 0 1245 1245 if state.structurecombobox is not None: 1246 state.structurecombobox = unicode(state.structurecombobox)1246 state.structurecombobox = str(state.structurecombobox) 1247 1247 for ind_struct in range(self.structurebox.GetCount()): 1248 1248 if (self.structurebox.GetString(ind_struct) … … 1354 1354 self.weights = copy.deepcopy(state.weights) 1355 1355 1356 for key, disp_type in state.disp_obj_dict.ite ritems():1356 for key, disp_type in state.disp_obj_dict.items(): 1357 1357 # disp_model = disp 1358 1358 disp_model = POLYDISPERSITY_MODELS[disp_type]() … … 1415 1415 """ 1416 1416 ids = iter(self._id_pool) # Reusing ids for context menu 1417 for name, _ in self.state.saved_states.ite ritems():1417 for name, _ in self.state.saved_states.items(): 1418 1418 self.number_saved_state += 1 1419 1419 # Add item in the context menu 1420 wx_id = ids.next()1420 wx_id = next(ids) 1421 1421 msg = 'Save model and state %g' % self.number_saved_state 1422 1422 self.popUpMenu.Append(wx_id, name, msg) … … 2314 2314 value_ctrl.SetValue(format_number(value)) 2315 2315 2316 if name not in self.model.details.keys():2316 if name not in list(self.model.details.keys()): 2317 2317 self.model.details[name] = ["", None, None] 2318 2318 old_low, old_high = self.model.details[name][1:3] … … 2675 2675 if disp_func is not None: 2676 2676 try: 2677 return POLYDISPERSITY_MODELS.values().index(disp_func.__class__)2677 return list(POLYDISPERSITY_MODELS.values()).index(disp_func.__class__) 2678 2678 except ValueError: 2679 2679 pass # Fall through to default class 2680 return POLYDISPERSITY_MODELS.keys().index('gaussian')2680 return list(POLYDISPERSITY_MODELS.keys()).index('gaussian') 2681 2681 2682 2682 def on_reset_clicked(self, event): … … 2770 2770 gui_manager = self._manager.parent 2771 2771 # loops through the panels [dic] 2772 for _, item2 in gui_manager.plot_panels.ite ritems():2772 for _, item2 in gui_manager.plot_panels.items(): 2773 2773 data_title = self.data.group_id 2774 2774 # try to get all plots belonging to this control panel … … 3340 3340 if self.data.__class__.__name__ == "Data2D": 3341 3341 name = item[1] 3342 if name in content.keys():3342 if name in list(content.keys()): 3343 3343 values = content[name] 3344 3344 check = values[0] … … 3389 3389 if not item[1] in orient_param: 3390 3390 name = item[1] 3391 if name in content.keys():3391 if name in list(content.keys()): 3392 3392 check = content[name][0] 3393 3393 # Avoid changing combox content … … 3615 3615 sizer_cat = wx.BoxSizer(wx.HORIZONTAL) 3616 3616 self.mbox_description.SetForegroundColour(wx.RED) 3617 wx_id = self._ids.next()3617 wx_id = next(self._ids) 3618 3618 self.model_func = wx.Button(self, wx_id, 'Help', size=(80, 23)) 3619 3619 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, 3620 3620 id=wx_id) 3621 3621 self.model_func.SetToolTipString("Full Model Function Help") 3622 wx_id = self._ids.next()3622 wx_id = next(self._ids) 3623 3623 self.model_help = wx.Button(self, wx_id, 'Description', size=(80, 23)) 3624 3624 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, 3625 3625 id=wx_id) 3626 3626 self.model_help.SetToolTipString("Short Model Function Description") 3627 wx_id = self._ids.next()3627 wx_id = next(self._ids) 3628 3628 self.model_view = wx.Button(self, wx_id, "Show 2D", size=(80, 23)) 3629 3629 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=wx_id) -
src/sas/sasgui/perspectives/fitting/fit_thread.py
- Property mode changed from 100644 to 100755
rf4a1433 rfa81e94 11 11 12 12 def map_apply(arguments): 13 return a pply(arguments[0],arguments[1:])13 return arguments[0](*arguments[1:]) 14 14 15 15 class FitThread(CalcThread): … … 49 49 except KeyboardInterrupt: 50 50 msg = "Fitting: terminated by the user." 51 raise KeyboardInterrupt , msg51 raise KeyboardInterrupt(msg) 52 52 53 53 def compute(self): … … 72 72 list_map_get_attr.append(map_getattr) 73 73 #from multiprocessing import Pool 74 inputs = zip(list_map_get_attr, self.fitter, list_fit_function,74 inputs = list(zip(list_map_get_attr, self.fitter, list_fit_function, 75 75 list_q, list_q, list_handler, list_curr_thread, 76 list_reset_flag) 77 result = map(map_apply, inputs)76 list_reset_flag)) 77 result = list(map(map_apply, inputs)) 78 78 79 79 self.complete(result=result, … … 84 84 elapsed=time.time() - self.starttime) 85 85 86 except KeyboardInterrupt ,msg:86 except KeyboardInterrupt as msg: 87 87 # Thread was interrupted, just proceed and re-raise. 88 88 # Real code should not print, but this is an example... -
src/sas/sasgui/perspectives/fitting/fitpage.py
- Property mode changed from 100644 to 100755
r3bd677b rfa81e94 281 281 282 282 # Fit button 283 self.btFit = wx.Button(self, self._ids.next(), 'Fit')283 self.btFit = wx.Button(self, next(self._ids), 'Fit') 284 284 self.default_bt_colour = self.btFit.GetDefaultAttributes() 285 285 self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id=self.btFit.GetId()) … … 377 377 378 378 # Update and Draw button 379 self.draw_button = wx.Button(self, self._ids.next(), 'Compute')379 self.draw_button = wx.Button(self, next(self._ids), 'Compute') 380 380 self.draw_button.Bind(wx.EVT_BUTTON, 381 381 self._onDraw, id=self.draw_button.GetId()) … … 532 532 self.qmin.Bind(wx.EVT_TEXT, self.on_qrange_text) 533 533 self.qmax.Bind(wx.EVT_TEXT, self.on_qrange_text) 534 wx_id = self._ids.next()534 wx_id = next(self._ids) 535 535 self.reset_qrange = wx.Button(self, wx_id, 'Reset') 536 536 … … 540 540 sizer = wx.GridSizer(5, 5, 2, 6) 541 541 542 self.btEditMask = wx.Button(self, self._ids.next(), 'Editor')542 self.btEditMask = wx.Button(self, next(self._ids), 'Editor') 543 543 self.btEditMask.Bind(wx.EVT_BUTTON, self._onMask, 544 544 id=self.btEditMask.GetId()) … … 660 660 self.text_disp_min.Show(True) 661 661 662 for item in self.model.dispersion.keys():662 for item in list(self.model.dispersion.keys()): 663 663 if not self.magnetic_on: 664 664 if item in self.model.magnetic_params: … … 675 675 676 676 iy += 1 677 for p in self.model.dispersion[item].keys():677 for p in list(self.model.dispersion[item].keys()): 678 678 679 679 if p == "width": … … 765 765 disp_box = wx.ComboBox(self, wx.ID_ANY, size=(65, -1), 766 766 style=wx.CB_READONLY, name='%s' % name1) 767 for key, value in POLYDISPERSITY_MODELS.ite ritems():767 for key, value in POLYDISPERSITY_MODELS.items(): 768 768 name_disp = str(key) 769 769 disp_box.Append(name_disp, value) … … 779 779 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 780 780 first_orient = True 781 for item in self.model.dispersion.keys():781 for item in list(self.model.dispersion.keys()): 782 782 if not self.magnetic_on: 783 783 if item in self.model.magnetic_params: … … 795 795 796 796 iy += 1 797 for p in self.model.dispersion[item].keys():797 for p in list(self.model.dispersion[item].keys()): 798 798 799 799 if p == "width": … … 929 929 disp_box = wx.ComboBox(self, wx.ID_ANY, size=(65, -1), 930 930 style=wx.CB_READONLY, name='%s' % name1) 931 for key, value in POLYDISPERSITY_MODELS.ite ritems():931 for key, value in POLYDISPERSITY_MODELS.items(): 932 932 name_disp = str(key) 933 933 disp_box.Append(name_disp, value) … … 1370 1370 except: 1371 1371 tcrtl.SetBackgroundColour("pink") 1372 msg = "Model Error:wrong value entered : %s" % sys.exc_ value1372 msg = "Model Error:wrong value entered : %s" % sys.exc_info()[1] 1373 1373 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 1374 1374 return … … 1482 1482 else: 1483 1483 tcrtl.SetBackgroundColour("pink") 1484 msg = "Model Error:wrong value entered : %s" % sys.exc_ value1484 msg = "Model Error:wrong value entered : %s" % sys.exc_info()[1] 1485 1485 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 1486 1486 return 1487 1487 except: 1488 1488 tcrtl.SetBackgroundColour("pink") 1489 msg = "Model Error:wrong value entered : %s" % sys.exc_ value1489 msg = "Model Error:wrong value entered : %s" % sys.exc_info()[1] 1490 1490 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 1491 1491 return … … 1733 1733 ind = 0 1734 1734 while(ind < len(list)): 1735 for key, val in list .items():1735 for key, val in list(list.items()): 1736 1736 if val == ind: 1737 1737 fun_box.Append(key, val) … … 1865 1865 wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 1866 1866 info="error")) 1867 raise ValueError , msg1867 raise ValueError(msg) 1868 1868 1869 1869 else: … … 1877 1877 wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 1878 1878 info="error")) 1879 raise ValueError , msg1879 raise ValueError(msg) 1880 1880 # Maximum value of data 1881 1881 qmax = math.sqrt(x * x + y * y) … … 2118 2118 self._on_fit_complete() 2119 2119 if out is None or not np.isfinite(chisqr): 2120 raise ValueError , "Fit error occured..."2120 raise ValueError("Fit error occured...") 2121 2121 2122 2122 is_modified = False … … 2193 2193 i += 1 2194 2194 else: 2195 raise ValueError , "onsetValues: Invalid parameters..."2195 raise ValueError("onsetValues: Invalid parameters...") 2196 2196 # Show error title when any errors displayed 2197 2197 if has_error: … … 2951 2951 2952 2952 # type can be either Guassian or Array 2953 if len( self.model.dispersion.values()) > 0:2954 type = self.model.dispersion.values()[0]["type"]2953 if len(list(self.model.dispersion.values())) > 0: 2954 type = list(self.model.dispersion.values())[0]["type"] 2955 2955 else: 2956 2956 type = "Gaussian" -
src/sas/sasgui/perspectives/fitting/fitpanel.py
- Property mode changed from 100644 to 100755
r69363c7 rfa81e94 94 94 batch_state = self.sim_page.set_state() 95 95 96 for uid, page in self.opened_pages.ite ritems():96 for uid, page in self.opened_pages.items(): 97 97 data = page.get_data() 98 98 # state must be cloned … … 135 135 if uid not in self.opened_pages: 136 136 msg = "Fitpanel cannot find ID: %s in self.opened_pages" % str(uid) 137 raise ValueError , msg137 raise ValueError(msg) 138 138 else: 139 139 return self.opened_pages[uid] … … 217 217 page_is_opened = False 218 218 if state is not None: 219 for uid, panel in self.opened_pages.ite ritems():219 for uid, panel in self.opened_pages.items(): 220 220 # Don't return any panel is the exact same page is created 221 221 if uid == panel.uid and panel.data == state.data: … … 396 396 """ 397 397 if data.__class__.__name__ != "list": 398 raise ValueError , "Fitpanel delete_data expect list of id"398 raise ValueError("Fitpanel delete_data expect list of id") 399 399 else: 400 for page in self.opened_pages.values():400 for page in list(self.opened_pages.values()): 401 401 pos = self.GetPageIndex(page) 402 402 temp_data = page.get_data() … … 433 433 data_2d_list.append(data) 434 434 page = None 435 for p in self.opened_pages.values():435 for p in list(self.opened_pages.values()): 436 436 # check if there is an empty page to fill up 437 437 if not check_data_validity(p.get_data()) and p.batch_on: … … 503 503 return None 504 504 focused_page = self.GetPage(self.GetSelection()) 505 for page in self.opened_pages.values():505 for page in list(self.opened_pages.values()): 506 506 # check if the selected data existing in the fitpanel 507 507 pos = self.GetPageIndex(page) … … 592 592 if selected_page in page_finder: 593 593 # Delete the name of the page into the list of open page 594 for uid, list in self.opened_pages.ite ritems():594 for uid, list in self.opened_pages.items(): 595 595 # Don't return any panel is the exact same page is created 596 596 if flag and selected_page.uid == uid: … … 600 600 601 601 # Delete the name of the page into the list of open page 602 for uid, list in self.opened_pages.ite ritems():602 for uid, list in self.opened_pages.items(): 603 603 # Don't return any panel is the exact same page is created 604 604 if selected_page.uid == uid: -
src/sas/sasgui/perspectives/fitting/fitproblem.py
- Property mode changed from 100644 to 100755
r251ef684 rfa81e94 309 309 self._smear_on = flag 310 310 if fid is None: 311 for value in self.values():311 for value in list(self.values()): 312 312 value.enable_smearing(flag) 313 313 elif fid in self: … … 320 320 """ 321 321 if fid is None: 322 for value in self.values():322 for value in list(self.values()): 323 323 value.set_smearer(smearer) 324 324 elif fid in self: … … 336 336 """ 337 337 if fid is None: 338 for value in self.values():338 for value in list(self.values()): 339 339 value.save_model_name(name) 340 340 elif fid in self: … … 346 346 result = [] 347 347 if fid is None: 348 for value in self.values():348 for value in list(self.values()): 349 349 result.append(value.get_name()) 350 350 elif fid in self: … … 360 360 self.model = model 361 361 if fid is None: 362 for value in self.values():362 for value in list(self.values()): 363 363 value.set_model(self.model) 364 364 elif fid in self: … … 456 456 """ 457 457 if fid is None: 458 for value in self.values():458 for value in list(self.values()): 459 459 value.set_model_param(name, value) 460 460 elif fid in self: … … 486 486 """ 487 487 self.scheduled = schedule 488 for value in self.values():488 for value in list(self.values()): 489 489 value.schedule_tofit(schedule) 490 490 … … 502 502 self.qmax = qmax 503 503 if fid is None: 504 for value in self.values():504 for value in list(self.values()): 505 505 value.set_range(self.qmin, self.qmax) 506 506 elif fid in self: … … 519 519 """ 520 520 if fid is None: 521 for value in self.values():521 for value in list(self.values()): 522 522 value.set_weight(flag=flag, is2d=is2d) 523 523 elif fid in self: … … 536 536 """ 537 537 if fid is None: 538 for value in self.values():538 for value in list(self.values()): 539 539 value.clear_model_param() 540 540 elif fid in self: … … 545 545 return fitproblem contained in this dictionary 546 546 """ 547 return self.values()547 return list(self.values()) 548 548 549 549 def set_result(self, result, fid): -
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 -
src/sas/sasgui/perspectives/fitting/model_thread.py
- Property mode changed from 100644 to 100755
rc416a17 rfa81e94 65 65 if self.data is None: 66 66 msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 67 raise ValueError , msg67 raise ValueError(msg) 68 68 69 69 # Define matrix where data will be plotted -
src/sas/sasgui/perspectives/fitting/simfitpage.py
- Property mode changed from 100644 to 100755
r0a3c740 rfa81e94 168 168 i = 0 169 169 for model in self.model_list: 170 model_id = self._format_id( model[1].keys()[0])170 model_id = self._format_id(list(model[1].keys())[0]) 171 171 for saved_model in sim_state.model_list: 172 172 save_id = saved_model.pop('name') … … 195 195 param = item.pop('param_cbox') 196 196 equality = item.pop('egal_txt') 197 for key, value in init_map.items():197 for key, value in list(init_map.items()): 198 198 model_cbox = model_cbox.replace(key, value) 199 199 constraint_value = constraint_value.replace(key, value) 200 for key, value in final_map.items():200 for key, value in list(final_map.items()): 201 201 model_cbox = model_cbox.replace(key, value) 202 202 constraint_value = constraint_value.replace(key, value) … … 328 328 sizer.Add(tab_used, (iy, ix), (1, 1), 329 329 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 330 for id, value in self.page_finder.ite ritems():330 for id, value in self.page_finder.items(): 331 331 if id not in self.parent.opened_pages: 332 332 continue … … 757 757 self.set_button.Disable() 758 758 759 for id, model in self.constraint_dict.ite ritems():759 for id, model in self.constraint_dict.items(): 760 760 # check if all parameters have been selected for constraint 761 761 # then do not allow add constraint on parameters 762 762 self.model_cbox_left.Append(str(model.name), model) 763 763 self.model_cbox_left.Select(0) 764 for id, model in self.constraint_dict.ite ritems():764 for id, model in self.constraint_dict.items(): 765 765 # check if all parameters have been selected for constraint 766 766 # then do not allow add constraint on parameters … … 814 814 model_right = self.model_cbox_right.GetValue() 815 815 model_b = self.model_cbox_right.GetClientData(selection_b) 816 for id, dic_model in self.constraint_dict.ite ritems():816 for id, dic_model in self.constraint_dict.items(): 817 817 if model == dic_model: 818 818 param_list = self.page_finder[id].get_param2fit() … … 857 857 if len(self.constraints_list) != 0: 858 858 nb_fit_param = 0 859 for id, model in self.constraint_dict.ite ritems():859 for id, model in self.constraint_dict.items(): 860 860 nb_fit_param += len(self.page_finder[id].get_param2fit()) 861 861 # Don't add anymore … … 879 879 model_cbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 880 880 model_cbox.Clear() 881 for id, model in self.constraint_dict.ite ritems():881 for id, model in self.constraint_dict.items(): 882 882 # check if all parameters have been selected for constraint 883 883 # then do not allow add constraint on parameters … … 898 898 # Remove button 899 899 #btRemove = wx.Button(self, self.ID_REMOVE, 'Remove') 900 bt_remove = wx.Button(self, self._ids.next(), 'Remove')900 bt_remove = wx.Button(self, next(self._ids), 'Remove') 901 901 bt_remove.Bind(wx.EVT_BUTTON, self.on_remove, 902 902 id=bt_remove.GetId()) … … 931 931 hide buttons related constraint 932 932 """ 933 for id in self.page_finder. iterkeys():933 for id in self.page_finder.keys(): 934 934 self.page_finder[id].clear_model_param() 935 935 … … 969 969 model = model_cbox.GetClientData(n) 970 970 param_list = [] 971 for id, dic_model in self.constraint_dict.ite ritems():971 for id, dic_model in self.constraint_dict.items(): 972 972 if model == dic_model: 973 973 param_list = self.page_finder[id].get_param2fit() … … 1056 1056 msg += " in combobox to set constraint! " 1057 1057 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 1058 for id, value in self.constraint_dict.ite ritems():1058 for id, value in self.constraint_dict.items(): 1059 1059 if model == value: 1060 1060 if constraint == "": … … 1080 1080 return False 1081 1081 1082 for fid in self.page_finder[id]. iterkeys():1082 for fid in self.page_finder[id].keys(): 1083 1083 # wrap in param/constraint in str() to remove unicode 1084 1084 self.page_finder[id].set_model_param(str(param),
Note: See TracChangeset
for help on using the changeset viewer.