Changeset 9dda8cc in sasview for src/sas/sascalc


Ignore:
Timestamp:
Apr 6, 2017 11:42:01 AM (8 years ago)
Author:
Ricardo Ferraz Leal <ricleal@…>
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:
ccc7192
Parents:
a470e88
Message:

New style exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/manipulations.py

    rfd5d6eac r9dda8cc  
    8383    """ 
    8484    if data2d.data is None or data2d.x_bins is None or data2d.y_bins is None: 
    85         raise ValueError, "Can't convert this data: data=None..." 
     85        raise ValueError("Can't convert this data: data=None...") 
    8686    new_x = np.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
    8787    new_y = np.tile(data2d.y_bins, (len(data2d.x_bins), 1)) 
     
    149149            msg = "_Slab._avg: invalid number of " 
    150150            msg += " detectors: %g" % len(data2D.detector) 
    151             raise RuntimeError, msg 
     151            raise RuntimeError(msg) 
    152152 
    153153        # Get data 
     
    171171            nbins = int(math.ceil((self.y_max - y_min) / self.bin_width)) 
    172172        else: 
    173             raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj) 
     173            raise RuntimeError("_Slab._avg: unrecognized axis %s" % str(maj)) 
    174174 
    175175        x = np.zeros(nbins) 
     
    232232        if not idx.any(): 
    233233            msg = "Average Error: No points inside ROI to average..." 
    234             raise ValueError, msg 
     234            raise ValueError(msg) 
    235235        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx]) 
    236236 
     
    308308            msg = "Circular averaging: invalid number " 
    309309            msg += "of detectors: %g" % len(data2D.detector) 
    310             raise RuntimeError, msg 
     310            raise RuntimeError(msg) 
    311311        # Get data 
    312312        data = data2D.data[np.isfinite(data2D.data)] 
     
    473473        if len(data2D.q_data) == None: 
    474474            msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 
    475             raise RuntimeError, msg 
     475            raise RuntimeError(msg) 
    476476 
    477477        # Build array of Q intervals 
     
    497497            # No need to calculate the frac when all data are within range 
    498498            if self.r_min >= self.r_max: 
    499                 raise ValueError, "Limit Error: min > max" 
     499                raise ValueError("Limit Error: min > max") 
    500500 
    501501            if self.r_min <= q_value and q_value <= self.r_max: 
     
    548548        if not idx.any(): 
    549549            msg = "Average Error: No points inside ROI to average..." 
    550             raise ValueError, msg 
     550            raise ValueError(msg) 
    551551 
    552552        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx], dx=d_x) 
     
    589589        """ 
    590590        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    591             raise RuntimeError, "Ring averaging only take plottable_2D objects" 
     591            raise RuntimeError("Ring averaging only take plottable_2D objects") 
    592592 
    593593        Pi = math.pi 
     
    649649        if not idx.any(): 
    650650            msg = "Average Error: No points inside ROI to average..." 
    651             raise ValueError, msg 
     651            raise ValueError(msg) 
    652652        # elif len(phi_bins[idx])!= self.nbins_phi: 
    653653        #    print "resulted",self.nbins_phi- len(phi_bins[idx]) 
     
    775775        """ 
    776776        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    777             raise RuntimeError, "Ring averaging only take plottable_2D objects" 
     777            raise RuntimeError("Ring averaging only take plottable_2D objects") 
    778778        Pi = math.pi 
    779779 
     
    942942        if not idx.any(): 
    943943            msg = "Average Error: No points inside sector of ROI to average..." 
    944             raise ValueError, msg 
     944            raise ValueError(msg) 
    945945        # elif len(y[idx])!= self.nbins: 
    946946        #    print "resulted",self.nbins- len(y[idx]), 
     
    10211021        """ 
    10221022        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1023             raise RuntimeError, "Ring cut only take plottable_2D objects" 
     1023            raise RuntimeError("Ring cut only take plottable_2D objects") 
    10241024 
    10251025        # Get data 
     
    10701070        """ 
    10711071        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1072             raise RuntimeError, "Boxcut take only plottable_2D objects" 
     1072            raise RuntimeError("Boxcut take only plottable_2D objects") 
    10731073        # Get qx_ and qy_data 
    10741074        qx_data = data2D.qx_data 
     
    11221122        """ 
    11231123        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1124             raise RuntimeError, "Sectorcut take only plottable_2D objects" 
     1124            raise RuntimeError("Sectorcut take only plottable_2D objects") 
    11251125        Pi = math.pi 
    11261126        # Get data 
Note: See TracChangeset for help on using the changeset viewer.