Changeset ba8d326 in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Jun 23, 2017 4:16:29 PM (7 years ago)
- Branches:
- master, 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 98e3f24
- Parents:
- 81b35396
- git-author:
- Paul Kienzle <pkienzle@…> (06/21/17 12:38:48)
- git-committer:
- Paul Kienzle <pkienzle@…> (06/23/17 16:16:29)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r81b35396 rba8d326 285 285 """ 286 286 x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 287 287 num=self.npts_x, endpoint=True) 288 288 self.data = Data1D(x=x) 289 289 self.data.xaxis('\\rm{Q}', "A^{-1}") … … 311 311 312 312 x = np.logspace(start=qmin, stop=qmax, 313 313 num=self.npts_x, endpoint=True, base=10.0) 314 314 self.data = Data1D(x=x) 315 315 self.data.xaxis('\\rm{Q}', "A^{-1}") … … 904 904 if len(self._disp_obj_dict) > 0: 905 905 for k, v in self._disp_obj_dict.iteritems(): 906 self.state. _disp_obj_dict[k] = v.type906 self.state.disp_obj_dict[k] = v.type 907 907 908 908 self.state.values = copy.deepcopy(self.values) … … 922 922 self.state.str_parameters) 923 923 self._copy_parameters_state(self.orientation_params, 924 924 self.state.orientation_params) 925 925 self._copy_parameters_state(self.orientation_params_disp, 926 926 self.state.orientation_params_disp) … … 976 976 try: 977 977 self.state.disp_cb_dict[k] = v.GetValue() 978 except :978 except Exception: 979 979 self.state.disp_cb_dict[k] = None 980 980 if len(self._disp_obj_dict) > 0: 981 981 for k, v in self._disp_obj_dict.iteritems(): 982 self.state. _disp_obj_dict[k] = v.type982 self.state.disp_obj_dict[k] = v.type 983 983 984 984 self.state.values = copy.deepcopy(self.values) … … 1022 1022 # to support older version 1023 1023 category_pos = int(state.categorycombobox) 1024 except :1024 except Exception: 1025 1025 category_pos = 0 1026 1026 for ind_cat in range(self.categorybox.GetCount()): … … 1034 1034 # to support older version 1035 1035 formfactor_pos = int(state.formfactorcombobox) 1036 except :1036 except Exception: 1037 1037 formfactor_pos = 0 1038 1038 for ind_form in range(self.formfactorbox.GetCount()): … … 1047 1047 # to support older version 1048 1048 structfactor_pos = int(state.structurecombobox) 1049 except :1049 except Exception: 1050 1050 structfactor_pos = 0 1051 1051 for ind_struct in range(self.structurebox.GetCount()): … … 1284 1284 self.dI_sqrdata.SetValue(state.dI_sqrdata) 1285 1285 self.dI_idata.SetValue(state.dI_idata) 1286 except :1286 except Exception: 1287 1287 # to support older state file formats 1288 1288 self.dI_noweight.SetValue(False) … … 1340 1340 self.weights = copy.deepcopy(state.weights) 1341 1341 1342 for key, disp_type in state. _disp_obj_dict.iteritems():1342 for key, disp_type in state.disp_obj_dict.iteritems(): 1343 1343 # disp_model = disp 1344 1344 disp_model = POLYDISPERSITY_MODELS[disp_type]() … … 1574 1574 try: 1575 1575 self.npts_x = float(self.Npts_total.GetValue()) 1576 except :1576 except Exception: 1577 1577 flag = False 1578 1578 return flag … … 1615 1615 return 1616 1616 1617 for j in range(len(listtorestore)):1617 for item_page in listtorestore: 1618 1618 for param in statelist: 1619 if param[1] == listtorestore[j][1]: 1620 item_page = listtorestore[j] 1619 if param[1] == item_page[1]: 1621 1620 item_page_info = param 1622 1621 if (item_page_info[1] == "theta" or item_page_info[1] == … … 1664 1663 listtorestore = copy.deepcopy(statelist) 1665 1664 1666 for j in range(len(listtorestore)): 1667 item_page = listtorestore[j] 1668 item_page_info = statelist[j] 1665 for item_page, item_page_info in zip(listtorestore, statelist): 1669 1666 # change the state of the check box for simple parameters 1670 1671 1667 if item_page[0] is not None: 1672 1668 item_page[0].SetValue(format_number(item_page_info[0], True)) … … 1921 1917 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1922 1918 return 1923 except :1919 except Exception: 1924 1920 tcrtl.SetBackgroundColour("pink") 1925 1921 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] … … 1978 1974 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 1979 1975 return 1980 except :1976 except Exception: 1981 1977 tcrtl.SetBackgroundColour("pink") 1982 1978 msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1] … … 2156 2152 # q value from qx and qy 2157 2153 radius = np.sqrt(data.qx_data * data.qx_data + 2158 2154 data.qy_data * data.qy_data) 2159 2155 # get unmasked index 2160 2156 index_data = (float(self.qmin.GetValue()) <= radius) & \ … … 2385 2381 put gaussian dispersity into current model 2386 2382 """ 2387 if len(self.param_toFit) > 0:2383 if self.param_toFit: 2388 2384 for item in self.fittable_param: 2389 2385 if item in self.param_toFit: … … 2402 2398 # from sas.models.dispersion_models import GaussianDispersion 2403 2399 from sasmodels.weights import GaussianDispersion 2404 if len(self.disp_cb_dict) == 0: 2405 self.save_current_state() 2400 if not self.disp_cb_dict: 2406 2401 self.sizer4_4.Clear(True) 2407 self.Layout() 2408 return 2409 if (len(self.disp_cb_dict) > 0): 2402 else: 2410 2403 for p in self.disp_cb_dict: 2411 2404 # The parameter was un-selected. … … 2480 2473 self._disp_obj_dict[name1] = disp_model 2481 2474 self.model.set_dispersion(param_name, disp_model) 2482 self.state. _disp_obj_dict[name1] = disp_model.type2475 self.state.disp_obj_dict[name1] = disp_model.type 2483 2476 2484 2477 value1 = str(format_number(self.model.getParam(name1), True)) … … 2595 2588 self._disp_obj_dict[name] = disp 2596 2589 self.model.set_dispersion(name.split('.')[0], disp) 2597 self.state. _disp_obj_dict[name] = disp.type2590 self.state.disp_obj_dict[name] = disp.type 2598 2591 self.values[name] = values 2599 2592 self.weights[name] = weights … … 2953 2946 # go through the parameters 2954 2947 strings = self._get_copy_helper(self.parameters, 2955 self.orientation_params)2948 self.orientation_params) 2956 2949 content += strings 2957 2950 2958 2951 # go through the fittables 2959 2952 strings = self._get_copy_helper(self.fittable_param, 2960 self.orientation_params_disp)2953 self.orientation_params_disp) 2961 2954 content += strings 2962 2955 2963 2956 # go through the fixed params 2964 2957 strings = self._get_copy_helper(self.fixed_param, 2965 self.orientation_params_disp)2958 self.orientation_params_disp) 2966 2959 content += strings 2967 2960 2968 2961 # go through the str params 2969 2962 strings = self._get_copy_helper(self.str_parameters, 2970 self.orientation_params)2963 self.orientation_params) 2971 2964 content += strings 2972 2965 return content … … 3027 3020 Get the string copies of the param names and values in the tap 3028 3021 """ 3029 content = '\\begin{table}'3030 content += '\\begin{tabular}[h]'3022 content = r'\begin{table}' 3023 content += r'\begin{tabular}[h]' 3031 3024 3032 3025 crlf = chr(13) + chr(10) … … 3039 3032 for param in self.parameters: 3040 3033 content += 'l|l|' 3041 content += '}\hline'3034 content += r'}\hline' 3042 3035 content += crlf 3043 3036 3044 3037 for index, param in enumerate(self.parameters): 3045 content += param[1].replace('_', '\_') # parameter name3038 content += param[1].replace('_', r'\_') # parameter name 3046 3039 content += ' & ' 3047 content += param[1].replace('_', '\_') + "\_err"3040 content += param[1].replace('_', r'\_') + r'\_err' 3048 3041 if index < len(self.parameters) - 1: 3049 3042 content += ' & ' 3050 content += '\\\\ \\hline'3043 content += r'\\ \hline' 3051 3044 content += crlf 3052 3045 … … 3058 3051 if index < len(self.parameters) - 1: 3059 3052 content += ' & ' 3060 content += '\\\\ \\hline'3053 content += r'\\ \hline' 3061 3054 content += crlf 3062 3055 3063 content += '\\end{tabular}'3064 content += '\\end{table}'3056 content += r'\end{tabular}' 3057 content += r'\end{table}' 3065 3058 return content 3066 3059 else: … … 3320 3313 if name.endswith('.npts'): 3321 3314 pd = int(pd) 3322 except :3315 except Exception: 3323 3316 # continue 3324 3317 if not pd and pd != '': … … 3406 3399 self._disp_obj_dict[name] = disp_model 3407 3400 self.model.set_dispersion(param_name, disp_model) 3408 self.state. _disp_obj_dict[name] = disp_model.type3401 self.state.disp_obj_dict[name] = disp_model.type 3409 3402 # TODO: It's not an array, why update values and weights? 3410 3403 self.model._persistency_dict[param_name] = \ … … 3512 3505 3513 3506 else: 3514 for (model, enabled)in sorted(self.master_category_dict[category],3515 3516 if (enabled):3507 for model, enabled in sorted(self.master_category_dict[category], 3508 key=lambda name: name[0]): 3509 if enabled: 3517 3510 self.model_box.Append(model) 3518 3511 … … 3755 3748 self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 3756 3749 self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus 3757 if kill_focus_callback is None else kill_focus_callback)3750 if kill_focus_callback is None else kill_focus_callback) 3758 3751 self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter 3759 if text_enter_callback is None else text_enter_callback)3752 if text_enter_callback is None else text_enter_callback) 3760 3753 if not ON_MAC: 3761 3754 self.Bind(wx.EVT_LEFT_UP, self._highlight_text 3762 if mouse_up_callback is None else mouse_up_callback)3755 if mouse_up_callback is None else mouse_up_callback) 3763 3756 3764 3757 def _on_set_focus(self, event):
Note: See TracChangeset
for help on using the changeset viewer.