Changeset 9a5097c in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Mar 26, 2017 11:33:16 PM (8 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

Location:
src/sas/sasgui/perspectives/fitting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    rb301db9 r9a5097c  
    55import os 
    66import wx 
    7 import numpy 
     7import numpy as np 
    88import time 
    99import copy 
     
    100100        self.graph_id = None 
    101101        # Q range for data set 
    102         self.qmin_data_set = numpy.inf 
     102        self.qmin_data_set = np.inf 
    103103        self.qmax_data_set = None 
    104104        self.npts_data_set = 0 
     
    278278 
    279279        """ 
    280         x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
     280        x = np.linspace(start=self.qmin_x, stop=self.qmax_x, 
    281281                           num=self.npts_x, endpoint=True) 
    282282        self.data = Data1D(x=x) 
     
    295295        """ 
    296296        if self.qmin_x >= 1.e-10: 
    297             qmin = numpy.log10(self.qmin_x) 
     297            qmin = np.log10(self.qmin_x) 
    298298        else: 
    299299            qmin = -10. 
    300300 
    301301        if self.qmax_x <= 1.e10: 
    302             qmax = numpy.log10(self.qmax_x) 
     302            qmax = np.log10(self.qmax_x) 
    303303        else: 
    304304            qmax = 10. 
    305305 
    306         x = numpy.logspace(start=qmin, stop=qmax, 
     306        x = np.logspace(start=qmin, stop=qmax, 
    307307                           num=self.npts_x, endpoint=True, base=10.0) 
    308308        self.data = Data1D(x=x) 
     
    341341        qstep = self.npts_x 
    342342 
    343         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    344         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
     343        x = np.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
     344        y = np.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    345345        # use data info instead 
    346         new_x = numpy.tile(x, (len(y), 1)) 
    347         new_y = numpy.tile(y, (len(x), 1)) 
     346        new_x = np.tile(x, (len(y), 1)) 
     347        new_y = np.tile(y, (len(x), 1)) 
    348348        new_y = new_y.swapaxes(0, 1) 
    349349        # all data reuire now in 1d array 
    350350        qx_data = new_x.flatten() 
    351351        qy_data = new_y.flatten() 
    352         q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data) 
     352        q_data = np.sqrt(qx_data * qx_data + qy_data * qy_data) 
    353353        # set all True (standing for unmasked) as default 
    354         mask = numpy.ones(len(qx_data), dtype=bool) 
     354        mask = np.ones(len(qx_data), dtype=bool) 
    355355        # store x and y bin centers in q space 
    356356        x_bins = x 
     
    358358 
    359359        self.data.source = Source() 
    360         self.data.data = numpy.ones(len(mask)) 
    361         self.data.err_data = numpy.ones(len(mask)) 
     360        self.data.data = np.ones(len(mask)) 
     361        self.data.err_data = np.ones(len(mask)) 
    362362        self.data.qx_data = qx_data 
    363363        self.data.qy_data = qy_data 
     
    783783                    # Skip non-data lines 
    784784                    logging.error(traceback.format_exc()) 
    785             return numpy.array(angles), numpy.array(weights) 
     785            return np.array(angles), np.array(weights) 
    786786        except: 
    787787            raise 
     
    21202120        for data in self.data_list: 
    21212121            # q value from qx and qy 
    2122             radius = numpy.sqrt(data.qx_data * data.qx_data + 
     2122            radius = np.sqrt(data.qx_data * data.qx_data + 
    21232123                                data.qy_data * data.qy_data) 
    21242124            # get unmasked index 
     
    21262126                         (radius <= float(self.qmax.GetValue())) 
    21272127            index_data = (index_data) & (data.mask) 
    2128             index_data = (index_data) & (numpy.isfinite(data.data)) 
     2128            index_data = (index_data) & (np.isfinite(data.data)) 
    21292129 
    21302130            if len(index_data[index_data]) < 10: 
     
    21612161            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    21622162                         (radius <= float(self.qmax.GetValue())) 
    2163             index_data = (index_data) & (numpy.isfinite(data.y)) 
     2163            index_data = (index_data) & (np.isfinite(data.y)) 
    21642164 
    21652165            if len(index_data[index_data]) < 5: 
     
    22332233 
    22342234                # Check that min is less than max 
    2235                 low = -numpy.inf if min_str == "" else float(min_str) 
    2236                 high = numpy.inf if max_str == "" else float(max_str) 
     2235                low = -np.inf if min_str == "" else float(min_str) 
     2236                high = np.inf if max_str == "" else float(max_str) 
    22372237                if high < low: 
    22382238                    min_ctrl.SetBackgroundColour("pink") 
     
    26542654            self.qmin_x = data_min 
    26552655            self.qmax_x = math.sqrt(x * x + y * y) 
    2656             # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2656            # self.data.mask = np.ones(len(self.data.data),dtype=bool) 
    26572657            # check smearing 
    26582658            if not self.disable_smearer.GetValue(): 
     
    33663366 
    33673367            if value[1] == 'array': 
    3368                 pd_vals = numpy.array(value[2]) 
    3369                 pd_weights = numpy.array(value[3]) 
     3368                pd_vals = np.array(value[2]) 
     3369                pd_weights = np.array(value[3]) 
    33703370                if len(pd_vals) == 0 or len(pd_vals) != len(pd_weights): 
    33713371                    msg = ("bad array distribution parameters for %s" 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    rd85f1d8a r9a5097c  
    66import wx 
    77import wx.lib.newevent 
    8 import numpy 
     8import numpy as np 
    99import copy 
    1010import math 
     
    11151115            if item.GetValue(): 
    11161116                if button_list.index(item) == 0: 
    1117                     flag = 0  # dy = numpy.ones_like(dy_data) 
     1117                    flag = 0  # dy = np.ones_like(dy_data) 
    11181118                elif button_list.index(item) == 1: 
    11191119                    flag = 1  # dy = dy_data 
    11201120                elif button_list.index(item) == 2: 
    1121                     flag = 2  # dy = numpy.sqrt(numpy.abs(data)) 
     1121                    flag = 2  # dy = np.sqrt(np.abs(data)) 
    11221122                elif button_list.index(item) == 3: 
    1123                     flag = 3  # dy = numpy.abs(data) 
     1123                    flag = 3  # dy = np.abs(data) 
    11241124                break 
    11251125        return flag 
     
    14221422        key = event.GetKeyCode() 
    14231423        length = len(self.data.x) 
    1424         indx = (numpy.abs(self.data.x - x_data)).argmin() 
     1424        indx = (np.abs(self.data.x - x_data)).argmin() 
    14251425        # return array.flat[idx] 
    14261426        if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: 
     
    14771477                    self.enable2D: 
    14781478                # set mask 
    1479                 radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     1479                radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    14801480                                    self.data.qy_data * self.data.qy_data) 
    14811481                index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x)) 
    14821482                index_data = (index_data) & (self.data.mask) 
    1483                 index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     1483                index_data = (index_data) & (np.isfinite(self.data.data)) 
    14841484                if len(index_data[index_data]) < 10: 
    14851485                    msg = "Cannot Plot :No or too little npts in" 
     
    15981598                and data.dqx_data.any() != 0: 
    15991599                self.smear_type = "Pinhole2d" 
    1600                 self.dq_l = format_number(numpy.average(data.dqx_data)) 
    1601                 self.dq_r = format_number(numpy.average(data.dqy_data)) 
     1600                self.dq_l = format_number(np.average(data.dqx_data)) 
     1601                self.dq_r = format_number(np.average(data.dqy_data)) 
    16021602                return 
    16031603            else: 
    16041604                return 
    16051605        # check if it is pinhole smear and get min max if it is. 
    1606         if data.dx is not None and numpy.any(data.dx): 
     1606        if data.dx is not None and np.any(data.dx): 
    16071607            self.smear_type = "Pinhole" 
    16081608            self.dq_l = data.dx[0] 
     
    16121612        elif data.dxl is not None or data.dxw is not None: 
    16131613            self.smear_type = "Slit" 
    1614             if data.dxl is not None and numpy.all(data.dxl, 0): 
     1614            if data.dxl is not None and np.all(data.dxl, 0): 
    16151615                self.dq_l = data.dxl[0] 
    1616             if data.dxw is not None and numpy.all(data.dxw, 0): 
     1616            if data.dxw is not None and np.all(data.dxw, 0): 
    16171617                self.dq_r = data.dxw[0] 
    16181618        # return self.smear_type,self.dq_l,self.dq_r 
     
    19211921                self.default_mask = copy.deepcopy(self.data.mask) 
    19221922                if self.data.err_data is not None \ 
    1923                         and numpy.any(self.data.err_data): 
     1923                        and np.any(self.data.err_data): 
    19241924                    di_flag = True 
    19251925                if self.data.dqx_data is not None \ 
    1926                         and numpy.any(self.data.dqx_data): 
     1926                        and np.any(self.data.dqx_data): 
    19271927                    dq_flag = True 
    19281928            else: 
    19291929                self.slit_smearer.Enable(True) 
    19301930                self.pinhole_smearer.Enable(True) 
    1931                 if self.data.dy is not None and numpy.any(self.data.dy): 
     1931                if self.data.dy is not None and np.any(self.data.dy): 
    19321932                    di_flag = True 
    1933                 if self.data.dx is not None and numpy.any(self.data.dx): 
     1933                if self.data.dx is not None and np.any(self.data.dx): 
    19341934                    dq_flag = True 
    1935                 elif self.data.dxl is not None and numpy.any(self.data.dxl): 
     1935                elif self.data.dxl is not None and np.any(self.data.dxl): 
    19361936                    dq_flag = True 
    19371937 
     
    20672067        if self.data.__class__.__name__ == "Data2D" or \ 
    20682068                        self.enable2D: 
    2069             radius = numpy.sqrt(self.data.qx_data * self.data.qx_data + 
     2069            radius = np.sqrt(self.data.qx_data * self.data.qx_data + 
    20702070                                self.data.qy_data * self.data.qy_data) 
    20712071            index_data = (self.qmin_x <= radius) & (radius <= self.qmax_x) 
    20722072            index_data = (index_data) & (self.data.mask) 
    2073             index_data = (index_data) & (numpy.isfinite(self.data.data)) 
     2073            index_data = (index_data) & (np.isfinite(self.data.data)) 
    20742074            npts2fit = len(self.data.data[index_data]) 
    20752075        else: 
     
    21042104        # make sure stop button to fit button all the time 
    21052105        self._on_fit_complete() 
    2106         if out is None or not numpy.isfinite(chisqr): 
     2106        if out is None or not np.isfinite(chisqr): 
    21072107            raise ValueError, "Fit error occured..." 
    21082108 
     
    21152115 
    21162116        # Check if chi2 is finite 
    2117         if chisqr is not None and numpy.isfinite(chisqr): 
     2117        if chisqr is not None and np.isfinite(chisqr): 
    21182118            # format chi2 
    21192119            chi2 = format_number(chisqr, True) 
     
    21672167 
    21682168                        if cov[ind] is not None: 
    2169                             if numpy.isfinite(float(cov[ind])): 
     2169                            if np.isfinite(float(cov[ind])): 
    21702170                                val_err = format_number(cov[ind], True) 
    21712171                                item[4].SetForegroundColour(wx.BLACK) 
     
    22912291            self.smear_type = 'Pinhole2d' 
    22922292            len_data = len(data.data) 
    2293             data.dqx_data = numpy.zeros(len_data) 
    2294             data.dqy_data = numpy.zeros(len_data) 
     2293            data.dqx_data = np.zeros(len_data) 
     2294            data.dqy_data = np.zeros(len_data) 
    22952295        else: 
    22962296            self.smear_type = 'Pinhole' 
    22972297            len_data = len(data.x) 
    2298             data.dx = numpy.zeros(len_data) 
     2298            data.dx = np.zeros(len_data) 
    22992299            data.dxl = None 
    23002300            data.dxw = None 
     
    24692469        try: 
    24702470            self.dxl = float(self.smear_slit_height.GetValue()) 
    2471             data.dxl = self.dxl * numpy.ones(data_len) 
     2471            data.dxl = self.dxl * np.ones(data_len) 
    24722472            self.smear_slit_height.SetBackgroundColour(wx.WHITE) 
    24732473        except: 
    24742474            self.dxl = None 
    2475             data.dxl = numpy.zeros(data_len) 
     2475            data.dxl = np.zeros(data_len) 
    24762476            if self.smear_slit_height.GetValue().lstrip().rstrip() != "": 
    24772477                self.smear_slit_height.SetBackgroundColour("pink") 
     
    24822482            self.dxw = float(self.smear_slit_width.GetValue()) 
    24832483            self.smear_slit_width.SetBackgroundColour(wx.WHITE) 
    2484             data.dxw = self.dxw * numpy.ones(data_len) 
     2484            data.dxw = self.dxw * np.ones(data_len) 
    24852485        except: 
    24862486            self.dxw = None 
    2487             data.dxw = numpy.zeros(data_len) 
     2487            data.dxw = np.zeros(data_len) 
    24882488            if self.smear_slit_width.GetValue().lstrip().rstrip() != "": 
    24892489                self.smear_slit_width.SetBackgroundColour("pink") 
     
    26122612            if event is None: 
    26132613                output = "-" 
    2614             elif not numpy.isfinite(event.output): 
     2614            elif not np.isfinite(event.output): 
    26152615                output = "-" 
    26162616            else: 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    rddbac66 r9a5097c  
    1616import wx 
    1717import logging 
    18 import numpy 
     18import numpy as np 
    1919import time 
    2020from copy import deepcopy 
     
    13321332                    new_theory = copy_data.data 
    13331333                    new_theory[res.index] = res.theory 
    1334                     new_theory[res.index == False] = numpy.nan 
     1334                    new_theory[res.index == False] = np.nan 
    13351335                    correct_result = True 
    13361336                #get all fittable parameters of the current model 
     
    13411341                        param_list.remove(param) 
    13421342                if not correct_result or res.fitness is None or \ 
    1343                     not numpy.isfinite(res.fitness) or \ 
    1344                     numpy.any(res.pvec == None) or not \ 
    1345                     numpy.all(numpy.isfinite(res.pvec)): 
     1343                    not np.isfinite(res.fitness) or \ 
     1344                        np.any(res.pvec == None) or not \ 
     1345                        np.all(np.isfinite(res.pvec)): 
    13461346                    data_name = str(None) 
    13471347                    if data is not None: 
     
    13521352                    msg += "Data %s and Model %s did not fit.\n" % (data_name, 
    13531353                                                                    model_name) 
    1354                     ERROR = numpy.NAN 
     1354                    ERROR = np.NAN 
    13551355                    cell = BatchCell() 
    13561356                    cell.label = res.fitness 
     
    13661366                            batch_inputs["error on %s" % str(param)].append(ERROR) 
    13671367                else: 
    1368                     # TODO: Why sometimes res.pvec comes with numpy.float64? 
     1368                    # TODO: Why sometimes res.pvec comes with np.float64? 
    13691369                    # probably from scipy lmfit 
    1370                     if res.pvec.__class__ == numpy.float64: 
     1370                    if res.pvec.__class__ == np.float64: 
    13711371                        res.pvec = [res.pvec] 
    13721372 
     
    15331533                fit_msg = res.mesg 
    15341534                if res.fitness is None or \ 
    1535                     not numpy.isfinite(res.fitness) or \ 
    1536                     numpy.any(res.pvec == None) or \ 
    1537                     not numpy.all(numpy.isfinite(res.pvec)): 
     1535                    not np.isfinite(res.fitness) or \ 
     1536                        np.any(res.pvec == None) or \ 
     1537                    not np.all(np.isfinite(res.pvec)): 
    15381538                    fit_msg += "\nFitting did not converge!!!" 
    15391539                    wx.CallAfter(self._update_fit_button, page_id) 
    15401540                else: 
    15411541                    #set the panel when fit result are float not list 
    1542                     if res.pvec.__class__ == numpy.float64: 
     1542                    if res.pvec.__class__ == np.float64: 
    15431543                        pvec = [res.pvec] 
    15441544                    else: 
    15451545                        pvec = res.pvec 
    1546                     if res.stderr.__class__ == numpy.float64: 
     1546                    if res.stderr.__class__ == np.float64: 
    15471547                        stderr = [res.stderr] 
    15481548                    else: 
     
    16921692        if dy is None: 
    16931693            new_plot.is_data = False 
    1694             new_plot.dy = numpy.zeros(len(y)) 
     1694            new_plot.dy = np.zeros(len(y)) 
    16951695            # If this is a theory curve, pick the proper symbol to make it a curve 
    16961696            new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
     
    17411741        """ 
    17421742        try: 
    1743             numpy.nan_to_num(y) 
     1743            np.nan_to_num(y) 
    17441744            new_plot = self.create_theory_1D(x, y, page_id, model, data, state, 
    17451745                                             data_description=model.name, 
     
    18261826        that can be plot. 
    18271827        """ 
    1828         numpy.nan_to_num(image) 
     1828        np.nan_to_num(image) 
    18291829        new_plot = Data2D(image=image, err_image=data.err_data) 
    18301830        new_plot.name = model.name + '2d' 
     
    20182018        if data_copy.__class__.__name__ == "Data2D": 
    20192019            if index == None: 
    2020                 index = numpy.ones(len(data_copy.data), dtype=bool) 
     2020                index = np.ones(len(data_copy.data), dtype=bool) 
    20212021            if weight != None: 
    20222022                data_copy.err_data = weight 
    20232023            # get rid of zero error points 
    20242024            index = index & (data_copy.err_data != 0) 
    2025             index = index & (numpy.isfinite(data_copy.data)) 
     2025            index = index & (np.isfinite(data_copy.data)) 
    20262026            fn = data_copy.data[index] 
    20272027            theory_data = self.page_finder[page_id].get_theory_data(fid=data_copy.id) 
     
    20332033            # 1 d theory from model_thread is only in the range of index 
    20342034            if index == None: 
    2035                 index = numpy.ones(len(data_copy.y), dtype=bool) 
     2035                index = np.ones(len(data_copy.y), dtype=bool) 
    20362036            if weight != None: 
    20372037                data_copy.dy = weight 
    20382038            if data_copy.dy == None or data_copy.dy == []: 
    2039                 dy = numpy.ones(len(data_copy.y)) 
     2039                dy = np.ones(len(data_copy.y)) 
    20402040            else: 
    20412041                ## Set consistently w/AbstractFitengine: 
     
    20582058            return 
    20592059 
    2060         residuals = res[numpy.isfinite(res)] 
     2060        residuals = res[np.isfinite(res)] 
    20612061        # get chisqr only w/finite 
    2062         chisqr = numpy.average(residuals * residuals) 
     2062        chisqr = np.average(residuals * residuals) 
    20632063 
    20642064        self._plot_residuals(page_id=page_id, data=data_copy, 
     
    20972097            residuals.qy_data = data_copy.qy_data 
    20982098            residuals.q_data = data_copy.q_data 
    2099             residuals.err_data = numpy.ones(len(residuals.data)) 
     2099            residuals.err_data = np.ones(len(residuals.data)) 
    21002100            residuals.xmin = min(residuals.qx_data) 
    21012101            residuals.xmax = max(residuals.qx_data) 
     
    21112111            # 1 d theory from model_thread is only in the range of index 
    21122112            if data_copy.dy == None or data_copy.dy == []: 
    2113                 dy = numpy.ones(len(data_copy.y)) 
     2113                dy = np.ones(len(data_copy.y)) 
    21142114            else: 
    21152115                if weight == None: 
    2116                     dy = numpy.ones(len(data_copy.y)) 
     2116                    dy = np.ones(len(data_copy.y)) 
    21172117                ## Set consitently w/AbstractFitengine: 
    21182118                ## But this should be corrected later. 
     
    21332133                residuals.y = (fn - gn[index]) / en 
    21342134            residuals.x = data_copy.x[index] 
    2135             residuals.dy = numpy.ones(len(residuals.y)) 
     2135            residuals.dy = np.ones(len(residuals.y)) 
    21362136            residuals.dx = None 
    21372137            residuals.dxl = None 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rc1c9929 r9a5097c  
    44 
    55import time 
    6 import numpy 
     6import numpy as np 
    77import math 
    88from sas.sascalc.data_util.calcthread import CalcThread 
     
    6868 
    6969        # Define matrix where data will be plotted 
    70         radius = numpy.sqrt((self.data.qx_data * self.data.qx_data) + \ 
     70        radius = np.sqrt((self.data.qx_data * self.data.qx_data) + \ 
    7171                    (self.data.qy_data * self.data.qy_data)) 
    7272 
     
    7575        index_model = (self.qmin <= radius) & (radius <= self.qmax) 
    7676        index_model = index_model & self.data.mask 
    77         index_model = index_model & numpy.isfinite(self.data.data) 
     77        index_model = index_model & np.isfinite(self.data.data) 
    7878 
    7979        if self.smearer is not None: 
     
    9191                self.data.qy_data[index_model] 
    9292            ]) 
    93         output = numpy.zeros(len(self.data.qx_data)) 
     93        output = np.zeros(len(self.data.qx_data)) 
    9494        # output default is None 
    9595        # This method is to distinguish between masked 
     
    163163        """ 
    164164        self.starttime = time.time() 
    165         output = numpy.zeros((len(self.data.x))) 
     165        output = np.zeros((len(self.data.x))) 
    166166        index = (self.qmin <= self.data.x) & (self.data.x <= self.qmax) 
    167167 
     
    175175                                                             self.qmax) 
    176176            mask = self.data.x[first_bin:last_bin+1] 
    177             unsmeared_output = numpy.zeros((len(self.data.x))) 
     177            unsmeared_output = np.zeros((len(self.data.x))) 
    178178            unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 
    179179            self.smearer.model = self.model 
     
    183183            # Check that the arrays are compatible. If we only have a model but no data, 
    184184            # the length of data.y will be zero. 
    185             if isinstance(self.data.y, numpy.ndarray) and output.shape == self.data.y.shape: 
    186                 unsmeared_data = numpy.zeros((len(self.data.x))) 
    187                 unsmeared_error = numpy.zeros((len(self.data.x))) 
     185            if isinstance(self.data.y, np.ndarray) and output.shape == self.data.y.shape: 
     186                unsmeared_data = np.zeros((len(self.data.x))) 
     187                unsmeared_error = np.zeros((len(self.data.x))) 
    188188                unsmeared_data[first_bin:last_bin+1] = self.data.y[first_bin:last_bin+1]\ 
    189189                                                        * unsmeared_output[first_bin:last_bin+1]\ 
     
    209209 
    210210        if p_model is not None and s_model is not None: 
    211             sq_values = numpy.zeros((len(self.data.x))) 
    212             pq_values = numpy.zeros((len(self.data.x))) 
     211            sq_values = np.zeros((len(self.data.x))) 
     212            pq_values = np.zeros((len(self.data.x))) 
    213213            sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
    214214            pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    rd5aff7f r9a5097c  
    1818import copy 
    1919import logging 
    20 import numpy 
     20import numpy as np 
    2121import traceback 
    2222 
     
    410410        for fittable, name, value, _, uncert, lower, upper, units in params: 
    411411            if not value: 
    412                 value = numpy.nan 
     412                value = np.nan 
    413413            if not uncert or uncert[1] == '' or uncert[1] == 'None': 
    414414                uncert[0] = False 
    415                 uncert[1] = numpy.nan 
     415                uncert[1] = np.nan 
    416416            if not upper or upper[1] == '' or upper[1] == 'None': 
    417417                upper[0] = False 
    418                 upper[1] = numpy.nan 
     418                upper[1] = np.nan 
    419419            if not lower or lower[1] == '' or lower[1] == 'None': 
    420420                lower[0] = False 
    421                 lower[1] = numpy.nan 
     421                lower[1] = np.nan 
    422422            if is_string: 
    423423                p[name] = str(value) 
     
    449449                lower = params.get(name + ".lower", '-inf') 
    450450                units = params.get(name + ".units") 
    451                 if std is not None and std is not numpy.nan: 
     451                if std is not None and std is not np.nan: 
    452452                    std = [True, str(std)] 
    453453                else: 
    454454                    std = [False, ''] 
    455                 if lower is not None and lower is not numpy.nan: 
     455                if lower is not None and lower is not np.nan: 
    456456                    lower = [True, str(lower)] 
    457457                else: 
    458458                    lower = [True, '-inf'] 
    459                 if upper is not None and upper is not numpy.nan: 
     459                if upper is not None and upper is not np.nan: 
    460460                    upper = [True, str(upper)] 
    461461                else: 
     
    11001100                                       % (line, tagname, name)) 
    11011101                                logging.error(msg + traceback.format_exc()) 
    1102                         dic[name] = numpy.array(value_list) 
     1102                        dic[name] = np.array(value_list) 
    11031103                    setattr(self, varname, dic) 
    11041104 
  • src/sas/sasgui/perspectives/fitting/utils.py

    rd85c194 r9a5097c  
    22Module contains functions frequently used in this package 
    33""" 
    4 import numpy 
     4import numpy as np 
    55 
    66 
     
    1919        data = data.y 
    2020    if flag == 0: 
    21         weight = numpy.ones_like(data) 
     21        weight = np.ones_like(data) 
    2222    elif flag == 1: 
    2323        weight = dy_data 
    2424    elif flag == 2: 
    25         weight = numpy.sqrt(numpy.abs(data)) 
     25        weight = np.sqrt(np.abs(data)) 
    2626    elif flag == 3: 
    27         weight = numpy.abs(data) 
     27        weight = np.abs(data) 
    2828    return weight 
Note: See TracChangeset for help on using the changeset viewer.