Changeset 4036cb0 in sasview
- Timestamp:
- Aug 31, 2016 11:08:23 AM (8 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7b15990, a3f1c11e
- Parents:
- 2c60f304 (diff), ee4b3cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
re4c897b ree4b3cb 1504 1504 is_2Ddata = True 1505 1505 if self.model != None: 1506 try: 1507 is_modified = self._check_value_enter(self.fittable_param, 1508 is_modified) 1509 is_modified = self._check_value_enter(self.fixed_param, 1510 is_modified) 1511 is_modified = self._check_value_enter(self.parameters, 1512 is_modified) 1513 except Exception: 1514 logging.error(traceback.format_exc()) 1506 is_modified = (self._check_value_enter(self.fittable_param) 1507 or self._check_value_enter(self.fixed_param) 1508 or self._check_value_enter(self.parameters)) 1515 1509 1516 1510 # Here we should check whether the boundaries have been modified. … … 1561 1555 flag = True 1562 1556 self.fitrange = True 1563 is_modified = False1564 1557 1565 1558 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ … … 1574 1567 [self.data]) 1575 1568 ##Check the values 1576 self._check_value_enter(self.fittable_param , is_modified)1577 self._check_value_enter(self.fixed_param , is_modified)1578 self._check_value_enter(self.parameters , is_modified)1569 self._check_value_enter(self.fittable_param) 1570 self._check_value_enter(self.fixed_param) 1571 self._check_value_enter(self.parameters) 1579 1572 1580 1573 # If qmin and qmax have been modified, update qmin and qmax and … … 1660 1653 return flag 1661 1654 1662 def _is_modified(self, is_modified):1663 """1664 return to self._is_modified1665 """1666 return is_modified1667 1668 1655 def _reset_parameters_state(self, listtorestore, statelist): 1669 1656 """ … … 1964 1951 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1965 1952 # Flag to register when a parameter has changed. 1966 #is_modified = False1967 1953 if tcrtl.GetValue().lstrip().rstrip() != "": 1968 1954 try: … … 1994 1980 if temp_npts != self.num_points: 1995 1981 self.num_points = temp_npts 1996 #is_modified = True1997 1982 else: 1998 1983 msg = "Cannot plot: No points in Q range!!! " … … 2170 2155 self.Layout() 2171 2156 2157 2172 2158 def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 2173 2159 """ … … 2276 2262 return flag 2277 2263 2278 def _check_value_enter(self, list , modified):2264 def _check_value_enter(self, list): 2279 2265 """ 2280 2266 :param list: model parameter and panel info … … 2286 2272 parameter's maximum value , 2287 2273 parameter's units] 2288 """ 2289 is_modified = modified2290 if len(list) == 0:2291 return is_modified2274 2275 Returns True if the model parameters have changed. 2276 """ 2277 is_modified = False 2292 2278 for item in list: 2293 2279 #skip angle parameters for 1D 2294 if not self.enable2D: 2295 if item in self.orientation_params: 2296 continue 2297 #try: 2280 if not self.enable2D and item in self.orientation_params: 2281 continue 2282 2298 2283 name = str(item[1]) 2299 2300 if string.find(name, ".npts") == -1 and \ 2301 string.find(name, ".nsigmas") == -1: 2302 ## check model parameters range 2303 param_min = None 2304 param_max = None 2305 2306 ## check minimun value 2307 if item[5] != None and item[5] != "": 2308 if item[5].GetValue().lstrip().rstrip() != "": 2309 try: 2310 param_min = float(item[5].GetValue()) 2311 if not self._validate_qrange(item[5], item[2]): 2312 if numpy.isfinite(param_min): 2313 item[2].SetValue(format_number(param_min)) 2314 2315 item[5].SetBackgroundColour(wx.WHITE) 2316 item[2].SetBackgroundColour(wx.WHITE) 2317 2318 except: 2319 msg = "Wrong fit parameter range entered" 2320 wx.PostEvent(self._manager.parent, 2321 StatusEvent(status=msg)) 2322 raise ValueError, msg 2323 is_modified = True 2324 ## check maximum value 2325 if item[6] != None and item[6] != "": 2326 if item[6].GetValue().lstrip().rstrip() != "": 2327 try: 2328 param_max = float(item[6].GetValue()) 2329 if not self._validate_qrange(item[2], item[6]): 2330 if numpy.isfinite(param_max): 2331 item[2].SetValue(format_number(param_max)) 2332 2333 item[6].SetBackgroundColour(wx.WHITE) 2334 item[2].SetBackgroundColour(wx.WHITE) 2335 except: 2336 msg = "Wrong Fit parameter range entered " 2337 wx.PostEvent(self._manager.parent, 2338 StatusEvent(status=msg)) 2339 raise ValueError, msg 2340 is_modified = True 2341 2342 if param_min != None and param_max != None: 2343 if not self._validate_qrange(item[5], item[6]): 2344 msg = "Wrong Fit range entered for parameter " 2345 msg += "name %s of model %s " % (name, self.model.name) 2346 wx.PostEvent(self._manager.parent, 2347 StatusEvent(status=msg)) 2348 2349 if name in self.model.details.keys(): 2350 self.model.details[name][1:3] = param_min, param_max 2351 is_modified = True 2352 else: 2353 self.model.details[name] = ["", param_min, param_max] 2354 is_modified = True 2355 try: 2356 # Check if the textctr is enabled 2357 if item[2].IsEnabled(): 2358 value = float(item[2].GetValue()) 2359 item[2].SetBackgroundColour("white") 2360 # If the value of the parameter has changed, 2361 # +update the model and set the is_modified flag 2362 if value != self.model.getParam(name) and \ 2363 numpy.isfinite(value): 2364 self.model.setParam(name, value) 2365 except: 2366 item[2].SetBackgroundColour("pink") 2367 msg = "Wrong Fit parameter value entered " 2368 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2284 if name.endswith(".npts") or name.endswith(".nsigmas"): 2285 continue 2286 2287 # Check that min, max and value are floats 2288 value_ctrl, min_ctrl, max_ctrl = item[2], item[5], item[6] 2289 min_str = min_ctrl.GetValue().strip() 2290 max_str = max_ctrl.GetValue().strip() 2291 value_str = value_ctrl.GetValue().strip() 2292 validity = check_float(value_ctrl) 2293 if min_str != "": 2294 validity = validity and check_float(min_ctrl) 2295 if max_str != "": 2296 validity = validity and check_float(max_ctrl) 2297 if not validity: 2298 continue 2299 2300 # Check that min is less than max 2301 low = -numpy.inf if min_str == "" else float(min_str) 2302 high = numpy.inf if max_str == "" else float(max_str) 2303 if high < low: 2304 min_ctrl.SetBackgroundColour("pink") 2305 min_ctrl.Refresh() 2306 max_ctrl.SetBackgroundColour("pink") 2307 max_ctrl.Refresh() 2308 #msg = "Invalid fit range for %s: min must be smaller than max"%name 2309 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2310 continue 2311 2312 # Force value between min and max 2313 value = float(value_str) 2314 if value < low: 2315 value = low 2316 value_ctrl.SetValue(format_number(value)) 2317 elif value > high: 2318 value = high 2319 value_ctrl.SetValue(format_number(value)) 2320 2321 # Update value in model if it has changed 2322 if value != self.model.getParam(name): 2323 self.model.setParam(name, value) 2324 is_modified = True 2325 2326 if name not in self.model.details.keys(): 2327 self.model.details[name] = ["", None, None] 2328 old_low, old_high = self.model.details[name][1:3] 2329 if old_low != low or old_high != high: 2330 # The configuration has changed but it won't change the 2331 # computed curve so no need to set is_modified to True 2332 #is_modified = True 2333 self.model.details[name][1:3] = low, high 2369 2334 2370 2335 return is_modified -
src/sas/sasgui/perspectives/fitting/batchfitpage.py
rfc18690 ree4b3cb 256 256 # if self.model != None: 257 257 # ##Check the values 258 # self._check_value_enter( self.fittable_param , is_modified)259 # self._check_value_enter( self.fixed_param , is_modified)260 # self._check_value_enter( self.parameters , is_modified)258 # self._check_value_enter( self.fittable_param) 259 # self._check_value_enter( self.fixed_param) 260 # self._check_value_enter( self.parameters) 261 261 # 262 262 # # If qmin and qmax have been modified, update qmin and qmax and -
src/sas/sasgui/perspectives/fitting/fitpage.py
r934ce649 ree4b3cb 1365 1365 try: 1366 1366 tcrtl.SetBackgroundColour(wx.WHITE) 1367 self._check_value_enter(self.fittable_param , is_modified)1368 self._check_value_enter(self.parameters , is_modified)1367 self._check_value_enter(self.fittable_param) 1368 self._check_value_enter(self.parameters) 1369 1369 except: 1370 1370 tcrtl.SetBackgroundColour("pink") -
src/sas/sascalc/pr/invertor.py
rb699768 r2c60f304 154 154 return self.set_err(value2) 155 155 elif name == 'd_max': 156 if value <= 0.0: 157 msg = "Invertor: d_max must be greater than zero." 158 msg += "Correct that entry before proceeding" 159 raise ValueError, msg 156 160 return self.set_dmax(value) 157 161 elif name == 'q_min':
Note: See TracChangeset
for help on using the changeset viewer.