Ignore:
Timestamp:
Sep 22, 2017 2:01:32 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
34d7b35
Parents:
9706d88
Message:

convert sascalc to python 2/3 syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/calculator/sas_gen.py

    rf2ea95a r574adc7  
    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 
     
    100100        """ 
    101101        if self.data_vol is None: 
    102             raise 
     102            raise TypeError("data_vol is missing") 
    103103        self.data_vol = volume 
    104104 
     
    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): 
     
    313313        :Params length: data length 
    314314        """ 
    315         msg = "Error: Inconsistent data length." 
    316         if len(self.pos_x) != length: 
    317             raise ValueError, msg 
    318         if len(self.pos_y) != length: 
    319             raise ValueError, msg 
    320         if len(self.pos_z) != length: 
    321             raise ValueError, msg 
    322         if len(self.mx) != length: 
    323             raise ValueError, msg 
    324         if len(self.my) != length: 
    325             raise ValueError, msg 
    326         if len(self.mz) != length: 
    327             raise ValueError, msg 
     315        parts = (self.pos_x, self.pos_y, self.pos_z, self.mx, self.my, self.mz) 
     316        if any(len(v) != length for v in parts): 
     317            raise ValueError("Error: Inconsistent data length.") 
    328318 
    329319    def remove_null_points(self, remove=False, recenter=False): 
     
    415405                        msg = "Error: \n" 
    416406                        msg += "We accept only m as meshunit" 
    417                         raise ValueError, msg 
     407                        raise ValueError(msg) 
    418408                if s_line[0].lower().count("xbase") > 0: 
    419409                    xbase = s_line[1].lstrip() 
     
    485475            msg = "%s is not supported: \n" % path 
    486476            msg += "We accept only Text format OMF file." 
    487             raise RuntimeError, msg 
     477            raise RuntimeError(msg) 
    488478 
    489479class PDBReader(object): 
     
    605595            return output 
    606596        except: 
    607             raise RuntimeError, "%s is not a sld file" % path 
     597            raise RuntimeError("%s is not a sld file" % path) 
    608598 
    609599    def write(self, path, data): 
     
    697687            return output 
    698688        except: 
    699             raise RuntimeError, "%s is not a sld file" % path 
     689            raise RuntimeError("%s is not a sld file" % path) 
    700690 
    701691    def write(self, path, data): 
     
    706696        """ 
    707697        if path is None: 
    708             raise ValueError, "Missing the file path." 
     698            raise ValueError("Missing the file path.") 
    709699        if data is None: 
    710             raise ValueError, "Missing the data to save." 
     700            raise ValueError("Missing the data to save.") 
    711701        x_val = data.pos_x 
    712702        y_val = data.pos_y 
Note: See TracChangeset for help on using the changeset viewer.