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


Ignore:
Timestamp:
Mar 26, 2017 9:33:16 PM (7 years ago)
Author:
andyfaff
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ed2276f
Parents:
9146ed9
Message:

MAINT: import numpy as np

File:
1 edited

Legend:

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

    r2c60f304 r9a5097c  
    77""" 
    88 
    9 import numpy 
     9import numpy as np 
    1010import sys 
    1111import math 
     
    189189        #import numpy 
    190190        if name == 'x': 
    191             out = numpy.ones(self.get_nx()) 
     191            out = np.ones(self.get_nx()) 
    192192            self.get_x(out) 
    193193            return out 
    194194        elif name == 'y': 
    195             out = numpy.ones(self.get_ny()) 
     195            out = np.ones(self.get_ny()) 
    196196            self.get_y(out) 
    197197            return out 
    198198        elif name == 'err': 
    199             out = numpy.ones(self.get_nerr()) 
     199            out = np.ones(self.get_nerr()) 
    200200            self.get_err(out) 
    201201            return out 
     
    325325            raise RuntimeError, msg 
    326326 
    327         p = numpy.ones(nfunc) 
     327        p = np.ones(nfunc) 
    328328        t_0 = time.time() 
    329329        out, cov_x, _, _, _ = optimize.leastsq(self.residuals, p, full_output=1) 
     
    341341 
    342342        if cov_x is None: 
    343             cov_x = numpy.ones([nfunc, nfunc]) 
     343            cov_x = np.ones([nfunc, nfunc]) 
    344344            cov_x *= math.fabs(chisqr) 
    345345        return out, cov_x 
     
    358358            raise RuntimeError, msg 
    359359 
    360         p = numpy.ones(nfunc) 
     360        p = np.ones(nfunc) 
    361361        t_0 = time.time() 
    362362        out, cov_x, _, _, _ = optimize.leastsq(self.pr_residuals, p, full_output=1) 
     
    435435        """ 
    436436        # Note: To make sure an array is contiguous: 
    437         # blah = numpy.ascontiguousarray(blah_original) 
     437        # blah = np.ascontiguousarray(blah_original) 
    438438        # ... before passing it to C 
    439439 
     
    456456            nfunc += 1 
    457457 
    458         a = numpy.zeros([npts + nq, nfunc]) 
    459         b = numpy.zeros(npts + nq) 
    460         err = numpy.zeros([nfunc, nfunc]) 
     458        a = np.zeros([npts + nq, nfunc]) 
     459        b = np.zeros(npts + nq) 
     460        err = np.zeros([nfunc, nfunc]) 
    461461 
    462462        # Construct the a matrix and b vector that represent the problem 
     
    476476        self.chi2 = chi2 
    477477 
    478         inv_cov = numpy.zeros([nfunc, nfunc]) 
     478        inv_cov = np.zeros([nfunc, nfunc]) 
    479479        # Get the covariance matrix, defined as inv_cov = a_transposed * a 
    480480        self._get_invcov_matrix(nfunc, nr, a, inv_cov) 
     
    490490 
    491491        try: 
    492             cov = numpy.linalg.pinv(inv_cov) 
     492            cov = np.linalg.pinv(inv_cov) 
    493493            err = math.fabs(chi2 / float(npts - nfunc)) * cov 
    494494        except: 
     
    505505            self.background = c[0] 
    506506 
    507             err_0 = numpy.zeros([nfunc, nfunc]) 
    508             c_0 = numpy.zeros(nfunc) 
     507            err_0 = np.zeros([nfunc, nfunc]) 
     508            c_0 = np.zeros(nfunc) 
    509509 
    510510            for i in range(nfunc_0): 
     
    662662                                                   str(self.cov[i][i]))) 
    663663        file.write("<r>  <Pr>  <dPr>\n") 
    664         r = numpy.arange(0.0, self.d_max, self.d_max / npts) 
     664        r = np.arange(0.0, self.d_max, self.d_max / npts) 
    665665 
    666666        for r_i in r: 
     
    694694                        toks = line.split('=') 
    695695                        self.nfunc = int(toks[1]) 
    696                         self.out = numpy.zeros(self.nfunc) 
    697                         self.cov = numpy.zeros([self.nfunc, self.nfunc]) 
     696                        self.out = np.zeros(self.nfunc) 
     697                        self.cov = np.zeros([self.nfunc, self.nfunc]) 
    698698                    elif line.startswith('#alpha='): 
    699699                        toks = line.split('=') 
Note: See TracChangeset for help on using the changeset viewer.