Changeset b8080e1 in sasview for src/sas/sascalc/pr
- Timestamp:
- Aug 29, 2018 10:01:23 AM (7 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)
- Location:
- src/sas/sascalc/pr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/c_extensions/Cinvertor.c
rd04ac05 rb8080e1 735 735 736 736 const char get_peaks_doc[] = 737 "Returns the number of peaks in the output P(r) distr ubution\n"737 "Returns the number of peaks in the output P(r) distribution\n" 738 738 "for the given set of coefficients.\n" 739 739 " @param args: c-parameters\n" -
src/sas/sascalc/pr/fit/AbstractFitEngine.py
r574adc7 rb8080e1 78 78 def get_params(self, fitparams): 79 79 """ 80 return a list of value of param ter to fit81 82 :param fitparams: list of param aters name to fit80 return a list of value of parameter to fit 81 82 :param fitparams: list of parameters name to fit 83 83 84 84 """ -
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: -
src/sas/sascalc/pr/num_term.py
r8f83719f rb8080e1 55 55 medi = 0 56 56 for i in range(dv): 57 if odd == True:57 if odd: 58 58 medi = osc[int(med)] 59 59 else: … … 98 98 new_osc3.append(self.osc_list[i]) 99 99 100 if flag9 == True:100 if flag9: 101 101 self.dataset = new_osc1 102 elif flag8 == True:102 elif flag8: 103 103 self.dataset = new_osc2 104 104 else: … … 141 141 div = len(nts) 142 142 tem = float(div) / 2.0 143 odd = self.is_odd(div) 144 if odd == True: 143 if self.is_odd(div): 145 144 nt = nts[int(tem)] 146 145 else: … … 148 147 return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 149 148 except: 150 #TODO: check the logic above and make sure it doesn't 149 #TODO: check the logic above and make sure it doesn't 151 150 # rely on the try-except. 152 151 return self.nterm_min, self.invertor.alpha, '' … … 183 182 data_y = np.append(data_y, test_y) 184 183 data_err = np.append(data_err, err) 185 except Exception as ex:186 logger.error( ex)184 except: 185 logger.error(sys.exc_value) 187 186 188 187 return data_x, data_y, data_err
Note: See TracChangeset
for help on using the changeset viewer.