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


Ignore:
Timestamp:
Mar 5, 2019 4:26:14 PM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1249
Children:
1342f6a
Parents:
dbfd307 (diff), 8c9e65c (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.
git-author:
Paul Kienzle <pkienzle@…> (03/05/19 16:26:14)
git-committer:
GitHub <noreply@…> (03/05/19 16:26:14)
Message:

Merge branch 'master' into py37-sascalc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/pr/invertor.py

    rdbfd307 r7af652d  
    66FIXME: The way the Invertor interacts with its C component should be cleaned up 
    77""" 
     8from __future__ import division 
    89 
    910import numpy as np 
     
    1718from numpy.linalg import lstsq 
    1819from scipy import optimize 
    19 from sas.sascalc.pr.core.pr_inversion import Cinvertor 
     20from sas.sascalc.pr._pr_inversion import Cinvertor 
    2021 
    2122logger = logging.getLogger(__name__) 
     
    7172        A[j][i] = (Fourier transformed base function for point j) 
    7273 
    73     We them choose a number of r-points, n_r, to evaluate the second 
     74    We then choose a number of r-points, n_r, to evaluate the second 
    7475    derivative of P(r) at. This is used as our regularization term. 
    7576    For a vector r of length n_r, the following n_r rows are set to :: 
     
    144145        x, y, err, d_max, q_min, q_max and alpha 
    145146        """ 
    146         if   name == 'x': 
     147        if name == 'x': 
    147148            if 0.0 in value: 
    148149                msg = "Invertor: one of your q-values is zero. " 
     
    268269            A[i][j] = (Fourier transformed base function for point j) 
    269270 
    270         We them choose a number of r-points, n_r, to evaluate the second 
     271        We then choose a number of r-points, n_r, to evaluate the second 
    271272        derivative of P(r) at. This is used as our regularization term. 
    272273        For a vector r of length n_r, the following n_r rows are set to :: 
     
    416417            A[i][j] = (Fourier transformed base function for point j) 
    417418 
    418         We them choose a number of r-points, n_r, to evaluate the second 
     419        We then choose a number of r-points, n_r, to evaluate the second 
    419420        derivative of P(r) at. This is used as our regularization term. 
    420421        For a vector r of length n_r, the following n_r rows are set to :: 
     
    498499        try: 
    499500            cov = np.linalg.pinv(inv_cov) 
    500             err = math.fabs(chi2 / float(npts - nfunc)) * cov 
    501         except: 
     501            err = math.fabs(chi2 / (npts - nfunc)) * cov 
     502        except Exception as exc: 
    502503            # We were not able to estimate the errors 
    503504            # Return an empty error matrix 
    504             logger.error(sys.exc_value) 
     505            logger.error(exc) 
    505506 
    506507        # Keep a copy of the last output 
     
    539540 
    540541        """ 
    541         from num_term import NTermEstimator 
     542        from .num_term import NTermEstimator 
    542543        estimator = NTermEstimator(self.clone()) 
    543544        try: 
    544545            return estimator.num_terms(isquit_func) 
    545         except: 
     546        except Exception as exc: 
    546547            # If we fail, estimate alpha and return the default 
    547548            # number of terms 
    548549            best_alpha, _, _ = self.estimate_alpha(self.nfunc) 
    549             logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 
     550            logger.warning("Invertor.estimate_numterms: %s" % exc) 
    550551            return self.nfunc, best_alpha, "Could not estimate number of terms" 
    551552 
     
    633634                return best_alpha, message, elapsed 
    634635 
    635         except: 
    636             message = "Invertor.estimate_alpha: %s" % sys.exc_value 
     636        except Exception as exc: 
     637            message = "Invertor.estimate_alpha: %s" % exc 
    637638            return 0, message, elapsed 
    638639 
     
    750751                        self.cov[i][i] = float(toks2[1]) 
    751752 
    752             except: 
    753                 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 
     753            except Exception as exc: 
     754                msg = "Invertor.from_file: corrupted file\n%s" % exc 
    754755                raise RuntimeError(msg) 
    755756        else: 
Note: See TracChangeset for help on using the changeset viewer.