Changes in / [c00a797a:0cc77d8] in sasview


Ignore:
Files:
66 edited

Legend:

Unmodified
Added
Removed
  • sasview/setup_mac.py

    ra1b8fee ra1b8fee  
    6363        libxml_path = libxml_path_test 
    6464if libxml_path is None: 
    65     raise RuntimeError, "Could not find libxml2 on the system" 
     65    raise RuntimeError("Could not find libxml2 on the system") 
    6666 
    6767APP = ['sasview.py'] 
  • src/sas/sascalc/calculator/BaseComponent.py

    r9a5097c rb9d74f3  
    143143                qdist[1].__class__.__name__ != 'ndarray': 
    144144                msg = "evalDistribution expects a list of 2 ndarrays" 
    145                 raise RuntimeError, msg 
     145                raise RuntimeError(msg) 
    146146 
    147147            # Extract qx and qy for code clarity 
     
    167167            mesg = "evalDistribution is expecting an ndarray of scalar q-values" 
    168168            mesg += " or a list [qx,qy] where qx,qy are 2D ndarrays." 
    169             raise RuntimeError, mesg 
     169            raise RuntimeError(mesg) 
    170170 
    171171 
     
    228228                    return 
    229229 
    230         raise ValueError, "Model does not contain parameter %s" % name 
     230        raise ValueError("Model does not contain parameter %s" % name) 
    231231 
    232232    def getParam(self, name): 
     
    250250                    return self.params[item] 
    251251 
    252         raise ValueError, "Model does not contain parameter %s" % name 
     252        raise ValueError("Model does not contain parameter %s" % name) 
    253253 
    254254    def getParamList(self): 
     
    294294        add 
    295295        """ 
    296         raise ValueError, "Model operation are no longer supported" 
     296        raise ValueError("Model operation are no longer supported") 
    297297    def __sub__(self, other): 
    298298        """ 
    299299        sub 
    300300        """ 
    301         raise ValueError, "Model operation are no longer supported" 
     301        raise ValueError("Model operation are no longer supported") 
    302302    def __mul__(self, other): 
    303303        """ 
    304304        mul 
    305305        """ 
    306         raise ValueError, "Model operation are no longer supported" 
     306        raise ValueError("Model operation are no longer supported") 
    307307    def __div__(self, other): 
    308308        """ 
    309309        div 
    310310        """ 
    311         raise ValueError, "Model operation are no longer supported" 
     311        raise ValueError("Model operation are no longer supported") 
    312312 
    313313 
  • src/sas/sascalc/calculator/instrument.py

    r9a5097c rb9d74f3  
    324324            plt.show() 
    325325        except: 
    326             raise RuntimeError, "Can't import matplotlib required to plot..." 
     326            raise RuntimeError("Can't import matplotlib required to plot...") 
    327327 
    328328 
  • src/sas/sascalc/calculator/resolution_calculator.py

    r7432acb rb9d74f3  
    208208        if wavelength == 0: 
    209209            msg = "Can't compute the resolution: the wavelength is zero..." 
    210             raise RuntimeError, msg 
     210            raise RuntimeError(msg) 
    211211        return self.intensity 
    212212 
     
    503503        # otherwise 
    504504        else: 
    505             raise ValueError, " Improper input..." 
     505            raise ValueError(" Improper input...") 
    506506        # get them squared 
    507507        sigma = x_comp * x_comp 
     
    766766        """ 
    767767        if len(size) < 1 or len(size) > 2: 
    768             raise RuntimeError, "The length of the size must be one or two." 
     768            raise RuntimeError("The length of the size must be one or two.") 
    769769        self.aperture.set_source_size(size) 
    770770 
     
    783783        """ 
    784784        if len(size) < 1 or len(size) > 2: 
    785             raise RuntimeError, "The length of the size must be one or two." 
     785            raise RuntimeError("The length of the size must be one or two.") 
    786786        self.aperture.set_sample_size(size) 
    787787 
     
    806806        """ 
    807807        if len(distance) < 1 or len(distance) > 2: 
    808             raise RuntimeError, "The length of the size must be one or two." 
     808            raise RuntimeError("The length of the size must be one or two.") 
    809809        self.aperture.set_sample_distance(distance) 
    810810 
     
    816816        """ 
    817817        if len(distance) < 1 or len(distance) > 2: 
    818             raise RuntimeError, "The length of the size must be one or two." 
     818            raise RuntimeError("The length of the size must be one or two.") 
    819819        self.sample.set_distance(distance) 
    820820 
     
    826826        """ 
    827827        if len(distance) < 1 or len(distance) > 2: 
    828             raise RuntimeError, "The length of the size must be one or two." 
     828            raise RuntimeError("The length of the size must be one or two.") 
    829829        self.detector.set_distance(distance) 
    830830 
     
    998998            pix_y_size = detector_pix_size[1] 
    999999        else: 
    1000             raise ValueError, " Input value format error..." 
     1000            raise ValueError(" Input value format error...") 
    10011001        # Sample to detector distance = sample slit to detector 
    10021002        # minus sample offset 
  • src/sas/sascalc/calculator/sas_gen.py

    ra1b8fee ra1b8fee  
    3434        factor = MFACTOR_MT 
    3535    else: 
    36         raise ValueError, "Invalid valueunit" 
     36        raise ValueError("Invalid valueunit") 
    3737    sld_m = factor * mag 
    3838    return sld_m 
     
    174174            if len(x[1]) > 0: 
    175175                msg = "Not a 1D." 
    176                 raise ValueError, msg 
     176                raise ValueError(msg) 
    177177            i_out = np.zeros_like(x[0]) 
    178178            # 1D I is found at y =0 in the 2D pattern 
     
    181181        else: 
    182182            msg = "Q must be given as list of qx's and qy's" 
    183             raise ValueError, msg 
     183            raise ValueError(msg) 
    184184 
    185185    def runXY(self, x=0.0): 
     
    196196        else: 
    197197            msg = "Q must be given as list of qx's and qy's" 
    198             raise ValueError, msg 
     198            raise ValueError(msg) 
    199199 
    200200    def evalDistribution(self, qdist): 
     
    214214            mesg = "evalDistribution is expecting an ndarray of " 
    215215            mesg += "a list [qx,qy] where qx,qy are arrays." 
    216             raise RuntimeError, mesg 
     216            raise RuntimeError(mesg) 
    217217 
    218218class OMF2SLD(object): 
     
    315315        msg = "Error: Inconsistent data length." 
    316316        if len(self.pos_x) != length: 
    317             raise ValueError, msg 
     317            raise ValueError(msg) 
    318318        if len(self.pos_y) != length: 
    319             raise ValueError, msg 
     319            raise ValueError(msg) 
    320320        if len(self.pos_z) != length: 
    321             raise ValueError, msg 
     321            raise ValueError(msg) 
    322322        if len(self.mx) != length: 
    323             raise ValueError, msg 
     323            raise ValueError(msg) 
    324324        if len(self.my) != length: 
    325             raise ValueError, msg 
     325            raise ValueError(msg) 
    326326        if len(self.mz) != length: 
    327             raise ValueError, msg 
     327            raise ValueError(msg) 
    328328 
    329329    def remove_null_points(self, remove=False, recenter=False): 
     
    415415                        msg = "Error: \n" 
    416416                        msg += "We accept only m as meshunit" 
    417                         raise ValueError, msg 
     417                        raise ValueError(msg) 
    418418                if s_line[0].lower().count("xbase") > 0: 
    419419                    xbase = s_line[1].lstrip() 
     
    485485            msg = "%s is not supported: \n" % path 
    486486            msg += "We accept only Text format OMF file." 
    487             raise RuntimeError, msg 
     487            raise RuntimeError(msg) 
    488488 
    489489class PDBReader(object): 
     
    605605            return output 
    606606        except: 
    607             raise RuntimeError, "%s is not a sld file" % path 
     607            raise RuntimeError("%s is not a sld file" % path) 
    608608 
    609609    def write(self, path, data): 
     
    697697            return output 
    698698        except: 
    699             raise RuntimeError, "%s is not a sld file" % path 
     699            raise RuntimeError("%s is not a sld file" % path) 
    700700 
    701701    def write(self, path, data): 
     
    706706        """ 
    707707        if path is None: 
    708             raise ValueError, "Missing the file path." 
     708            raise ValueError("Missing the file path.") 
    709709        if data is None: 
    710             raise ValueError, "Missing the data to save." 
     710            raise ValueError("Missing the data to save.") 
    711711        x_val = data.pos_x 
    712712        y_val = data.pos_y 
  • src/sas/sascalc/corfunc/corfunc_calculator.py

    rff11b21 rb9d74f3  
    8080        # Only process data of the class Data1D 
    8181        if not issubclass(data.__class__, Data1D): 
    82             raise ValueError, "Data must be of the type DataLoader.Data1D" 
     82            raise ValueError("Data must be of the type DataLoader.Data1D") 
    8383 
    8484        # Prepare the data 
     
    151151            err = ("Incorrect transform type supplied, must be 'fourier'", 
    152152                " or 'hilbert'") 
    153             raise ValueError, err 
     153            raise ValueError(err) 
    154154 
    155155        self._transform_thread.queue() 
  • src/sas/sascalc/data_util/nxsunit.py

    rb699768 rb9d74f3  
    189189 
    190190def _check(expect,get): 
    191     if expect != get: raise ValueError, "Expected %s but got %s"%(expect,get) 
     191    if expect != get: raise ValueError("Expected %s but got %s"%(expect,get)) 
    192192     #print expect,"==",get 
    193193 
  • src/sas/sascalc/data_util/odict.py

    rb699768 rb9d74f3  
    612612        """ 
    613613        if len(args) > 1: 
    614             raise TypeError, ('pop expected at most 2 arguments, got %s' % 
     614            raise TypeError('pop expected at most 2 arguments, got %s' % 
    615615                (len(args) + 1)) 
    616616        if key in self: 
  • src/sas/sascalc/data_util/registry.py

    ra1b8fee ra1b8fee  
    106106        # Raise an error if there are no matching extensions 
    107107        if len(loaders) == 0: 
    108             raise ValueError, "Unknown file type for "+path 
     108            raise ValueError("Unknown file type for "+path) 
    109109        # All done 
    110110        return loaders 
     
    160160    try:  reg.load('hello.cx2') 
    161161    except CxError: pass # correct failure 
    162     else: raise AssertError,"Incorrect error on load failure" 
     162    else: raise AssertError("Incorrect error on load failure") 
    163163    # Make sure the case of no loaders fails correctly 
    164164    try: reg.load('hello.missing') 
    165165    except ValueError,msg: 
    166166        assert str(msg)=="Unknown file type for hello.missing",'Message: <%s>'%(msg) 
    167     else: raise AssertError,"No error raised for missing extension" 
     167    else: raise AssertError("No error raised for missing extension") 
    168168    assert reg.formats() == ['new_cx'] 
    169169    assert reg.extensions() == ['.cx','.cx.gz','.cx1','.cx1.gz','.cx2','.gz'] 
  • src/sas/sascalc/dataloader/data_info.py

    ra1b8fee ra1b8fee  
    716716                self.y_unit = '1/cm' 
    717717        except: # the data is not recognized/supported, and the user is notified 
    718             raise(TypeError, 'data not recognized, check documentation for supported 1D data formats') 
     718            raise TypeError 
    719719 
    720720    def __str__(self): 
     
    796796                len(self.y) != len(other.y): 
    797797                msg = "Unable to perform operation: data length are not equal" 
    798                 raise ValueError, msg 
     798                raise ValueError(msg) 
    799799            # Here we could also extrapolate between data points 
    800800            TOLERANCE = 0.01 
     
    802802                if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 
    803803                    msg = "Incompatible data sets: x-values do not match" 
    804                     raise ValueError, msg 
     804                    raise ValueError(msg) 
    805805 
    806806            # Check that the other data set has errors, otherwise 
     
    876876        if not isinstance(other, Data1D): 
    877877            msg = "Unable to perform operation: different types of data set" 
    878             raise ValueError, msg 
     878            raise ValueError(msg) 
    879879        return True 
    880880 
     
    948948 
    949949        if len(self.detector) > 0: 
    950             raise RuntimeError, "Data2D: Detector bank already filled at init" 
     950            raise RuntimeError("Data2D: Detector bank already filled at init") 
    951951 
    952952    def __str__(self): 
     
    10201020                len(self.qy_data) != len(other.qy_data): 
    10211021                msg = "Unable to perform operation: data length are not equal" 
    1022                 raise ValueError, msg 
     1022                raise ValueError(msg) 
    10231023            for ind in range(len(self.data)): 
    10241024                if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 
    10251025                    msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 
    1026                     raise ValueError, msg 
     1026                    raise ValueError(msg) 
    10271027                if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 
    10281028                    msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 
    1029                     raise ValueError, msg 
     1029                    raise ValueError(msg) 
    10301030 
    10311031            # Check that the scales match 
     
    11081108        if not isinstance(other, Data2D): 
    11091109            msg = "Unable to perform operation: different types of data set" 
    1110             raise ValueError, msg 
     1110            raise ValueError(msg) 
    11111111        return True 
    11121112 
  • src/sas/sascalc/dataloader/loader.py

    r463e7ffc rb9d74f3  
    295295        # Raise an error if there are no matching extensions 
    296296        if len(writers) == 0: 
    297             raise ValueError, "Unknown file type for " + path 
     297            raise ValueError("Unknown file type for " + path) 
    298298        # All done 
    299299        return writers 
  • src/sas/sascalc/dataloader/manipulations.py

    r7432acb rb9d74f3  
    8181    """ 
    8282    if data2d.data is None or data2d.x_bins is None or data2d.y_bins is None: 
    83         raise ValueError, "Can't convert this data: data=None..." 
     83        raise ValueError("Can't convert this data: data=None...") 
    8484    new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 
    8585    new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1)) 
     
    146146            msg = "_Slab._avg: invalid number of " 
    147147            msg += " detectors: %g" % len(data2D.detector) 
    148             raise RuntimeError, msg 
     148            raise RuntimeError(msg) 
    149149 
    150150        # Get data 
     
    168168            nbins = int(math.ceil((self.y_max - y_min) / self.bin_width)) 
    169169        else: 
    170             raise RuntimeError, "_Slab._avg: unrecognized axis %s" % str(maj) 
     170            raise RuntimeError("_Slab._avg: unrecognized axis %s" % str(maj)) 
    171171 
    172172        x = numpy.zeros(nbins) 
     
    229229        if not idx.any(): 
    230230            msg = "Average Error: No points inside ROI to average..." 
    231             raise ValueError, msg 
     231            raise ValueError(msg) 
    232232        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx]) 
    233233 
     
    302302            msg = "Circular averaging: invalid number " 
    303303            msg += "of detectors: %g" % len(data2D.detector) 
    304             raise RuntimeError, msg 
     304            raise RuntimeError(msg) 
    305305        # Get data 
    306306        data = data2D.data[numpy.isfinite(data2D.data)] 
     
    464464        if len(data2D.q_data) is None: 
    465465            msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 
    466             raise RuntimeError, msg 
     466            raise RuntimeError(msg) 
    467467 
    468468        # Build array of Q intervals 
     
    488488            ## No need to calculate the frac when all data are within range 
    489489            if self.r_min >= self.r_max: 
    490                 raise ValueError, "Limit Error: min > max" 
     490                raise ValueError("Limit Error: min > max") 
    491491 
    492492            if self.r_min <= q_value and q_value <= self.r_max: 
     
    539539        if not idx.any(): 
    540540            msg = "Average Error: No points inside ROI to average..." 
    541             raise ValueError, msg 
     541            raise ValueError(msg) 
    542542 
    543543        return Data1D(x=x[idx], y=y[idx], dy=err_y[idx], dx=d_x) 
     
    580580        """ 
    581581        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    582             raise RuntimeError, "Ring averaging only take plottable_2D objects" 
     582            raise RuntimeError("Ring averaging only take plottable_2D objects") 
    583583 
    584584        Pi = math.pi 
     
    640640        if not idx.any(): 
    641641            msg = "Average Error: No points inside ROI to average..." 
    642             raise ValueError, msg 
     642            raise ValueError(msg) 
    643643        #elif len(phi_bins[idx])!= self.nbins_phi: 
    644644        #    print "resulted",self.nbins_phi- len(phi_bins[idx]) 
     
    765765        """ 
    766766        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    767             raise RuntimeError, "Ring averaging only take plottable_2D objects" 
     767            raise RuntimeError("Ring averaging only take plottable_2D objects") 
    768768        Pi = math.pi 
    769769 
     
    931931        if not idx.any(): 
    932932            msg = "Average Error: No points inside sector of ROI to average..." 
    933             raise ValueError, msg 
     933            raise ValueError(msg) 
    934934        #elif len(y[idx])!= self.nbins: 
    935935        #    print "resulted",self.nbins- len(y[idx]), 
     
    10071007        """ 
    10081008        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1009             raise RuntimeError, "Ring cut only take plottable_2D objects" 
     1009            raise RuntimeError("Ring cut only take plottable_2D objects") 
    10101010 
    10111011        # Get data 
     
    10551055        """ 
    10561056        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1057             raise RuntimeError, "Boxcut take only plottable_2D objects" 
     1057            raise RuntimeError("Boxcut take only plottable_2D objects") 
    10581058        # Get qx_ and qy_data 
    10591059        qx_data = data2D.qx_data 
     
    11061106        """ 
    11071107        if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 
    1108             raise RuntimeError, "Sectorcut take only plottable_2D objects" 
     1108            raise RuntimeError("Sectorcut take only plottable_2D objects") 
    11091109        Pi = math.pi 
    11101110        # Get data 
  • src/sas/sascalc/dataloader/readers/abs_reader.py

    r959eb01 rb9d74f3  
    5050                    input_f = open(path,'r') 
    5151                except: 
    52                     raise  RuntimeError, "abs_reader: cannot open %s" % path 
     52                    raise  RuntimeError("abs_reader: cannot open %s" % path) 
    5353                buff = input_f.read() 
    5454                lines = buff.split('\n') 
     
    9999                            #goes to ASC reader 
    100100                            msg = "abs_reader: cannot open %s" % path 
    101                             raise  RuntimeError, msg 
     101                            raise  RuntimeError(msg) 
    102102                         
    103103                        # Distance in meters 
     
    114114                            #goes to ASC reader 
    115115                            msg = "abs_reader: cannot open %s" % path 
    116                             raise  RuntimeError, msg 
     116                            raise  RuntimeError(msg) 
    117117                        # Transmission 
    118118                        try: 
     
    223223                if not len(y) == len(dy): 
    224224                    msg = "abs_reader: y and dy have different length" 
    225                     raise ValueError, msg 
     225                    raise ValueError(msg) 
    226226                # If the data length is zero, consider this as 
    227227                # though we were not able to read the file. 
    228228                if len(x) == 0: 
    229                     raise ValueError, "ascii_reader: could not load file" 
     229                    raise ValueError("ascii_reader: could not load file") 
    230230                 
    231231                output.x = x[x != 0] 
     
    246246                return output 
    247247        else: 
    248             raise RuntimeError, "%s is not a file" % path 
     248            raise RuntimeError("%s is not a file" % path) 
    249249        return None 
  • src/sas/sascalc/dataloader/readers/ascii_reader.py

    r235f514 rb9d74f3  
    6464                    input_f = open(path,'rb') 
    6565                except: 
    66                     raise  RuntimeError, "ascii_reader: cannot open %s" % path 
     66                    raise  RuntimeError("ascii_reader: cannot open %s" % path) 
    6767                buff = input_f.read() 
    6868                lines = buff.splitlines() 
     
    173173                if not is_data: 
    174174                    msg = "ascii_reader: x has no data" 
    175                     raise RuntimeError, msg 
     175                    raise RuntimeError(msg) 
    176176                # Sanity check 
    177177                if has_error_dy == True and not len(ty) == len(tdy): 
    178178                    msg = "ascii_reader: y and dy have different length" 
    179                     raise RuntimeError, msg 
     179                    raise RuntimeError(msg) 
    180180                if has_error_dx == True and not len(tx) == len(tdx): 
    181181                    msg = "ascii_reader: y and dy have different length" 
    182                     raise RuntimeError, msg 
     182                    raise RuntimeError(msg) 
    183183                # If the data length is zero, consider this as 
    184184                # though we were not able to read the file. 
    185185                if len(tx) == 0: 
    186                     raise RuntimeError, "ascii_reader: could not load file" 
     186                    raise RuntimeError("ascii_reader: could not load file") 
    187187 
    188188                #Let's re-order the data to make cal. 
     
    222222                output.meta_data['loader'] = self.type_name 
    223223                if len(output.x) < 1: 
    224                     raise RuntimeError, "%s is empty" % path 
     224                    raise RuntimeError("%s is empty" % path) 
    225225                return output 
    226226 
    227227        else: 
    228             raise RuntimeError, "%s is not a file" % path 
     228            raise RuntimeError("%s is not a file" % path) 
    229229        return None 
    230230 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r7432acb rb9d74f3  
    14791479                                logger.info(err_mess) 
    14801480                            else: 
    1481                                 raise ValueError, err_mess 
     1481                                raise ValueError(err_mess) 
    14821482                    else: 
    14831483                        err_mess = "CanSAS reader: unrecognized %s unit [%s];"\ 
     
    14881488                            logger.info(err_mess) 
    14891489                        else: 
    1490                             raise ValueError, err_mess 
     1490                            raise ValueError(err_mess) 
    14911491                else: 
    14921492                    exec "storage.%s = value" % variable 
  • src/sas/sascalc/dataloader/readers/danse_reader.py

    r235f514 rb9d74f3  
    5656                datafile = open(filename, 'r') 
    5757            except: 
    58                 raise  RuntimeError,"danse_reader cannot open %s" % (filename) 
     58                raise  RuntimeError("danse_reader cannot open %s" % (filename)) 
    5959         
    6060            # defaults 
     
    271271            if not fversion >= 1.0: 
    272272                msg = "Danse_reader can't read this file %s" % filename 
    273                 raise ValueError, msg 
     273                raise ValueError(msg) 
    274274            else: 
    275275                logger.info("Danse_reader Reading %s \n" % filename) 
  • src/sas/sascalc/dataloader/readers/hfir1d_reader.py

    r959eb01 rb9d74f3  
    4949                    input_f = open(path,'r') 
    5050                except: 
    51                     raise  RuntimeError, "hfir1d_reader: cannot open %s" % path 
     51                    raise  RuntimeError("hfir1d_reader: cannot open %s" % path) 
    5252                buff = input_f.read() 
    5353                lines = buff.split('\n') 
     
    9999                if not len(y) == len(dy): 
    100100                    msg = "hfir1d_reader: y and dy have different length" 
    101                     raise RuntimeError, msg 
     101                    raise RuntimeError(msg) 
    102102                if not len(x) == len(dx): 
    103103                    msg = "hfir1d_reader: x and dx have different length" 
    104                     raise RuntimeError, msg 
     104                    raise RuntimeError(msg) 
    105105 
    106106                # If the data length is zero, consider this as 
    107107                # though we were not able to read the file. 
    108108                if len(x) == 0: 
    109                     raise RuntimeError, "hfir1d_reader: could not load file" 
     109                    raise RuntimeError("hfir1d_reader: could not load file") 
    110110                
    111111                output.x = x 
     
    126126                return output 
    127127        else: 
    128             raise RuntimeError, "%s is not a file" % path 
     128            raise RuntimeError("%s is not a file" % path) 
    129129        return None 
  • src/sas/sascalc/dataloader/readers/nexus_reader.py

    r959eb01 rb9d74f3  
    3535            msg = "Error reading Nexus file: Nexus package is missing.\n" 
    3636            msg += "  Get it from http://http://www.nexusformat.org/" 
    37             raise RuntimeError, msg 
     37            raise RuntimeError(msg) 
    3838         
    3939        # Instantiate data object 
  • src/sas/sascalc/dataloader/readers/red2d_reader.py

    ra1b8fee ra1b8fee  
    7272        """ Read file """ 
    7373        if not os.path.isfile(filename): 
    74             raise ValueError, \ 
    75             "Specified file %s is not a regular file" % filename 
     74            raise ValueError("Specified file %s is not a regular file" % filename) 
    7675 
    7776        # Read file 
     
    234233        except: 
    235234            msg = "red2d_reader: Can't read this file: Not a proper file format" 
    236             raise ValueError, msg 
     235            raise ValueError(msg) 
    237236        ## Get the all data: Let's HARDcoding; Todo find better way 
    238237        # Defaults 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r9a5097c rb9d74f3  
    5757                    input_f = open(path,'rb') 
    5858                except: 
    59                     raise  RuntimeError, "sesans_reader: cannot open %s" % path 
     59                    raise  RuntimeError("sesans_reader: cannot open %s" % path) 
    6060                buff = input_f.read() 
    6161                lines = buff.splitlines() 
     
    158158 
    159159                if len(output.x) < 1: 
    160                     raise RuntimeError, "%s is empty" % path 
     160                    raise RuntimeError("%s is empty" % path) 
    161161                return output 
    162162 
    163163        else: 
    164             raise RuntimeError, "%s is not a file" % path 
     164            raise RuntimeError("%s is not a file" % path) 
    165165        return None 
    166166 
  • src/sas/sascalc/dataloader/readers/tiff_reader.py

    r959eb01 rb9d74f3  
    4444        except: 
    4545            msg = "tiff_reader: could not load file. Missing Image module." 
    46             raise RuntimeError, msg 
     46            raise RuntimeError(msg) 
    4747         
    4848        # Instantiate data object 
     
    5454            im = Image.open(filename) 
    5555        except: 
    56             raise  RuntimeError, "cannot open %s"%(filename) 
     56            raise  RuntimeError("cannot open %s"%(filename)) 
    5757        data = im.getdata() 
    5858 
  • src/sas/sascalc/file_converter/cansas_writer.py

    r7432acb rb9d74f3  
    3232        valid_class = all([issubclass(data.__class__, Data1D) for data in frame_data]) 
    3333        if not valid_class: 
    34             raise RuntimeError, ("The cansas writer expects an array of " 
     34            raise RuntimeError("The cansas writer expects an array of " 
    3535                "Data1D instances") 
    3636 
  • src/sas/sascalc/fit/AbstractFitEngine.py

    ra1b8fee ra1b8fee  
    251251            msg = "FitData1D: invalid error array " 
    252252            msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 
    253             raise RuntimeError, msg 
     253            raise RuntimeError(msg) 
    254254        return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 
    255255             
  • src/sas/sascalc/fit/Loader.py

    ra1b8fee ra1b8fee  
    5959            # Sanity check 
    6060            if not len(self.x) == len(self.dx): 
    61                 raise ValueError, "x and dx have different length" 
     61                raise ValueError("x and dx have different length") 
    6262            if not len(self.y) == len(self.dy): 
    63                 raise ValueError, "y and dy have different length" 
     63                raise ValueError("y and dy have different length") 
    6464             
    6565             
  • src/sas/sascalc/fit/MultiplicationModel.py

    r7432acb rb9d74f3  
    245245                    return 
    246246 
    247         raise ValueError, "Model does not contain parameter %s" % name 
     247        raise ValueError("Model does not contain parameter %s" % name) 
    248248 
    249249 
  • src/sas/sascalc/fit/expression.py

    ra1b8fee ra1b8fee  
    239239        if independent == emptyset: 
    240240            cycleset = ", ".join(str(s) for s in left) 
    241             raise ValueError,"Cyclic dependencies amongst %s"%cycleset 
     241            raise ValueError("Cyclic dependencies amongst %s"%cycleset) 
    242242 
    243243        # The possibly resolvable items are those that depend on the independents 
     
    267267        n.sort() 
    268268        items = list(items); items.sort() 
    269         raise Exception,"%s expect %s to contain %s for %s"%(msg,n,items,pairs) 
     269        raise Exception("%s expect %s to contain %s for %s"%(msg,n,items,pairs)) 
    270270    for lo,hi in pairs: 
    271271        if lo in n and hi in n and n.index(lo) >= n.index(hi): 
    272             raise Exception,"%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs) 
     272            raise Exception("%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)) 
    273273 
    274274def test_deps(): 
     
    290290    try: n = order_dependencies(pairs) 
    291291    except ValueError: pass 
    292     else: raise Exception,"test3 expect ValueError exception for %s"%(pairs,) 
     292    else: raise Exception("test3 expect ValueError exception for %s"%(pairs,)) 
    293293 
    294294    # large test for gross speed check 
  • src/sas/sascalc/fit/pluginmodel.py

    r5213d22 rb9d74f3  
    3535            return self.function(x_val)*self.function(y_val) 
    3636        elif x.__class__.__name__ == 'tuple': 
    37             raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     37            raise ValueError("Tuples are not allowed as input to BaseComponent models") 
    3838        else: 
    3939            return self.function(x) 
     
    5252            return self.function(x[0])*self.function(x[1]) 
    5353        elif x.__class__.__name__ == 'tuple': 
    54             raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
     54            raise ValueError("Tuples are not allowed as input to BaseComponent models") 
    5555        else: 
    5656            return self.function(x) 
  • src/sas/sascalc/invariant/invariant.py

    r7432acb rb9d74f3  
    424424        if not issubclass(data.__class__, LoaderData1D): 
    425425            #Process only data that inherited from DataLoader.Data_info.Data1D 
    426             raise ValueError, "Data must be of type DataLoader.Data1D" 
     426            raise ValueError("Data must be of type DataLoader.Data1D") 
    427427        #from copy import deepcopy 
    428428        new_data = (self._scale * data) - self._background 
     
    484484            msg = "Length x and y must be equal" 
    485485            msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 
    486             raise ValueError, msg 
     486            raise ValueError(msg) 
    487487        else: 
    488488            # Take care of smeared data 
     
    533533            msg = "Length of data.x and data.y must be equal" 
    534534            msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 
    535             raise ValueError, msg 
     535            raise ValueError(msg) 
    536536        else: 
    537537            #Create error for data without dy error 
     
    742742        range = range.lower() 
    743743        if range not in ['high', 'low']: 
    744             raise ValueError, "Extrapolation range should be 'high' or 'low'" 
     744            raise ValueError("Extrapolation range should be 'high' or 'low'") 
    745745        function = function.lower() 
    746746        if function not in ['power_law', 'guinier']: 
    747747            msg = "Extrapolation function should be 'guinier' or 'power_law'" 
    748             raise ValueError, msg 
     748            raise ValueError(msg) 
    749749 
    750750        if range == 'high': 
    751751            if function != 'power_law': 
    752752                msg = "Extrapolation only allows a power law at high Q" 
    753                 raise ValueError, msg 
     753                raise ValueError(msg) 
    754754            self._high_extrapolation_npts = npts 
    755755            self._high_extrapolation_power = power 
     
    852852        """ 
    853853        if contrast <= 0: 
    854             raise ValueError, "The contrast parameter must be greater than zero" 
     854            raise ValueError("The contrast parameter must be greater than zero") 
    855855 
    856856        # Make sure Q star is up to date 
     
    859859        if self._qstar <= 0: 
    860860            msg = "Invalid invariant: Invariant Q* must be greater than zero" 
    861             raise RuntimeError, msg 
     861            raise RuntimeError(msg) 
    862862 
    863863        # Compute intermediate constant 
     
    869869        if discrim < 0: 
    870870            msg = "Could not compute the volume fraction: negative discriminant" 
    871             raise RuntimeError, msg 
     871            raise RuntimeError(msg) 
    872872        elif discrim == 0: 
    873873            return 1 / 2 
     
    881881                return volume2 
    882882            msg = "Could not compute the volume fraction: inconsistent results" 
    883             raise RuntimeError, msg 
     883            raise RuntimeError(msg) 
    884884 
    885885    def get_qstar_with_error(self, extrapolation=None): 
  • src/sas/sascalc/pr/fit/AbstractFitEngine.py

    ra1b8fee ra1b8fee  
    251251            msg = "FitData1D: invalid error array " 
    252252            msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 
    253             raise RuntimeError, msg 
     253            raise RuntimeError(msg) 
    254254        return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 
    255255             
  • src/sas/sascalc/pr/fit/Loader.py

    ra1b8fee ra1b8fee  
    5959            # Sanity check 
    6060            if not len(self.x) == len(self.dx): 
    61                 raise ValueError, "x and dx have different length" 
     61                raise ValueError("x and dx have different length") 
    6262            if not len(self.y) == len(self.dy): 
    63                 raise ValueError, "y and dy have different length" 
     63                raise ValueError("y and dy have different length") 
    6464             
    6565             
  • src/sas/sascalc/pr/fit/expression.py

    ra1b8fee ra1b8fee  
    239239        if independent == emptyset: 
    240240            cycleset = ", ".join(str(s) for s in left) 
    241             raise ValueError,"Cyclic dependencies amongst %s"%cycleset 
     241            raise ValueError("Cyclic dependencies amongst %s"%cycleset) 
    242242 
    243243        # The possibly resolvable items are those that depend on the independents 
     
    267267        n.sort() 
    268268        items = list(items); items.sort() 
    269         raise Exception,"%s expect %s to contain %s for %s"%(msg,n,items,pairs) 
     269        raise Exception("%s expect %s to contain %s for %s"%(msg,n,items,pairs)) 
    270270    for lo,hi in pairs: 
    271271        if lo in n and hi in n and n.index(lo) >= n.index(hi): 
    272             raise Exception,"%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs) 
     272            raise Exception("%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)) 
    273273 
    274274def test_deps(): 
     
    290290    try: n = order_dependencies(pairs) 
    291291    except ValueError: pass 
    292     else: raise Exception,"test3 expect ValueError exception for %s"%(pairs,) 
     292    else: raise Exception("test3 expect ValueError exception for %s"%(pairs,)) 
    293293 
    294294    # large test for gross speed check 
  • src/sas/sascalc/pr/invertor.py

    r45dffa69 rb9d74f3  
    148148                msg = "Invertor: one of your q-values is zero. " 
    149149                msg += "Delete that entry before proceeding" 
    150                 raise ValueError, msg 
     150                raise ValueError(msg) 
    151151            return self.set_x(value) 
    152152        elif name == 'y': 
     
    159159                msg = "Invertor: d_max must be greater than zero." 
    160160                msg += "Correct that entry before proceeding" 
    161                 raise ValueError, msg 
     161                raise ValueError(msg) 
    162162            return self.set_dmax(value) 
    163163        elif name == 'q_min': 
     
    181181                return self.set_has_bck(0) 
    182182            else: 
    183                 raise ValueError, "Invertor: has_bck can only be True or False" 
     183                raise ValueError("Invertor: has_bck can only be True or False") 
    184184 
    185185        return Cinvertor.__setattr__(self, name, value) 
     
    325325        if self.is_valid() <= 0: 
    326326            msg = "Invertor.invert: Data array are of different length" 
    327             raise RuntimeError, msg 
     327            raise RuntimeError(msg) 
    328328 
    329329        p = np.ones(nfunc) 
     
    358358        if self.is_valid() <= 0: 
    359359            msg = "Invertor.invert: Data arrays are of different length" 
    360             raise RuntimeError, msg 
     360            raise RuntimeError(msg) 
    361361 
    362362        p = np.ones(nfunc) 
     
    442442        if self.is_valid() < 0: 
    443443            msg = "Invertor: invalid data; incompatible data lengths." 
    444             raise RuntimeError, msg 
     444            raise RuntimeError(msg) 
    445445 
    446446        self.nfunc = nfunc 
     
    467467            self._get_matrix(nfunc, nq, a, b) 
    468468        except: 
    469             raise RuntimeError, "Invertor: could not invert I(Q)\n  %s" % sys.exc_value 
     469            raise RuntimeError("Invertor: could not invert I(Q)\n  %s" % sys.exc_value) 
    470470 
    471471        # Perform the inversion (least square fit) 
     
    751751            except: 
    752752                msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 
    753                 raise RuntimeError, msg 
     753                raise RuntimeError(msg) 
    754754        else: 
    755755            msg = "Invertor.from_file: '%s' is not a file" % str(path) 
    756             raise RuntimeError, msg 
     756            raise RuntimeError(msg) 
  • src/sas/sasgui/guiframe/data_processor.py

    ra1b8fee ra1b8fee  
    909909                    msg = "Edit axis doesn't understand this selection.\n" 
    910910                    msg += "Please select only one column" 
    911                     raise ValueError, msg 
     911                    raise ValueError(msg) 
    912912            for (_, cell_col) in grid.selected_cells: 
    913913                if cell_col != col: 
     
    915915                    msg += "this operation.\n" 
    916916                    msg += "Please select elements of the same col.\n" 
    917                     raise ValueError, msg 
     917                    raise ValueError(msg) 
    918918 
    919919            # Finally check the highlighted cell if any cells missing 
     
    922922            msg = "No item selected.\n" 
    923923            msg += "Please select only one column or one cell" 
    924             raise ValueError, msg 
     924            raise ValueError(msg) 
    925925        return grid.selected_cells 
    926926 
     
    13261326            if sentence.strip() == "": 
    13271327                msg = "Select column values for x axis" 
    1328                 raise ValueError, msg 
     1328                raise ValueError(msg) 
    13291329        except: 
    13301330            msg = "X axis value error." 
     
    13451345            if sentence.strip() == "": 
    13461346                msg = "select value for y axis" 
    1347                 raise ValueError, msg 
     1347                raise ValueError(msg) 
    13481348        except: 
    13491349            msg = "Y axis value error." 
  • src/sas/sasgui/guiframe/gui_manager.py

    r2f22db9 rb9d74f3  
    26132613            wx.PostEvent(self, StatusEvent(status=msg, 
    26142614                                           info="error")) 
    2615             raise ValueError, msg 
     2615            raise ValueError(msg) 
    26162616        # text = str(data) 
    26172617        text = data.__str__() 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py

    r7432acb rb9d74f3  
    235235            msg = "Phi left and phi right are different" 
    236236            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    237             raise ValueError, msg 
     237            raise ValueError(msg) 
    238238        params["Phi [deg]"] = self.main_line.theta * 180 / math.pi 
    239239        params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py

    r463e7ffc rb9d74f3  
    187187        # Check that the trigger is valid 
    188188        if trigger not in self._actions: 
    189             raise ValueError, "%s invalid --- valid triggers are %s" \ 
    190                 % (trigger, ", ".join(self.events)) 
     189            raise ValueError("%s invalid --- valid triggers are %s" \ 
     190                % (trigger, ", ".join(self.events))) 
    191191        # Register the trigger callback 
    192192        self._actions[trigger][artist] = action 
     
    203203        """ 
    204204        if action not in self.events: 
    205             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     205            raise ValueError("Trigger expects " + ", ".join(self.events)) 
    206206        # Tag the event with modifiers 
    207207        for mod in ('alt', 'control', 'shift', 'meta'): 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py

    r7432acb rb9d74f3  
    152152            if new_slab is None: 
    153153                msg = "post data:cannot average , averager is empty" 
    154                 raise ValueError, msg 
     154                raise ValueError(msg) 
    155155            self.averager = new_slab 
    156156        if self.direction == "X": 
     
    168168        else: 
    169169            msg = "post data:no Box Average direction was supplied" 
    170             raise ValueError, msg 
     170            raise ValueError(msg) 
    171171        # # Average data2D given Qx or Qy 
    172172        box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py

    r235f514 rb9d74f3  
    199199 
    200200        msg = "1D Panel of group ID %s could not be created" % str(group_id) 
    201         raise ValueError, msg 
     201        raise ValueError(msg) 
    202202 
    203203    def create_2d_panel(self, data, group_id): 
     
    217217            return new_panel 
    218218        msg = "2D Panel of group ID %s could not be created" % str(group_id) 
    219         raise ValueError, msg 
     219        raise ValueError(msg) 
    220220 
    221221    def update_panel(self, data, panel): 
     
    237237            msg += " to panel %s\n" % str(panel.window_caption) 
    238238            msg += "Please edit %s's units, labels" % str(data.name) 
    239             raise ValueError, msg 
     239            raise ValueError(msg) 
    240240        else: 
    241241            if panel.group_id not in data.list_group_id: 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py

    r7432acb rb9d74f3  
    175175            msg += "different %f, %f" % (self.left_line.phi, 
    176176                                         self.right_line.phi) 
    177             raise ValueError, msg 
     177            raise ValueError(msg) 
    178178        params["Phi"] = self.main_line.theta 
    179179        params["Delta_Phi"] = math.fabs(self.left_line.phi) 
  • src/sas/sasgui/guiframe/plugin_base.py

    r7432acb rb9d74f3  
    277277        """ 
    278278        msg = "%s plugin: does not support import theory" % str(self.sub_menu) 
    279         raise ValueError, msg 
     279        raise ValueError(msg) 
    280280 
    281281    def on_set_state_helper(self, event): 
  • src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py

    r7432acb rb9d74f3  
    10821082                msg = "The numbers must be one or two (separated by ',')..." 
    10831083                self._status_info(msg, 'stop') 
    1084                 raise RuntimeError, msg 
     1084                raise RuntimeError(msg) 
    10851085 
    10861086        return new_string 
  • src/sas/sasgui/perspectives/calculator/slit_length_calculator_panel.py

    r7432acb rb9d74f3  
    262262            if x == [] or  x is None or y == [] or y is None: 
    263263                msg = "The current data is empty please check x and y" 
    264                 raise ValueError, msg 
     264                raise ValueError(msg) 
    265265            slit_length_calculator = SlitlengthCalculator() 
    266266            slit_length_calculator.set_data(x=x, y=y) 
  • src/sas/sasgui/perspectives/corfunc/corfunc_state.py

    r7432acb rb9d74f3  
    284284            root, ext = os.path.splitext(basename) 
    285285            if not ext.lower() in self.ext: 
    286                 raise IOError, "{} is not a supported file type".format(ext) 
     286                raise IOError("{} is not a supported file type".format(ext)) 
    287287            tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 
    288288            root = tree.getroot() 
     
    300300            # File not found 
    301301            msg = "{} is not a valid file path or doesn't exist".format(path) 
    302             raise IOError, msg 
     302            raise IOError(msg) 
    303303 
    304304        if len(output) == 0: 
     
    324324            msg = ("The CanSAS writer expects a Data1D instance. {} was " 
    325325                "provided").format(datainfo.__class__.__name__) 
    326             raise RuntimeError, msg 
     326            raise RuntimeError(msg) 
    327327        if datainfo.title is None or datainfo.title == '': 
    328328            datainfo.title = datainfo.name 
  • src/sas/sasgui/perspectives/fitting/fit_thread.py

    r959eb01 rb9d74f3  
    5454        except KeyboardInterrupt: 
    5555            msg = "Fitting: terminated by the user." 
    56             raise KeyboardInterrupt, msg 
     56            raise KeyboardInterrupt(msg) 
    5757 
    5858    def compute(self): 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r9a5097c rb9d74f3  
    18471847                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 
    18481848                                               info="error")) 
    1849                     raise ValueError, msg 
     1849                    raise ValueError(msg) 
    18501850 
    18511851            else: 
     
    18591859                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 
    18601860                                               info="error")) 
    1861                     raise ValueError, msg 
     1861                    raise ValueError(msg) 
    18621862                # Maximum value of data 
    18631863                qmax = math.sqrt(x * x + y * y) 
     
    20982098        self._on_fit_complete() 
    20992099        if out is None or not np.isfinite(chisqr): 
    2100             raise ValueError, "Fit error occured..." 
     2100            raise ValueError("Fit error occured...") 
    21012101 
    21022102        is_modified = False 
     
    21732173                i += 1 
    21742174            else: 
    2175                 raise ValueError, "onsetValues: Invalid parameters..." 
     2175                raise ValueError("onsetValues: Invalid parameters...") 
    21762176        # Show error title when any errors displayed 
    21772177        if has_error: 
  • src/sas/sasgui/perspectives/fitting/fitpanel.py

    r67b0a99 rb9d74f3  
    125125        if uid not in self.opened_pages: 
    126126            msg = "Fitpanel cannot find ID: %s in self.opened_pages" % str(uid) 
    127             raise ValueError, msg 
     127            raise ValueError(msg) 
    128128        else: 
    129129            return self.opened_pages[uid] 
     
    389389        """ 
    390390        if data.__class__.__name__ != "list": 
    391             raise ValueError, "Fitpanel delete_data expect list of id" 
     391            raise ValueError("Fitpanel delete_data expect list of id") 
    392392        else: 
    393393            for page in self.opened_pages.values(): 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    ra1b8fee ra1b8fee  
    12341234        panel = self.plot_panel 
    12351235        if panel is None: 
    1236             raise ValueError, "Fitting:_onSelect: NonType panel" 
     1236            raise ValueError("Fitting:_onSelect: NonType panel") 
    12371237        Plugin.on_perspective(self, event=event) 
    12381238        self.select_data(panel) 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    r7432acb rb9d74f3  
    6565        if self.data is None: 
    6666            msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 
    67             raise ValueError, msg 
     67            raise ValueError(msg) 
    6868 
    6969        # Define matrix where data will be plotted 
  • src/sas/sasgui/perspectives/fitting/models.py

    ra1b8fee ra1b8fee  
    144144        if type is not None and issubclass(type, py_compile.PyCompileError): 
    145145            print("Problem with", repr(value)) 
    146             raise type, value, tb 
     146            raise type(value).with_traceback(tb) 
    147147        return 1 
    148148 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r959eb01 rb9d74f3  
    10141014            msg = "PageState no longer supports non-CanSAS" 
    10151015            msg += " format for fitting files" 
    1016             raise RuntimeError, msg 
     1016            raise RuntimeError(msg) 
    10171017 
    10181018        if node.get('version'): 
     
    13101310            else: 
    13111311                self.call_back(format=ext) 
    1312                 raise RuntimeError, "%s is not a file" % path 
     1312                raise RuntimeError("%s is not a file" % path) 
    13131313 
    13141314            # Return output consistent with the loader's api 
  • src/sas/sasgui/perspectives/invariant/invariant.py

    r7432acb rb9d74f3  
    133133            name = data.__class__.__name__ 
    134134            msg = "Invariant use only Data1D got: [%s] " % str(name) 
    135             raise ValueError, msg 
     135            raise ValueError(msg) 
    136136        self.compute_helper(data=data) 
    137137 
     
    240240            msg = "invariant.save_file: the data being saved is" 
    241241            msg += " not a sas.sascalc.dataloader.data_info.Data1D object" 
    242             raise RuntimeError, msg 
     242            raise RuntimeError(msg) 
    243243 
    244244    def set_state(self, state=None, datainfo=None): 
     
    258258                msg = "invariant.set_state: datainfo parameter cannot" 
    259259                msg += " be None in standalone mode" 
    260                 raise RuntimeError, msg 
     260                raise RuntimeError(msg) 
    261261            # Make sure the user sees the invariant panel after loading 
    262262            # self.parent.set_perspective(self.perspective) 
     
    320320        else: 
    321321            msg = "Scale can not be zero." 
    322             raise ValueError, msg 
     322            raise ValueError(msg) 
    323323        if len(new_plot.x) == 0: 
    324324            return 
  • src/sas/sasgui/perspectives/invariant/invariant_panel.py

    r7432acb rb9d74f3  
    318318        background = self.background_tcl.GetValue().lstrip().rstrip() 
    319319        if background == "": 
    320             raise ValueError, "Need a background" 
     320            raise ValueError("Need a background") 
    321321        if check_float(self.background_tcl): 
    322322            return float(background) 
    323323        else: 
    324324            msg = "Receive invalid value for background : %s" % (background) 
    325             raise ValueError, msg 
     325            raise ValueError(msg) 
    326326 
    327327    def get_scale(self): 
     
    331331        scale = self.scale_tcl.GetValue().lstrip().rstrip() 
    332332        if scale == "": 
    333             raise ValueError, "Need a background" 
     333            raise ValueError("Need a background") 
    334334        if check_float(self.scale_tcl): 
    335335            if float(scale) <= 0.0: 
     
    337337                self.scale_tcl.Refresh() 
    338338                msg = "Receive invalid value for scale: %s" % (scale) 
    339                 raise ValueError, msg 
     339                raise ValueError(msg) 
    340340            return float(scale) 
    341341        else: 
    342             raise ValueError, "Receive invalid value for scale : %s" % (scale) 
     342            raise ValueError("Receive invalid value for scale : %s" % (scale)) 
    343343 
    344344    def get_contrast(self): 
     
    865865        except: 
    866866            logger.error(sys.exc_value) 
    867             raise ValueError, "No such bookmark exists" 
     867            raise ValueError("No such bookmark exists") 
    868868 
    869869        # set the parameters 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    r7432acb rb9d74f3  
    365365            msg = "InvariantSate no longer supports non-CanSAS" 
    366366            msg += " format for invariant files" 
    367             raise RuntimeError, msg 
     367            raise RuntimeError(msg) 
    368368 
    369369        if node.get('version')\ 
     
    739739                        output.append(sas_entry) 
    740740        else: 
    741             raise RuntimeError, "%s is not a file" % path 
     741            raise RuntimeError("%s is not a file" % path) 
    742742 
    743743        # Return output consistent with the loader's api 
     
    785785            msg = "The cansas writer expects a Data1D" 
    786786            msg += " instance: %s" % str(datainfo.__class__.__name__) 
    787             raise RuntimeError, msg 
     787            raise RuntimeError(msg) 
    788788        # make sure title and data run is filled up. 
    789789        if datainfo.title is None or datainfo.title == '': 
  • src/sas/sasgui/perspectives/pr/inversion_panel.py

    r7432acb rb9d74f3  
    854854                message += "than the number of points" 
    855855                wx.PostEvent(self._manager.parent, StatusEvent(status=message)) 
    856                 raise ValueError, message 
     856                raise ValueError(message) 
    857857            self.nfunc_ctl.SetBackgroundColour(wx.WHITE) 
    858858            self.nfunc_ctl.Refresh() 
  • src/sas/sasgui/perspectives/pr/inversion_state.py

    r7432acb rb9d74f3  
    235235            msg = "InversionState no longer supports non-CanSAS" 
    236236            msg += " format for P(r) files" 
    237             raise RuntimeError, msg 
     237            raise RuntimeError(msg) 
    238238 
    239239        if node.get('version') and node.get('version') == '1.0': 
     
    478478                        output.append(sas_entry) 
    479479        else: 
    480             raise RuntimeError, "%s is not a file" % path 
     480            raise RuntimeError("%s is not a file" % path) 
    481481 
    482482        # Return output consistent with the loader's api 
     
    522522            msg = "The cansas writer expects a Data1D " 
    523523            msg += "instance: %s" % str(datainfo.__class__.__name__) 
    524             raise RuntimeError, msg 
     524            raise RuntimeError(msg) 
    525525 
    526526        # Create basic XML document 
  • src/sas/sasgui/perspectives/pr/pr.py

    ra1b8fee ra1b8fee  
    150150                msg = "Pr.set_state: datainfo parameter cannot " 
    151151                msg += "be None in standalone mode" 
    152                 raise RuntimeError, msg 
     152                raise RuntimeError(msg) 
    153153 
    154154            # Ensuring that plots are coordinated correctly 
     
    451451        # Notify the user if we could not read the file 
    452452        if dataread is None: 
    453             raise RuntimeError, "Invalid data" 
     453            raise RuntimeError("Invalid data") 
    454454 
    455455        x = None 
     
    471471                if dataread is None: 
    472472                    return x, y, err 
    473                 raise RuntimeError, "This tool can only read 1D data" 
     473                raise RuntimeError("This tool can only read 1D data") 
    474474 
    475475        self._current_file_data.x = x 
     
    850850                status = "Problem reading data: %s" % sys.exc_value 
    851851                wx.PostEvent(self.parent, StatusEvent(status=status)) 
    852                 raise RuntimeError, status 
     852                raise RuntimeError(status) 
    853853 
    854854            # If the file contains nothing, just return 
    855855            if pr is None: 
    856                 raise RuntimeError, "Loaded data is invalid" 
     856                raise RuntimeError("Loaded data is invalid") 
    857857 
    858858            self.pr = pr 
     
    904904            msg = "pr.save_data: the data being saved is not a" 
    905905            msg += " sas.data_info.Data1D object" 
    906             raise RuntimeError, msg 
     906            raise RuntimeError(msg) 
    907907 
    908908    def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None, 
  • src/sas/sasgui/perspectives/simulation/ShapeAdapter.py

    r959eb01 rb9d74f3  
    8787            self.sim_canvas._model_changed() 
    8888        else: 
    89             raise ValueError, "SimShapeVisitor: Wrong class for visited object" 
     89            raise ValueError("SimShapeVisitor: Wrong class for visited object") 
    9090         
    9191         
     
    115115            self.sim_canvas._model_changed() 
    116116        else: 
    117             raise ValueError, "SimShapeVisitor: Wrong class for visited object" 
     117            raise ValueError("SimShapeVisitor: Wrong class for visited object") 
    118118         
    119119     
     
    130130            shape.accept_update(self) 
    131131        else: 
    132             raise ValueError, "ShapeAdapter: Shape [%s] not in list" % shape.name 
     132            raise ValueError("ShapeAdapter: Shape [%s] not in list" % shape.name) 
    133133 
  • src/sas/sasgui/plottools/LineModel.py

    r959eb01 rb9d74f3  
    8282        elif x.__class__.__name__ == 'tuple': 
    8383            msg = "Tuples are not allowed as input to BaseComponent models" 
    84             raise ValueError, msg 
     84            raise ValueError(msg) 
    8585        else: 
    8686            return self._line(x) 
     
    104104        elif x.__class__.__name__ == 'tuple': 
    105105            msg = "Tuples are not allowed as input to BaseComponent models" 
    106             raise ValueError, msg 
     106            raise ValueError(msg) 
    107107        else: 
    108108            return self._line(x) 
  • src/sas/sasgui/plottools/binder.py

    ra1b8fee ra1b8fee  
    189189        # Check that the trigger is valid 
    190190        if trigger not in self._actions: 
    191             raise ValueError, "%s invalid --- valid triggers are %s"\ 
    192                  % (trigger, ", ".join(self.events)) 
     191            raise ValueError("%s invalid --- valid triggers are %s"\ 
     192                 % (trigger, ", ".join(self.events))) 
    193193 
    194194        # Register the trigger callback 
     
    205205        """ 
    206206        if action not in self.events: 
    207             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     207            raise ValueError("Trigger expects " + ", ".join(self.events)) 
    208208 
    209209        # Tag the event with modifiers 
  • src/sas/sasgui/plottools/convert_units.py

    ra1b8fee ra1b8fee  
    4444                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4545                else: 
    46                     raise ValueError, "missing } in unit expression" 
     46                    raise ValueError("missing } in unit expression") 
    4747        else:  # no powerer 
    4848            if  power != 1: 
    4949                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    5050    else: 
    51         raise ValueError, "empty unit ,enter a powerer different from zero" 
     51        raise ValueError("empty unit ,enter a powerer different from zero") 
    5252    return unit 
    5353 
  • src/sas/sasgui/plottools/fitDialog.py

    r7432acb rb9d74f3  
    671671                return x 
    672672            else: 
    673                 raise ValueError, "cannot compute log of a negative number" 
     673                raise ValueError("cannot compute log of a negative number") 
    674674 
    675675    def floatInvTransform(self, x): 
     
    734734        except: 
    735735            msg = "LinearFit.set_fit_region: fit range must be floats" 
    736             raise ValueError, msg 
     736            raise ValueError(msg) 
    737737        self.xminFit.SetValue(format_number(xmin)) 
    738738        self.xmaxFit.SetValue(format_number(xmax)) 
  • src/sas/sasgui/plottools/plottables.py

    r45dffa69 rb9d74f3  
    386386 
    387387        """ 
    388         raise NotImplemented, "Not a valid transform" 
     388        raise NotImplemented("Not a valid transform") 
    389389 
    390390    # Related issues 
     
    686686                msg = "Plottable.View: Given x and dx are not" 
    687687                msg += " of the same length" 
    688                 raise ValueError, msg 
     688                raise ValueError(msg) 
    689689            # Check length of y array 
    690690            if not len(y) == len(x): 
    691691                msg = "Plottable.View: Given y " 
    692692                msg += "and x are not of the same length" 
    693                 raise ValueError, msg 
     693                raise ValueError(msg) 
    694694 
    695695            if dy is not None and not len(dy) == 0 and not len(y) == len(dy): 
    696696                msg = "Plottable.View: Given y and dy are not of the same " 
    697697                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
    698                 raise ValueError, msg 
     698                raise ValueError(msg) 
    699699            self.x = [] 
    700700            self.y = [] 
     
    731731                msg = "Plottable.View: transformed x " 
    732732                msg += "and y are not of the same length" 
    733                 raise ValueError, msg 
     733                raise ValueError(msg) 
    734734            if has_err_x and not (len(self.x) == len(self.dx)): 
    735735                msg = "Plottable.View: transformed x and dx" 
    736736                msg += " are not of the same length" 
    737                 raise ValueError, msg 
     737                raise ValueError(msg) 
    738738            if has_err_y and not (len(self.y) == len(self.dy)): 
    739739                msg = "Plottable.View: transformed y" 
    740740                msg += " and dy are not of the same length" 
    741                 raise ValueError, msg 
     741                raise ValueError(msg) 
    742742            # Check that negative values are not plot on x and y axis for 
    743743            # log10 transformation 
     
    11051105        Plottable.__init__(self) 
    11061106        msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 
    1107         raise DeprecationWarning, msg 
     1107        raise DeprecationWarning(msg) 
    11081108 
    11091109class Fit1D(Plottable): 
  • src/sas/sasgui/plottools/transform.py

    r7432acb rb9d74f3  
    2424    """ 
    2525    if not x > 0: 
    26         raise ValueError, "Transformation only accepts positive values." 
     26        raise ValueError("Transformation only accepts positive values.") 
    2727    else: 
    2828        return x 
     
    5050    """ 
    5151    if not x >= 0: 
    52         raise ValueError, "square root of a negative value " 
     52        raise ValueError("square root of a negative value ") 
    5353    else: 
    5454        return math.sqrt(x) 
     
    7676    """ 
    7777    if not x >= 0: 
    78         raise ValueError, "double square root of a negative value " 
     78        raise ValueError("double square root of a negative value ") 
    7979    else: 
    8080        return math.sqrt(math.sqrt(x)) 
     
    9090    """ 
    9191    if not x > 0: 
    92         raise ValueError, "Log(x)of a negative value " 
     92        raise ValueError("Log(x)of a negative value ") 
    9393    else: 
    9494        return math.log(x) 
     
    100100        return 1 / x 
    101101    else: 
    102         raise ValueError, "cannot divide by zero" 
     102        raise ValueError("cannot divide by zero") 
    103103 
    104104 
     
    109109        return 1 / math.sqrt(y) 
    110110    else: 
    111         raise ValueError, "transform.toOneOverSqrtX: cannot be computed" 
     111        raise ValueError("transform.toOneOverSqrtX: cannot be computed") 
    112112 
    113113 
     
    118118        return math.log(y * (x ** 2)) 
    119119    else: 
    120         raise ValueError, "transform.toLogYX2: cannot be computed" 
     120        raise ValueError("transform.toLogYX2: cannot be computed") 
    121121 
    122122 
     
    127127        return math.log(math.pow(x, 4) * y) 
    128128    else: 
    129         raise ValueError, "transform.toLogYX4: input error" 
     129        raise ValueError("transform.toLogYX4: input error") 
    130130 
    131131 
     
    149149    """ 
    150150    if not (x * y) > 0: 
    151         raise ValueError, "Log(X*Y)of a negative value " 
     151        raise ValueError("Log(X*Y)of a negative value ") 
    152152    else: 
    153153        return math.log(x * y) 
     
    211211    else: 
    212212        msg = "transform.errFromX2: can't compute error of negative x" 
    213         raise ValueError, msg 
     213        raise ValueError(msg) 
    214214 
    215215 
     
    245245    else: 
    246246        msg = "transform.errFromX4: can't compute error of negative x" 
    247         raise ValueError, msg 
     247        raise ValueError(msg) 
    248248 
    249249 
     
    264264        msg = "Transformation does not accept" 
    265265        msg += " point that are consistent with zero." 
    266         raise ValueError, msg 
     266        raise ValueError(msg) 
    267267    if x != 0: 
    268268        dx = dx / (x * math.log(10)) 
    269269    else: 
    270         raise ValueError, "errToLogX: divide by zero" 
     270        raise ValueError("errToLogX: divide by zero") 
    271271    return dx 
    272272 
     
    287287        dx = dx / x 
    288288    else: 
    289         raise ValueError, "errToLogX: divide by zero" 
     289        raise ValueError("errToLogX: divide by zero") 
    290290    return dx 
    291291 
     
    312312        msg = "Transformation does not accept point " 
    313313        msg += " that are consistent with zero." 
    314         raise ValueError, msg 
     314        raise ValueError(msg) 
    315315    if x != 0 and y != 0: 
    316316        if dx is None: 
     
    320320        err = (dx / x) ** 2 + (dy / y) ** 2 
    321321    else: 
    322         raise ValueError, "cannot compute this error" 
     322        raise ValueError("cannot compute this error") 
    323323 
    324324    return math.sqrt(math.fabs(err)) 
     
    335335        msg = "Transformation does not accept point" 
    336336        msg += " that are consistent with zero." 
    337         raise ValueError, msg 
     337        raise ValueError(msg) 
    338338    if x > 0 and y > 0: 
    339339        if dx is None: 
     
    343343        err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 
    344344    else: 
    345         raise ValueError, "cannot compute this error" 
     345        raise ValueError("cannot compute this error") 
    346346    return math.sqrt(math.fabs(err)) 
    347347 
     
    357357        err = dx / x ** 2 
    358358    else: 
    359         raise ValueError, "Cannot compute this error" 
     359        raise ValueError("Cannot compute this error") 
    360360    return math.fabs(err) 
    361361 
     
    371371        err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 
    372372    else: 
    373         raise ValueError, "Cannot compute this error" 
     373        raise ValueError("Cannot compute this error") 
    374374    return math.fabs(err) 
    375375 
     
    387387        msg = "Transformation does not accept point " 
    388388        msg += " that are consistent with zero." 
    389         raise ValueError, msg 
     389        raise ValueError(msg) 
    390390    if dx is None: 
    391391        dx = 0 
  • test/sasdataloader/plugins/test_reader.py

    raaf5e49 raaf5e49  
    4040                    input_f =  open(path,'r') 
    4141                except : 
    42                     raise  RuntimeError, "ascii_reader: cannot open %s" % path 
     42                    raise  RuntimeError("ascii_reader: cannot open %s" % path) 
    4343                buff = input_f.read() 
    4444                lines = buff.split('\n') 
     
    5555                return output 
    5656        else: 
    57             raise RuntimeError, "%s is not a file" % path 
     57            raise RuntimeError("%s is not a file" % path) 
    5858        return None 
    5959     
  • test/sasdataloader/test/utest_abs_reader.py

    raaf5e49 raaf5e49  
    276276                 
    277277        if _found1==False or _found2==False: 
    278             raise RuntimeError, "Could not find all data %s %s" % (_found1, _found2)  
     278            raise RuntimeError("Could not find all data %s %s" % (_found1, _found2))  
    279279             
    280280        # Detector 
     
    322322                     
    323323        if _found_term1==False or _found_term2==False: 
    324             raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2)  
     324            raise RuntimeError("Could not find all process terms %s %s" % (_found_term1, _found_term2))  
    325325             
    326326         
  • test/sasrealspace/test/utest_oriented.py

    raaf5e49 raaf5e49  
    243243        except: 
    244244            print("Error", ana_val, sim_val, sim_val/ana_val) 
    245             raise sys.exc_type, sys.exc_value 
     245            raise sys.exc_type(sys.exc_value) 
    246246 
    247247class TestCoreShell(unittest.TestCase): 
     
    397397        except: 
    398398            print("Error", ana_val, sim_val, sim_val/ana_val) 
    399             raise sys.exc_type, sys.exc_value 
     399            raise sys.exc_type(sys.exc_value) 
    400400 
    401401    def testRunXY_float(self): 
     
    408408            self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
    409409        except: 
     410            raise sys.exc_type(sys.exc_value) 
    410411            print("Error", ana_val, sim_val, sim_val/ana_val) 
    411             raise sys.exc_type, sys.exc_value 
     412            raise sys.exc_type(sys.exc_value) 
    412413 
    413414    def testRun_float(self): 
     
    421422        except: 
    422423            print("Error", ana_val, sim_val, sim_val/ana_val) 
    423             raise sys.exc_type, sys.exc_value 
     424            raise sys.exc_type(sys.exc_value) 
    424425 
    425426    def testRun_list(self): 
     
    433434        except: 
    434435            print("Error", ana_val, sim_val, sim_val/ana_val) 
    435             raise sys.exc_type, sys.exc_value 
     436            raise sys.exc_type(sys.exc_value) 
    436437 
    437438class TestParamChange(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.