Ignore:
Timestamp:
Mar 26, 2017 11: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/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 
Note: See TracChangeset for help on using the changeset viewer.