Changeset b8080e1 in sasview for src/sas/sascalc/pr/invertor.py
- Timestamp:
- Aug 29, 2018 10:01:23 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 9463ca2
- Parents:
- ce30949
- git-author:
- Piotr Rozyczko <rozyczko@…> (08/29/18 09:59:56)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (08/29/18 10:01:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/invertor.py
r6da860a rb8080e1 222 222 elif name == 'est_bck': 223 223 value = self.get_est_bck() 224 if value == 1: 225 return True 226 else: 227 return False 224 return value == 1 228 225 elif name in self.__dict__: 229 226 return self.__dict__[name] … … 460 457 461 458 # If we need to fit the background, add a term 462 if self.est_bck == True:459 if self.est_bck: 463 460 nfunc_0 = nfunc 464 461 nfunc += 1 … … 500 497 cov = np.linalg.pinv(inv_cov) 501 498 err = math.fabs(chi2 / float(npts - nfunc)) * cov 502 except Exception as ex:499 except: 503 500 # We were not able to estimate the errors 504 501 # Return an empty error matrix 505 logger.error( ex)502 logger.error(sys.exc_value) 506 503 507 504 # Keep a copy of the last output 508 if self.est_bck == False:505 if not self.est_bck: 509 506 self.out = c 510 507 self.cov = err … … 540 537 541 538 """ 542 from sas.sascalc.pr.num_term import NTermEstimator539 from .num_term import NTermEstimator 543 540 estimator = NTermEstimator(self.clone()) 544 541 try: 545 542 return estimator.num_terms(isquit_func) 546 except Exception as ex:543 except: 547 544 # If we fail, estimate alpha and return the default 548 545 # number of terms 549 546 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 550 logger.warning("Invertor.estimate_numterms: %s" % ex)547 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 551 548 return self.nfunc, best_alpha, "Could not estimate number of terms" 552 549 … … 634 631 return best_alpha, message, elapsed 635 632 636 except Exception as ex:637 message = "Invertor.estimate_alpha: %s" % ex633 except: 634 message = "Invertor.estimate_alpha: %s" % sys.exc_value 638 635 return 0, message, elapsed 639 636 … … 658 655 file.write("#slit_width=%g\n" % self.slit_width) 659 656 file.write("#background=%g\n" % self.background) 660 if self.est_bck == True:657 if self.est_bck: 661 658 file.write("#has_bck=1\n") 662 659 else: … … 738 735 elif line.startswith('#has_bck='): 739 736 toks = line.split('=') 740 if int(toks[1]) == 1: 741 self.est_bck = True 742 else: 743 self.est_bck = False 737 self.est_bck = int(toks[1]) == 1 744 738 745 739 # Now read in the parameters … … 754 748 self.cov[i][i] = float(toks2[1]) 755 749 756 except Exception as ex:757 msg = "Invertor.from_file: corrupted file\n%s" % ex750 except: 751 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 758 752 raise RuntimeError(msg) 759 753 else:
Note: See TracChangeset
for help on using the changeset viewer.