Changeset b8080e1 in sasview for src/sas/sascalc/pr


Ignore:
Timestamp:
Aug 29, 2018 10:01:23 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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)
Message:

cherry picking sascalc changes from master SASVIEW-996
minor unit test fixes

Location:
src/sas/sascalc/pr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/pr/c_extensions/Cinvertor.c

    rd04ac05 rb8080e1  
    735735 
    736736const char get_peaks_doc[] = 
    737         "Returns the number of peaks in the output P(r) distrubution\n" 
     737        "Returns the number of peaks in the output P(r) distribution\n" 
    738738        "for the given set of coefficients.\n" 
    739739        " @param args: c-parameters\n" 
  • src/sas/sascalc/pr/fit/AbstractFitEngine.py

    r574adc7 rb8080e1  
    7878    def get_params(self, fitparams): 
    7979        """ 
    80         return a list of value of paramter to fit 
    81  
    82         :param fitparams: list of paramaters name to fit 
     80        return a list of value of parameter to fit 
     81 
     82        :param fitparams: list of parameters name to fit 
    8383 
    8484        """ 
  • src/sas/sascalc/pr/invertor.py

    r6da860a rb8080e1  
    222222        elif name == 'est_bck': 
    223223            value = self.get_est_bck() 
    224             if value == 1: 
    225                 return True 
    226             else: 
    227                 return False 
     224            return value == 1 
    228225        elif name in self.__dict__: 
    229226            return self.__dict__[name] 
     
    460457 
    461458        # If we need to fit the background, add a term 
    462         if self.est_bck == True: 
     459        if self.est_bck: 
    463460            nfunc_0 = nfunc 
    464461            nfunc += 1 
     
    500497            cov = np.linalg.pinv(inv_cov) 
    501498            err = math.fabs(chi2 / float(npts - nfunc)) * cov 
    502         except Exception as ex: 
     499        except: 
    503500            # We were not able to estimate the errors 
    504501            # Return an empty error matrix 
    505             logger.error(ex) 
     502            logger.error(sys.exc_value) 
    506503 
    507504        # Keep a copy of the last output 
    508         if self.est_bck == False: 
     505        if not self.est_bck: 
    509506            self.out = c 
    510507            self.cov = err 
     
    540537 
    541538        """ 
    542         from sas.sascalc.pr.num_term import NTermEstimator 
     539        from .num_term import NTermEstimator 
    543540        estimator = NTermEstimator(self.clone()) 
    544541        try: 
    545542            return estimator.num_terms(isquit_func) 
    546         except Exception as ex: 
     543        except: 
    547544            # If we fail, estimate alpha and return the default 
    548545            # number of terms 
    549546            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) 
    551548            return self.nfunc, best_alpha, "Could not estimate number of terms" 
    552549 
     
    634631                return best_alpha, message, elapsed 
    635632 
    636         except Exception as ex: 
    637             message = "Invertor.estimate_alpha: %s" % ex 
     633        except: 
     634            message = "Invertor.estimate_alpha: %s" % sys.exc_value 
    638635            return 0, message, elapsed 
    639636 
     
    658655        file.write("#slit_width=%g\n" % self.slit_width) 
    659656        file.write("#background=%g\n" % self.background) 
    660         if self.est_bck == True: 
     657        if self.est_bck: 
    661658            file.write("#has_bck=1\n") 
    662659        else: 
     
    738735                    elif line.startswith('#has_bck='): 
    739736                        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 
    744738 
    745739                    # Now read in the parameters 
     
    754748                        self.cov[i][i] = float(toks2[1]) 
    755749 
    756             except Exception as ex: 
    757                 msg = "Invertor.from_file: corrupted file\n%s" % ex 
     750            except: 
     751                msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 
    758752                raise RuntimeError(msg) 
    759753        else: 
  • src/sas/sascalc/pr/num_term.py

    r8f83719f rb8080e1  
    5555        medi = 0 
    5656        for i in range(dv): 
    57             if odd == True: 
     57            if odd: 
    5858                medi = osc[int(med)] 
    5959            else: 
     
    9898                new_osc3.append(self.osc_list[i]) 
    9999 
    100         if flag9 == True: 
     100        if flag9: 
    101101            self.dataset = new_osc1 
    102         elif flag8 == True: 
     102        elif flag8: 
    103103            self.dataset = new_osc2 
    104104        else: 
     
    141141            div = len(nts) 
    142142            tem = float(div) / 2.0 
    143             odd = self.is_odd(div) 
    144             if odd == True: 
     143            if self.is_odd(div): 
    145144                nt = nts[int(tem)] 
    146145            else: 
     
    148147            return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 
    149148        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 
    151150            # rely on the try-except. 
    152151            return self.nterm_min, self.invertor.alpha, '' 
     
    183182                data_y = np.append(data_y, test_y) 
    184183                data_err = np.append(data_err, err) 
    185             except Exception as ex: 
    186                 logger.error(ex) 
     184            except: 
     185                logger.error(sys.exc_value) 
    187186 
    188187    return data_x, data_y, data_err 
Note: See TracChangeset for help on using the changeset viewer.