Changeset 952ea1f in sasview for src/sas/sascalc/pr


Ignore:
Timestamp:
Oct 11, 2018 1:33:22 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
Children:
7ba6470
Parents:
67ed543
git-author:
Paul Kienzle <pkienzle@…> (10/11/18 13:22:07)
git-committer:
Paul Kienzle <pkienzle@…> (10/11/18 13:33:22)
Message:

move c extensions from core/module.so to _module.so

Location:
src/sas/sascalc/pr
Files:
1 deleted
2 edited

Legend:

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

    ra52f32f r952ea1f  
    55 * 
    66 */ 
    7 #include <Python.h> 
    8 #include "structmember.h" 
    97#include <stdio.h> 
    108#include <stdlib.h> 
     
    1210#include <time.h> 
    1311 
     12//#define Py_LIMITED_API 0x03050000 
     13#include <Python.h> 
     14#include <structmember.h> 
     15 
    1416#include "invertor.h" 
    15  
    1617 
    1718/// Error object for raised exceptions 
     
    11211122 
    11221123#define MODULE_DOC "C extension module for inversion to P(r)." 
    1123 #define MODULE_NAME "pr_inversion" 
    1124 #define MODULE_INIT2 initpr_inversion 
    1125 #define MODULE_INIT3 PyInit_pr_inversion 
     1124#define MODULE_NAME "_pr_inversion" 
     1125#define MODULE_INIT2 init_pr_inversion 
     1126#define MODULE_INIT3 PyInit__pr_inversion 
    11261127#define MODULE_METHODS module_methods 
    11271128 
  • src/sas/sascalc/pr/invertor.py

    r2469df7 r952ea1f  
    1717from numpy.linalg import lstsq 
    1818from scipy import optimize 
    19 from sas.sascalc.pr.core.pr_inversion import Cinvertor 
     19from sas.sascalc.pr._pr_inversion import Cinvertor 
    2020 
    2121logger = logging.getLogger(__name__) 
     
    7171        A[j][i] = (Fourier transformed base function for point j) 
    7272 
    73     We them choose a number of r-points, n_r, to evaluate the second 
     73    We then choose a number of r-points, n_r, to evaluate the second 
    7474    derivative of P(r) at. This is used as our regularization term. 
    7575    For a vector r of length n_r, the following n_r rows are set to :: 
     
    144144        x, y, err, d_max, q_min, q_max and alpha 
    145145        """ 
    146         if   name == 'x': 
     146        if name == 'x': 
    147147            if 0.0 in value: 
    148148                msg = "Invertor: one of your q-values is zero. " 
     
    268268            A[i][j] = (Fourier transformed base function for point j) 
    269269 
    270         We them choose a number of r-points, n_r, to evaluate the second 
     270        We then choose a number of r-points, n_r, to evaluate the second 
    271271        derivative of P(r) at. This is used as our regularization term. 
    272272        For a vector r of length n_r, the following n_r rows are set to :: 
     
    416416            A[i][j] = (Fourier transformed base function for point j) 
    417417 
    418         We them choose a number of r-points, n_r, to evaluate the second 
     418        We then choose a number of r-points, n_r, to evaluate the second 
    419419        derivative of P(r) at. This is used as our regularization term. 
    420420        For a vector r of length n_r, the following n_r rows are set to :: 
     
    473473 
    474474        # Perform the inversion (least square fit) 
    475         c, chi2, _, _ = lstsq(a, b) 
     475        c, chi2, _, _ = lstsq(a, b, rcond=None) 
    476476        # Sanity check 
    477477        try: 
     
    497497            cov = np.linalg.pinv(inv_cov) 
    498498            err = math.fabs(chi2 / float(npts - nfunc)) * cov 
    499         except: 
     499        except Exception as exc: 
    500500            # We were not able to estimate the errors 
    501501            # Return an empty error matrix 
    502             logger.error(sys.exc_value) 
     502            logger.error(exc) 
    503503 
    504504        # Keep a copy of the last output 
     
    537537 
    538538        """ 
    539         from num_term import NTermEstimator 
     539        from .num_term import NTermEstimator 
    540540        estimator = NTermEstimator(self.clone()) 
    541541        try: 
    542542            return estimator.num_terms(isquit_func) 
    543         except: 
     543        except Exception as exc: 
    544544            # If we fail, estimate alpha and return the default 
    545545            # number of terms 
    546546            best_alpha, _, _ = self.estimate_alpha(self.nfunc) 
    547             logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 
     547            logger.warning("Invertor.estimate_numterms: %s" % exc) 
    548548            return self.nfunc, best_alpha, "Could not estimate number of terms" 
    549549 
     
    631631                return best_alpha, message, elapsed 
    632632 
    633         except: 
    634             message = "Invertor.estimate_alpha: %s" % sys.exc_value 
     633        except Exception as exc: 
     634            message = "Invertor.estimate_alpha: %s" % exc 
    635635            return 0, message, elapsed 
    636636 
     
    748748                        self.cov[i][i] = float(toks2[1]) 
    749749 
    750             except: 
    751                 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 
     750            except Exception as exc: 
     751                msg = "Invertor.from_file: corrupted file\n%s" % exc 
    752752                raise RuntimeError(msg) 
    753753        else: 
Note: See TracChangeset for help on using the changeset viewer.