Changeset b8080e1 in sasview for src/sas/sascalc/pr/invertor.py


Ignore:
Timestamp:
Aug 29, 2018 10:01:23 AM (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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: 
Note: See TracChangeset for help on using the changeset viewer.