Changes in src/sas/sasgui/perspectives/fitting/basepage.py [33dc18f:3bd677b] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r33dc18f r3bd677b 6 6 import sys 7 7 import os 8 import wx9 import numpy as np10 8 import time 11 9 import copy … … 14 12 import logging 15 13 import traceback 16 14 from Queue import Queue 15 from threading import Thread 17 16 from collections import defaultdict 17 18 import numpy as np 19 20 import wx 18 21 from wx.lib.scrolledpanel import ScrolledPanel 19 22 23 from sasmodels.sasview_model import MultiplicationModel 20 24 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS 25 from sasmodels.weights import GaussianDispersion 26 27 from sas.sascalc.dataloader.data_info import Detector 28 from sas.sascalc.dataloader.data_info import Source 29 from sas.sascalc.fit.pagestate import PageState 30 from sas.sascalc.fit.models import PLUGIN_NAME_BASE 21 31 22 32 from sas.sasgui.guiframe.panel_base import PanelBase … … 30 40 from sas.sasgui.guiframe.dataFitting import check_data_validity 31 41 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 32 from sas.sascalc.dataloader.data_info import Detector33 from sas.sascalc.dataloader.data_info import Source34 from sas.sasgui.perspectives.fitting.pagestate import PageState35 42 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 36 43 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 44 45 from .report_dialog import ReportDialog 46 from .utils import get_weight 37 47 38 48 logger = logging.getLogger(__name__) … … 153 163 self.disp_cb_dict = {} 154 164 155 # self.state = PageState( parent=parent)165 # self.state = PageState() 156 166 # dictionary containing list of models 157 167 self.model_list_box = {} … … 200 210 self.fitrange = True 201 211 # Create memento to save the current state 202 self.state = PageState(parent=self.parent, 203 model=self.model, data=self.data) 212 self.state = PageState(model=self.model, data=self.data) 204 213 # flag to determine if state has change 205 214 self.state_change = False … … 241 250 self.set_layout() 242 251 252 # Setting up a thread for the fitting 253 self.threaded_draw_queue = Queue() 254 255 self.draw_worker_thread = Thread(target = self._threaded_draw_worker, 256 args = (self.threaded_draw_queue,)) 257 self.draw_worker_thread.setDaemon(True) 258 self.draw_worker_thread.start() 259 260 # And a home for the thread submission times 261 self.last_time_fit_submitted = 0.00 262 243 263 def set_index_model(self, index): 244 264 """ … … 282 302 """ 283 303 x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 284 304 num=self.npts_x, endpoint=True) 285 305 self.data = Data1D(x=x) 286 306 self.data.xaxis('\\rm{Q}', "A^{-1}") … … 308 328 309 329 x = np.logspace(start=qmin, stop=qmax, 310 330 num=self.npts_x, endpoint=True, base=10.0) 311 331 self.data = Data1D(x=x) 312 332 self.data.xaxis('\\rm{Q}', "A^{-1}") … … 497 517 self.state.manager = manager 498 518 499 def populate_box(self, model_ dict):519 def populate_box(self, model_list_box): 500 520 """ 501 521 Store list of model 502 522 503 :param model_dict: dictionary containing list of models 504 505 """ 506 self.model_list_box = model_dict 507 self.state.model_list_box = self.model_list_box 523 :param model_list_box: dictionary containing categorized models 524 """ 525 self.model_list_box = model_list_box 508 526 self.initialize_combox() 509 527 510 def set_model_dictionary(self, model_dict ):528 def set_model_dictionary(self, model_dictionary): 511 529 """ 512 530 Store a dictionary linking model name -> model object 513 531 514 :param model_dict : dictionary containing list ofmodels515 """ 516 self.model_dict = model_dict532 :param model_dictionary: dictionary containing all models 533 """ 534 self.model_dictionary = model_dictionary 517 535 518 536 def initialize_combox(self): … … 520 538 put default value in the combo box 521 539 """ 522 if self.model_list_box is not None and len(self.model_list_box) > 0:540 if self.model_list_box: 523 541 self._populate_box(self.structurebox, 524 542 self.model_list_box["Structure Factors"]) … … 619 637 # Get plot image from plotpanel 620 638 images, canvases = self.get_images() 621 # get the report dialog 622 self.state.report(images, canvases) 639 imgRAM, images, refs = self._build_plots_for_report(images, canvases) 640 641 # get the strings for report 642 report_str, text_str = self.state.report(fig_urls=refs) 643 644 # Show the dialog 645 report_list = [report_str, text_str, images] 646 dialog = ReportDialog(report_list, None, wx.ID_ANY, "") 647 dialog.Show() 648 649 def _build_plots_for_report(self, figs, canvases): 650 """ 651 Build image state that wx.html understand 652 by plotting, putting it into wx.FileSystem image object 653 """ 654 images = [] 655 refs = [] 656 657 # For no figures in the list, prepare empty plot 658 if figs is None or len(figs) == 0: 659 figs = [None] 660 661 # Loop over the list of figures 662 # use wx.MemoryFSHandler 663 imgRAM = wx.MemoryFSHandler() 664 for fig in figs: 665 if fig is not None: 666 ind = figs.index(fig) 667 canvas = canvases[ind] 668 669 # store the image in wx.FileSystem Object 670 wx.FileSystem.AddHandler(wx.MemoryFSHandler()) 671 672 # index of the fig 673 ind = figs.index(fig) 674 675 # AddFile, image can be retrieved with 'memory:filename' 676 name = 'img_fit%s.png' % ind 677 refs.append('memory:' + name) 678 imgRAM.AddFile(name, canvas.bitmap, wx.BITMAP_TYPE_PNG) 679 680 # append figs 681 images.append(fig) 682 683 return imgRAM, images, refs 684 623 685 624 686 def on_save(self, event): … … 842 904 self.state.disable_disp = self.disable_disp.GetValue() 843 905 844 self.state.smearer = copy.deepcopy(self.current_smearer)845 906 if hasattr(self, "enable_smearer"): 846 907 self.state.enable_smearer = \ … … 858 919 if len(self._disp_obj_dict) > 0: 859 920 for k, v in self._disp_obj_dict.iteritems(): 860 self.state. _disp_obj_dict[k] = v.type921 self.state.disp_obj_dict[k] = v.type 861 922 862 923 self.state.values = copy.deepcopy(self.values) … … 876 937 self.state.str_parameters) 877 938 self._copy_parameters_state(self.orientation_params, 878 939 self.state.orientation_params) 879 940 self._copy_parameters_state(self.orientation_params_disp, 880 941 self.state.orientation_params_disp) … … 907 968 self.state.disable_disp = self.disable_disp.GetValue() 908 969 909 self.state.smearer = copy.deepcopy(self.current_smearer)910 970 if hasattr(self, "enable_smearer"): 911 971 self.state.enable_smearer = \ … … 931 991 try: 932 992 self.state.disp_cb_dict[k] = v.GetValue() 933 except :993 except Exception: 934 994 self.state.disp_cb_dict[k] = None 935 995 if len(self._disp_obj_dict) > 0: 936 996 for k, v in self._disp_obj_dict.iteritems(): 937 self.state. _disp_obj_dict[k] = v.type997 self.state.disp_obj_dict[k] = v.type 938 998 939 999 self.state.values = copy.deepcopy(self.values) … … 977 1037 # to support older version 978 1038 category_pos = int(state.categorycombobox) 979 except :1039 except Exception: 980 1040 category_pos = 0 981 1041 for ind_cat in range(self.categorybox.GetCount()): … … 989 1049 # to support older version 990 1050 formfactor_pos = int(state.formfactorcombobox) 991 except :1051 except Exception: 992 1052 formfactor_pos = 0 993 1053 for ind_form in range(self.formfactorbox.GetCount()): … … 1002 1062 # to support older version 1003 1063 structfactor_pos = int(state.structurecombobox) 1004 except :1064 except Exception: 1005 1065 structfactor_pos = 0 1006 1066 for ind_struct in range(self.structurebox.GetCount()): … … 1169 1229 self.categorybox.Select(category_pos) 1170 1230 self._show_combox(None) 1171 from models import PLUGIN_NAME_BASE 1172 if self.categorybox.GetValue() == CUSTOM_MODEL \ 1173 and PLUGIN_NAME_BASE not in state.formfactorcombobox: 1231 if (self.categorybox.GetValue() == CUSTOM_MODEL 1232 and PLUGIN_NAME_BASE not in state.formfactorcombobox): 1174 1233 state.formfactorcombobox = \ 1175 1234 PLUGIN_NAME_BASE + state.formfactorcombobox 1176 1235 formfactor_pos = 0 1177 1236 for ind_form in range(self.formfactorbox.GetCount()): 1178 if self.formfactorbox.GetString(ind_form) == \1179 (state.formfactorcombobox):1237 if (self.formfactorbox.GetString(ind_form) 1238 == state.formfactorcombobox): 1180 1239 formfactor_pos = int(ind_form) 1181 1240 break … … 1187 1246 state.structurecombobox = unicode(state.structurecombobox) 1188 1247 for ind_struct in range(self.structurebox.GetCount()): 1189 if self.structurebox.GetString(ind_struct) == \1190 (state.structurecombobox):1248 if (self.structurebox.GetString(ind_struct) 1249 == state.structurecombobox): 1191 1250 structfactor_pos = int(ind_struct) 1192 1251 break … … 1239 1298 self.dI_sqrdata.SetValue(state.dI_sqrdata) 1240 1299 self.dI_idata.SetValue(state.dI_idata) 1241 except :1300 except Exception: 1242 1301 # to support older state file formats 1243 1302 self.dI_noweight.SetValue(False) … … 1295 1354 self.weights = copy.deepcopy(state.weights) 1296 1355 1297 for key, disp_type in state. _disp_obj_dict.iteritems():1356 for key, disp_type in state.disp_obj_dict.iteritems(): 1298 1357 # disp_model = disp 1299 1358 disp_model = POLYDISPERSITY_MODELS[disp_type]() … … 1529 1588 try: 1530 1589 self.npts_x = float(self.Npts_total.GetValue()) 1531 except :1590 except Exception: 1532 1591 flag = False 1533 1592 return flag … … 1570 1629 return 1571 1630 1572 for j in range(len(listtorestore)):1631 for item_page in listtorestore: 1573 1632 for param in statelist: 1574 if param[1] == listtorestore[j][1]: 1575 item_page = listtorestore[j] 1633 if param[1] == item_page[1]: 1576 1634 item_page_info = param 1577 1635 if (item_page_info[1] == "theta" or item_page_info[1] == … … 1619 1677 listtorestore = copy.deepcopy(statelist) 1620 1678 1621 for j in range(len(listtorestore)): 1622 item_page = listtorestore[j] 1623 item_page_info = statelist[j] 1679 for item_page, item_page_info in zip(listtorestore, statelist): 1624 1680 # change the state of the check box for simple parameters 1625 1626 1681 if item_page[0] is not None: 1627 1682 item_page[0].SetValue(format_number(item_page_info[0], True)) … … 1693 1748 :param chisqr: update chisqr value [bool] 1694 1749 """ 1695 wx.CallAfter(self._draw_model_after, update_chisqr, source) 1750 self.threaded_draw_queue.put([copy.copy(update_chisqr), copy.copy(source)]) 1751 1752 def _threaded_draw_worker(self, threaded_draw_queue): 1753 while True: 1754 # sit and wait for the next task 1755 next_task = threaded_draw_queue.get() 1756 1757 # sleep for 1/10th second in case some other tasks accumulate 1758 time.sleep(0.1) 1759 1760 # skip all intermediate tasks 1761 while self.threaded_draw_queue.qsize() > 0: 1762 self.threaded_draw_queue.task_done() 1763 next_task = self.threaded_draw_queue.get() 1764 1765 # and finally, do the task 1766 self._draw_model_after(*next_task) 1767 threaded_draw_queue.task_done() 1696 1768 1697 1769 def _draw_model_after(self, update_chisqr=True, source='model'): … … 1711 1783 temp_smear = self.current_smearer 1712 1784 # compute weight for the current data 1713 from sas.sasgui.perspectives.fitting.utils import get_weight1714 1785 flag = self.get_weight_flag() 1715 1786 weight = get_weight(data=self.data, is2d=self._is_2D(), flag=flag) 1716 1787 toggle_mode_on = self.model_view.IsEnabled() 1717 1788 is_2d = self._is_2D() 1789 1718 1790 self._manager.draw_model(self.model, 1719 1791 data=self.data, … … 1737 1809 1738 1810 from sas.sasgui.plottools import Data1D as pf_data1d 1739 # from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel1740 1811 from sas.sasgui.guiframe.local_perspectives.plotting.profile_dialog \ 1741 1812 import SLDPanel … … 1798 1869 if mod_cat == CUSTOM_MODEL: 1799 1870 for model in self.model_list_box[mod_cat]: 1800 m_list.append(self.model_dict [model.name])1871 m_list.append(self.model_dictionary[model.name]) 1801 1872 else: 1802 1873 cat_dic = self.master_category_dict[mod_cat] 1803 for (model, enabled)in cat_dic:1874 for model, enabled in cat_dic: 1804 1875 if enabled: 1805 m_list.append(self.model_dict [model])1876 m_list.append(self.model_dictionary[model]) 1806 1877 except Exception: 1807 1878 msg = traceback.format_exc() … … 1875 1946 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1876 1947 return 1877 except :1948 except Exception: 1878 1949 tcrtl.SetBackgroundColour("pink") 1879 1950 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] … … 1932 2003 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 1933 2004 return 1934 except :2005 except Exception: 1935 2006 tcrtl.SetBackgroundColour("pink") 1936 2007 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] … … 2032 2103 2033 2104 if struct_factor is not None: 2034 from sasmodels.sasview_model import MultiplicationModel2035 2105 self.model = MultiplicationModel(form_factor(self.multi_factor), 2036 2106 struct_factor()) … … 2110 2180 # q value from qx and qy 2111 2181 radius = np.sqrt(data.qx_data * data.qx_data + 2112 2182 data.qy_data * data.qy_data) 2113 2183 # get unmasked index 2114 2184 index_data = (float(self.qmin.GetValue()) <= radius) & \ … … 2339 2409 put gaussian dispersity into current model 2340 2410 """ 2341 if len(self.param_toFit) > 0:2411 if self.param_toFit: 2342 2412 for item in self.fittable_param: 2343 2413 if item in self.param_toFit: … … 2354 2424 self.weights = {} 2355 2425 2356 # from sas.models.dispersion_models import GaussianDispersion 2357 from sasmodels.weights import GaussianDispersion 2358 if len(self.disp_cb_dict) == 0: 2359 self.save_current_state() 2426 if not self.disp_cb_dict: 2360 2427 self.sizer4_4.Clear(True) 2361 self.Layout() 2362 return 2363 if (len(self.disp_cb_dict) > 0): 2428 else: 2364 2429 for p in self.disp_cb_dict: 2365 2430 # The parameter was un-selected. … … 2434 2499 self._disp_obj_dict[name1] = disp_model 2435 2500 self.model.set_dispersion(param_name, disp_model) 2436 self.state. _disp_obj_dict[name1] = disp_model.type2501 self.state.disp_obj_dict[name1] = disp_model.type 2437 2502 2438 2503 value1 = str(format_number(self.model.getParam(name1), True)) … … 2549 2614 self._disp_obj_dict[name] = disp 2550 2615 self.model.set_dispersion(name.split('.')[0], disp) 2551 self.state. _disp_obj_dict[name] = disp.type2616 self.state.disp_obj_dict[name] = disp.type 2552 2617 self.values[name] = values 2553 2618 self.weights[name] = weights … … 2751 2816 "", name + " Help") 2752 2817 else: 2753 _TreeLocation = 'user/ index.html'2818 _TreeLocation = 'user/sasgui/perspectives/fitting/models/index.html' 2754 2819 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2755 2820 "", "General Model Help") … … 2788 2853 def _on_mag_angle_help(self, event): 2789 2854 """ 2790 Bring up Magnetic Angle definition bmpimage whenever the ? button2855 Bring up Magnetic Angle definition.png image whenever the ? button 2791 2856 is clicked. Calls DocumentationWindow with the path of the location 2792 2857 within the documentation tree (after /doc/ ....". When using old … … 2802 2867 """ 2803 2868 2804 _TreeLocation = "_images/M_angles_pic. bmp"2869 _TreeLocation = "_images/M_angles_pic.png" 2805 2870 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2806 2871 "Magnetic Angle Defintions") … … 2808 2873 def _on_mag_help(self, event): 2809 2874 """ 2810 Bring up Magnetic Angle definition bmpimage whenever the ? button2875 Bring up Magnetic Angle definition.png image whenever the ? button 2811 2876 is clicked. Calls DocumentationWindow with the path of the location 2812 2877 within the documentation tree (after /doc/ ....". When using old … … 2822 2887 """ 2823 2888 2824 _TreeLocation = "user/ magnetism.html"2889 _TreeLocation = "user/sasgui/perspectives/fitting/magnetism/magnetism.html" 2825 2890 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2826 2891 "Polarized Beam/Magnetc Help") … … 2868 2933 """ 2869 2934 2870 _TreeLocation = "user/sasgui/perspectives/fitting/pd _help.html"2935 _TreeLocation = "user/sasgui/perspectives/fitting/pd/polydispersity.html" 2871 2936 _PageAnchor = "" 2872 2937 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, … … 2907 2972 # go through the parameters 2908 2973 strings = self._get_copy_helper(self.parameters, 2909 self.orientation_params)2974 self.orientation_params) 2910 2975 content += strings 2911 2976 2912 2977 # go through the fittables 2913 2978 strings = self._get_copy_helper(self.fittable_param, 2914 self.orientation_params_disp)2979 self.orientation_params_disp) 2915 2980 content += strings 2916 2981 2917 2982 # go through the fixed params 2918 2983 strings = self._get_copy_helper(self.fixed_param, 2919 self.orientation_params_disp)2984 self.orientation_params_disp) 2920 2985 content += strings 2921 2986 2922 2987 # go through the str params 2923 2988 strings = self._get_copy_helper(self.str_parameters, 2924 self.orientation_params)2989 self.orientation_params) 2925 2990 content += strings 2926 2991 return content … … 2928 2993 return False 2929 2994 2995 2996 def _get_copy_params_details(self): 2997 """ 2998 Combines polydisperse parameters with self.parameters so that they can 2999 be written to the clipboard (for Excel or LaTeX). Also returns a list of 3000 the names of parameters that have been fitted 3001 3002 :returns: all_params - A list of all parameters, in the format of 3003 self.parameters 3004 :returns: fitted_par_names - A list of the names of parameters that have 3005 been fitted 3006 """ 3007 # Names of params that are being fitted 3008 fitted_par_names = [param[1] for param in self.param_toFit] 3009 # Names of params with associated polydispersity 3010 disp_params = [param[1].split('.')[0] for param in self.fittable_param] 3011 3012 # Create array of all parameters 3013 all_params = copy.copy(self.parameters) 3014 for param in self.parameters: 3015 if param[1] in disp_params: 3016 # Polydisperse params aren't in self.parameters, so need adding 3017 # to all_params 3018 name = param[1] + ".width" 3019 index = all_params.index(param) + 1 3020 to_insert = [] 3021 if name in fitted_par_names: 3022 # Param is fitted, so already has a param list in self.param_toFit 3023 to_insert = self.param_toFit[fitted_par_names.index(name)] 3024 else: 3025 # Param isn't fitted, so mockup a param list 3026 to_insert = [None, name, self.model.getParam(name), None, None] 3027 all_params.insert(index, to_insert) 3028 return all_params, fitted_par_names 3029 2930 3030 def get_copy_excel(self): 2931 3031 """ … … 2941 3041 Get the string copies of the param names and values in the tap 2942 3042 """ 3043 if not self.parameters: 3044 # Do nothing if parameters doesn't exist 3045 return False 3046 2943 3047 content = '' 2944 2945 3048 crlf = chr(13) + chr(10) 2946 3049 tab = chr(9) 2947 3050 2948 # Do it if params exist 2949 if self.parameters: 2950 2951 for param in self.parameters: 2952 content += param[1] # parameter name 3051 all_params, fitted_param_names = self._get_copy_params_details() 3052 3053 # Construct row of parameter names 3054 for param in all_params: 3055 name = param[1] # Parameter name 3056 content += name 3057 content += tab 3058 if name in fitted_param_names: 3059 # Only print errors for fitted parameters 3060 content += name + "_err" 2953 3061 content += tab 2954 content += param[1] + "_err" 3062 3063 content += crlf 3064 3065 # Construct row of parameter values and errors 3066 for param in all_params: 3067 value = param[2] 3068 if hasattr(value, 'GetValue'): 3069 # param[2] is a text box 3070 value = value.GetValue() 3071 else: 3072 # param[2] is a float (from our self._get_copy_params_details) 3073 value = str(value) 3074 content += value 3075 content += tab 3076 if param[1] in fitted_param_names: 3077 # Only print errors for fitted parameters 3078 content += param[4].GetValue() 2955 3079 content += tab 2956 3080 2957 content += crlf 2958 2959 # row of values and errors... 2960 for param in self.parameters: 2961 content += param[2].GetValue() # value 2962 content += tab 2963 content += param[4].GetValue() # error 2964 content += tab 2965 2966 return content 2967 else: 2968 return False 3081 return content 2969 3082 2970 3083 def get_copy_latex(self): … … 2981 3094 Get the string copies of the param names and values in the tap 2982 3095 """ 2983 content = '\\begin{table}' 2984 content += '\\begin{tabular}[h]' 3096 if not self.parameters: 3097 # Do nothing if self.parameters doesn't exist 3098 return False 3099 3100 content = r'\begin{table}' 3101 content += r'\begin{tabular}[h]' 2985 3102 2986 3103 crlf = chr(13) + chr(10) 2987 3104 tab = chr(9) 2988 3105 2989 # Do it if params exist 2990 if self.parameters: 2991 2992 content += '{|' 2993 for param in self.parameters: 2994 content += 'l|l|' 2995 content += '}\hline' 2996 content += crlf 2997 2998 for index, param in enumerate(self.parameters): 2999 content += param[1].replace('_', '\_') # parameter name 3106 all_params, fitted_param_names = self._get_copy_params_details() 3107 3108 content += '{|' 3109 for param in all_params: 3110 content += 'l|l|' 3111 content += r'}\hline' 3112 content += crlf 3113 3114 # Construct row of parameter names 3115 for index, param in enumerate(all_params): 3116 name = param[1] # Parameter name 3117 content += name.replace('_', r'\_') # Escape underscores 3118 if name in fitted_param_names: 3119 # Only print errors for fitted parameters 3000 3120 content += ' & ' 3001 content += param[1].replace('_', '\_') + "\_err" 3002 if index < len(self.parameters) - 1: 3003 content += ' & ' 3004 content += '\\\\ \\hline' 3005 content += crlf 3006 3007 # row of values and errors... 3008 for index, param in enumerate(self.parameters): 3009 content += param[2].GetValue() # parameter value 3121 content += name.replace('_', r'\_') + r"\_err" 3122 if index < len(all_params) - 1: 3010 3123 content += ' & ' 3011 content += param[4].GetValue() # parameter error 3012 if index < len(self.parameters) - 1: 3013 content += ' & ' 3014 content += '\\\\ \\hline' 3015 content += crlf 3016 3017 content += '\\end{tabular}' 3018 content += '\\end{table}' 3019 return content 3020 else: 3021 return False 3124 3125 content += r'\\ \hline' 3126 content += crlf 3127 3128 # Construct row of values and errors 3129 for index, param in enumerate(all_params): 3130 value = param[2] 3131 if hasattr(value, "GetValue"): 3132 # value is a text box 3133 value = value.GetValue() 3134 else: 3135 # value is a float (from self._get_copy_params_details) 3136 value = str(value) 3137 content += value 3138 if param[1] in fitted_param_names: 3139 # Only print errors for fitted params 3140 content += ' & ' 3141 content += param[4].GetValue() 3142 if index < len(all_params) - 1: 3143 content += ' & ' 3144 3145 content += r'\\ \hline' 3146 content += crlf 3147 content += r'\end{tabular}' 3148 content += r'\end{table}' 3149 3150 return content 3022 3151 3023 3152 def set_clipboard(self, content=None): … … 3274 3403 if name.endswith('.npts'): 3275 3404 pd = int(pd) 3276 except :3405 except Exception: 3277 3406 # continue 3278 3407 if not pd and pd != '': … … 3360 3489 self._disp_obj_dict[name] = disp_model 3361 3490 self.model.set_dispersion(param_name, disp_model) 3362 self.state. _disp_obj_dict[name] = disp_model.type3491 self.state.disp_obj_dict[name] = disp_model.type 3363 3492 # TODO: It's not an array, why update values and weights? 3364 3493 self.model._persistency_dict[param_name] = \ … … 3460 3589 self.model_box.Clear() 3461 3590 3462 if category == 'Plugin Models':3591 if category == CUSTOM_MODEL: 3463 3592 for model in self.model_list_box[category]: 3464 3593 str_m = str(model).split(".")[0] … … 3466 3595 3467 3596 else: 3468 for (model, enabled)in sorted(self.master_category_dict[category],3469 3470 if (enabled):3597 for model, enabled in sorted(self.master_category_dict[category], 3598 key=lambda name: name[0]): 3599 if enabled: 3471 3600 self.model_box.Append(model) 3472 3601 … … 3709 3838 self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 3710 3839 self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus 3711 if kill_focus_callback is None else kill_focus_callback)3840 if kill_focus_callback is None else kill_focus_callback) 3712 3841 self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter 3713 if text_enter_callback is None else text_enter_callback)3842 if text_enter_callback is None else text_enter_callback) 3714 3843 if not ON_MAC: 3715 3844 self.Bind(wx.EVT_LEFT_UP, self._highlight_text 3716 if mouse_up_callback is None else mouse_up_callback)3845 if mouse_up_callback is None else mouse_up_callback) 3717 3846 3718 3847 def _on_set_focus(self, event):
Note: See TracChangeset
for help on using the changeset viewer.