- Timestamp:
- Apr 20, 2017 6:29:34 AM (8 years ago)
- Children:
- 0cc77d8
- Parents:
- b636dfc5
- git-author:
- Andrew Nelson <andyfaff@…> (04/20/17 06:25:57)
- git-committer:
- Andrew Nelson <andyfaff@…> (04/20/17 06:29:34)
- Location:
- src/sas
- Files:
-
- 62 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/BaseComponent.py
r9a5097c rb9d74f3 143 143 qdist[1].__class__.__name__ != 'ndarray': 144 144 msg = "evalDistribution expects a list of 2 ndarrays" 145 raise RuntimeError , msg145 raise RuntimeError(msg) 146 146 147 147 # Extract qx and qy for code clarity … … 167 167 mesg = "evalDistribution is expecting an ndarray of scalar q-values" 168 168 mesg += " or a list [qx,qy] where qx,qy are 2D ndarrays." 169 raise RuntimeError , mesg169 raise RuntimeError(mesg) 170 170 171 171 … … 228 228 return 229 229 230 raise ValueError , "Model does not contain parameter %s" % name230 raise ValueError("Model does not contain parameter %s" % name) 231 231 232 232 def getParam(self, name): … … 250 250 return self.params[item] 251 251 252 raise ValueError , "Model does not contain parameter %s" % name252 raise ValueError("Model does not contain parameter %s" % name) 253 253 254 254 def getParamList(self): … … 294 294 add 295 295 """ 296 raise ValueError , "Model operation are no longer supported"296 raise ValueError("Model operation are no longer supported") 297 297 def __sub__(self, other): 298 298 """ 299 299 sub 300 300 """ 301 raise ValueError , "Model operation are no longer supported"301 raise ValueError("Model operation are no longer supported") 302 302 def __mul__(self, other): 303 303 """ 304 304 mul 305 305 """ 306 raise ValueError , "Model operation are no longer supported"306 raise ValueError("Model operation are no longer supported") 307 307 def __div__(self, other): 308 308 """ 309 309 div 310 310 """ 311 raise ValueError , "Model operation are no longer supported"311 raise ValueError("Model operation are no longer supported") 312 312 313 313 -
src/sas/sascalc/calculator/instrument.py
r9a5097c rb9d74f3 324 324 plt.show() 325 325 except: 326 raise RuntimeError , "Can't import matplotlib required to plot..."326 raise RuntimeError("Can't import matplotlib required to plot...") 327 327 328 328 -
src/sas/sascalc/calculator/resolution_calculator.py
r7432acb rb9d74f3 208 208 if wavelength == 0: 209 209 msg = "Can't compute the resolution: the wavelength is zero..." 210 raise RuntimeError , msg210 raise RuntimeError(msg) 211 211 return self.intensity 212 212 … … 503 503 # otherwise 504 504 else: 505 raise ValueError , " Improper input..."505 raise ValueError(" Improper input...") 506 506 # get them squared 507 507 sigma = x_comp * x_comp … … 766 766 """ 767 767 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.") 769 769 self.aperture.set_source_size(size) 770 770 … … 783 783 """ 784 784 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.") 786 786 self.aperture.set_sample_size(size) 787 787 … … 806 806 """ 807 807 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.") 809 809 self.aperture.set_sample_distance(distance) 810 810 … … 816 816 """ 817 817 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.") 819 819 self.sample.set_distance(distance) 820 820 … … 826 826 """ 827 827 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.") 829 829 self.detector.set_distance(distance) 830 830 … … 998 998 pix_y_size = detector_pix_size[1] 999 999 else: 1000 raise ValueError , " Input value format error..."1000 raise ValueError(" Input value format error...") 1001 1001 # Sample to detector distance = sample slit to detector 1002 1002 # minus sample offset -
src/sas/sascalc/calculator/sas_gen.py
r7432acb rb9d74f3 32 32 factor = MFACTOR_MT 33 33 else: 34 raise ValueError , "Invalid valueunit"34 raise ValueError("Invalid valueunit") 35 35 sld_m = factor * mag 36 36 return sld_m … … 172 172 if len(x[1]) > 0: 173 173 msg = "Not a 1D." 174 raise ValueError , msg174 raise ValueError(msg) 175 175 i_out = np.zeros_like(x[0]) 176 176 # 1D I is found at y =0 in the 2D pattern … … 179 179 else: 180 180 msg = "Q must be given as list of qx's and qy's" 181 raise ValueError , msg181 raise ValueError(msg) 182 182 183 183 def runXY(self, x=0.0): … … 194 194 else: 195 195 msg = "Q must be given as list of qx's and qy's" 196 raise ValueError , msg196 raise ValueError(msg) 197 197 198 198 def evalDistribution(self, qdist): … … 212 212 mesg = "evalDistribution is expecting an ndarray of " 213 213 mesg += "a list [qx,qy] where qx,qy are arrays." 214 raise RuntimeError , mesg214 raise RuntimeError(mesg) 215 215 216 216 class OMF2SLD(object): … … 313 313 msg = "Error: Inconsistent data length." 314 314 if len(self.pos_x) != length: 315 raise ValueError , msg315 raise ValueError(msg) 316 316 if len(self.pos_y) != length: 317 raise ValueError , msg317 raise ValueError(msg) 318 318 if len(self.pos_z) != length: 319 raise ValueError , msg319 raise ValueError(msg) 320 320 if len(self.mx) != length: 321 raise ValueError , msg321 raise ValueError(msg) 322 322 if len(self.my) != length: 323 raise ValueError , msg323 raise ValueError(msg) 324 324 if len(self.mz) != length: 325 raise ValueError , msg325 raise ValueError(msg) 326 326 327 327 def remove_null_points(self, remove=False, recenter=False): … … 413 413 msg = "Error: \n" 414 414 msg += "We accept only m as meshunit" 415 raise ValueError , msg415 raise ValueError(msg) 416 416 if s_line[0].lower().count("xbase") > 0: 417 417 xbase = s_line[1].lstrip() … … 483 483 msg = "%s is not supported: \n" % path 484 484 msg += "We accept only Text format OMF file." 485 raise RuntimeError , msg485 raise RuntimeError(msg) 486 486 487 487 class PDBReader(object): … … 603 603 return output 604 604 except: 605 raise RuntimeError , "%s is not a sld file" % path605 raise RuntimeError("%s is not a sld file" % path) 606 606 607 607 def write(self, path, data): … … 695 695 return output 696 696 except: 697 raise RuntimeError , "%s is not a sld file" % path697 raise RuntimeError("%s is not a sld file" % path) 698 698 699 699 def write(self, path, data): … … 704 704 """ 705 705 if path is None: 706 raise ValueError , "Missing the file path."706 raise ValueError("Missing the file path.") 707 707 if data is None: 708 raise ValueError , "Missing the data to save."708 raise ValueError("Missing the data to save.") 709 709 x_val = data.pos_x 710 710 y_val = data.pos_y -
src/sas/sascalc/corfunc/corfunc_calculator.py
rff11b21 rb9d74f3 80 80 # Only process data of the class Data1D 81 81 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") 83 83 84 84 # Prepare the data … … 151 151 err = ("Incorrect transform type supplied, must be 'fourier'", 152 152 " or 'hilbert'") 153 raise ValueError , err153 raise ValueError(err) 154 154 155 155 self._transform_thread.queue() -
src/sas/sascalc/data_util/nxsunit.py
rb699768 rb9d74f3 189 189 190 190 def _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)) 192 192 #print expect,"==",get 193 193 -
src/sas/sascalc/data_util/odict.py
rb699768 rb9d74f3 612 612 """ 613 613 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' % 615 615 (len(args) + 1)) 616 616 if key in self: -
src/sas/sascalc/data_util/registry.py
rb699768 rb9d74f3 105 105 # Raise an error if there are no matching extensions 106 106 if len(loaders) == 0: 107 raise ValueError , "Unknown file type for "+path107 raise ValueError("Unknown file type for "+path) 108 108 # All done 109 109 return loaders … … 159 159 try: reg.load('hello.cx2') 160 160 except CxError: pass # correct failure 161 else: raise AssertError ,"Incorrect error on load failure"161 else: raise AssertError("Incorrect error on load failure") 162 162 # Make sure the case of no loaders fails correctly 163 163 try: reg.load('hello.missing') 164 164 except ValueError,msg: 165 165 assert str(msg)=="Unknown file type for hello.missing",'Message: <%s>'%(msg) 166 else: raise AssertError ,"No error raised for missing extension"166 else: raise AssertError("No error raised for missing extension") 167 167 assert reg.formats() == ['new_cx'] 168 168 assert reg.extensions() == ['.cx','.cx.gz','.cx1','.cx1.gz','.cx2','.gz'] -
src/sas/sascalc/dataloader/data_info.py
r7432acb rb9d74f3 715 715 self.y_unit = '1/cm' 716 716 except: # the data is not recognized/supported, and the user is notified 717 raise (TypeError, 'data not recognized, check documentation for supported 1D data formats')717 raise TypeError 718 718 719 719 def __str__(self): … … 795 795 len(self.y) != len(other.y): 796 796 msg = "Unable to perform operation: data length are not equal" 797 raise ValueError , msg797 raise ValueError(msg) 798 798 # Here we could also extrapolate between data points 799 799 TOLERANCE = 0.01 … … 801 801 if math.fabs((self.x[i] - other.x[i])/self.x[i]) > TOLERANCE: 802 802 msg = "Incompatible data sets: x-values do not match" 803 raise ValueError , msg803 raise ValueError(msg) 804 804 805 805 # Check that the other data set has errors, otherwise … … 875 875 if not isinstance(other, Data1D): 876 876 msg = "Unable to perform operation: different types of data set" 877 raise ValueError , msg877 raise ValueError(msg) 878 878 return True 879 879 … … 947 947 948 948 if len(self.detector) > 0: 949 raise RuntimeError , "Data2D: Detector bank already filled at init"949 raise RuntimeError("Data2D: Detector bank already filled at init") 950 950 951 951 def __str__(self): … … 1019 1019 len(self.qy_data) != len(other.qy_data): 1020 1020 msg = "Unable to perform operation: data length are not equal" 1021 raise ValueError , msg1021 raise ValueError(msg) 1022 1022 for ind in range(len(self.data)): 1023 1023 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) > TOLERANCE: 1024 1024 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1025 raise ValueError , msg1025 raise ValueError(msg) 1026 1026 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) > TOLERANCE: 1027 1027 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1028 raise ValueError , msg1028 raise ValueError(msg) 1029 1029 1030 1030 # Check that the scales match … … 1107 1107 if not isinstance(other, Data2D): 1108 1108 msg = "Unable to perform operation: different types of data set" 1109 raise ValueError , msg1109 raise ValueError(msg) 1110 1110 return True 1111 1111 -
src/sas/sascalc/dataloader/loader.py
r463e7ffc rb9d74f3 295 295 # Raise an error if there are no matching extensions 296 296 if len(writers) == 0: 297 raise ValueError , "Unknown file type for " + path297 raise ValueError("Unknown file type for " + path) 298 298 # All done 299 299 return writers -
src/sas/sascalc/dataloader/manipulations.py
r7432acb rb9d74f3 81 81 """ 82 82 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...") 84 84 new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 85 85 new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1)) … … 146 146 msg = "_Slab._avg: invalid number of " 147 147 msg += " detectors: %g" % len(data2D.detector) 148 raise RuntimeError , msg148 raise RuntimeError(msg) 149 149 150 150 # Get data … … 168 168 nbins = int(math.ceil((self.y_max - y_min) / self.bin_width)) 169 169 else: 170 raise RuntimeError , "_Slab._avg: unrecognized axis %s" % str(maj)170 raise RuntimeError("_Slab._avg: unrecognized axis %s" % str(maj)) 171 171 172 172 x = numpy.zeros(nbins) … … 229 229 if not idx.any(): 230 230 msg = "Average Error: No points inside ROI to average..." 231 raise ValueError , msg231 raise ValueError(msg) 232 232 return Data1D(x=x[idx], y=y[idx], dy=err_y[idx]) 233 233 … … 302 302 msg = "Circular averaging: invalid number " 303 303 msg += "of detectors: %g" % len(data2D.detector) 304 raise RuntimeError , msg304 raise RuntimeError(msg) 305 305 # Get data 306 306 data = data2D.data[numpy.isfinite(data2D.data)] … … 464 464 if len(data2D.q_data) is None: 465 465 msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 466 raise RuntimeError , msg466 raise RuntimeError(msg) 467 467 468 468 # Build array of Q intervals … … 488 488 ## No need to calculate the frac when all data are within range 489 489 if self.r_min >= self.r_max: 490 raise ValueError , "Limit Error: min > max"490 raise ValueError("Limit Error: min > max") 491 491 492 492 if self.r_min <= q_value and q_value <= self.r_max: … … 539 539 if not idx.any(): 540 540 msg = "Average Error: No points inside ROI to average..." 541 raise ValueError , msg541 raise ValueError(msg) 542 542 543 543 return Data1D(x=x[idx], y=y[idx], dy=err_y[idx], dx=d_x) … … 580 580 """ 581 581 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") 583 583 584 584 Pi = math.pi … … 640 640 if not idx.any(): 641 641 msg = "Average Error: No points inside ROI to average..." 642 raise ValueError , msg642 raise ValueError(msg) 643 643 #elif len(phi_bins[idx])!= self.nbins_phi: 644 644 # print "resulted",self.nbins_phi- len(phi_bins[idx]) … … 765 765 """ 766 766 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") 768 768 Pi = math.pi 769 769 … … 931 931 if not idx.any(): 932 932 msg = "Average Error: No points inside sector of ROI to average..." 933 raise ValueError , msg933 raise ValueError(msg) 934 934 #elif len(y[idx])!= self.nbins: 935 935 # print "resulted",self.nbins- len(y[idx]), … … 1007 1007 """ 1008 1008 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") 1010 1010 1011 1011 # Get data … … 1055 1055 """ 1056 1056 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") 1058 1058 # Get qx_ and qy_data 1059 1059 qx_data = data2D.qx_data … … 1106 1106 """ 1107 1107 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") 1109 1109 Pi = math.pi 1110 1110 # Get data -
src/sas/sascalc/dataloader/readers/abs_reader.py
r959eb01 rb9d74f3 50 50 input_f = open(path,'r') 51 51 except: 52 raise RuntimeError , "abs_reader: cannot open %s" % path52 raise RuntimeError("abs_reader: cannot open %s" % path) 53 53 buff = input_f.read() 54 54 lines = buff.split('\n') … … 99 99 #goes to ASC reader 100 100 msg = "abs_reader: cannot open %s" % path 101 raise RuntimeError , msg101 raise RuntimeError(msg) 102 102 103 103 # Distance in meters … … 114 114 #goes to ASC reader 115 115 msg = "abs_reader: cannot open %s" % path 116 raise RuntimeError , msg116 raise RuntimeError(msg) 117 117 # Transmission 118 118 try: … … 223 223 if not len(y) == len(dy): 224 224 msg = "abs_reader: y and dy have different length" 225 raise ValueError , msg225 raise ValueError(msg) 226 226 # If the data length is zero, consider this as 227 227 # though we were not able to read the file. 228 228 if len(x) == 0: 229 raise ValueError , "ascii_reader: could not load file"229 raise ValueError("ascii_reader: could not load file") 230 230 231 231 output.x = x[x != 0] … … 246 246 return output 247 247 else: 248 raise RuntimeError , "%s is not a file" % path248 raise RuntimeError("%s is not a file" % path) 249 249 return None -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r235f514 rb9d74f3 64 64 input_f = open(path,'rb') 65 65 except: 66 raise RuntimeError , "ascii_reader: cannot open %s" % path66 raise RuntimeError("ascii_reader: cannot open %s" % path) 67 67 buff = input_f.read() 68 68 lines = buff.splitlines() … … 173 173 if not is_data: 174 174 msg = "ascii_reader: x has no data" 175 raise RuntimeError , msg175 raise RuntimeError(msg) 176 176 # Sanity check 177 177 if has_error_dy == True and not len(ty) == len(tdy): 178 178 msg = "ascii_reader: y and dy have different length" 179 raise RuntimeError , msg179 raise RuntimeError(msg) 180 180 if has_error_dx == True and not len(tx) == len(tdx): 181 181 msg = "ascii_reader: y and dy have different length" 182 raise RuntimeError , msg182 raise RuntimeError(msg) 183 183 # If the data length is zero, consider this as 184 184 # though we were not able to read the file. 185 185 if len(tx) == 0: 186 raise RuntimeError , "ascii_reader: could not load file"186 raise RuntimeError("ascii_reader: could not load file") 187 187 188 188 #Let's re-order the data to make cal. … … 222 222 output.meta_data['loader'] = self.type_name 223 223 if len(output.x) < 1: 224 raise RuntimeError , "%s is empty" % path224 raise RuntimeError("%s is empty" % path) 225 225 return output 226 226 227 227 else: 228 raise RuntimeError , "%s is not a file" % path228 raise RuntimeError("%s is not a file" % path) 229 229 return None 230 230 -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r7432acb rb9d74f3 1479 1479 logger.info(err_mess) 1480 1480 else: 1481 raise ValueError , err_mess1481 raise ValueError(err_mess) 1482 1482 else: 1483 1483 err_mess = "CanSAS reader: unrecognized %s unit [%s];"\ … … 1488 1488 logger.info(err_mess) 1489 1489 else: 1490 raise ValueError , err_mess1490 raise ValueError(err_mess) 1491 1491 else: 1492 1492 exec "storage.%s = value" % variable -
src/sas/sascalc/dataloader/readers/danse_reader.py
r235f514 rb9d74f3 56 56 datafile = open(filename, 'r') 57 57 except: 58 raise RuntimeError ,"danse_reader cannot open %s" % (filename)58 raise RuntimeError("danse_reader cannot open %s" % (filename)) 59 59 60 60 # defaults … … 271 271 if not fversion >= 1.0: 272 272 msg = "Danse_reader can't read this file %s" % filename 273 raise ValueError , msg273 raise ValueError(msg) 274 274 else: 275 275 logger.info("Danse_reader Reading %s \n" % filename) -
src/sas/sascalc/dataloader/readers/hfir1d_reader.py
r959eb01 rb9d74f3 49 49 input_f = open(path,'r') 50 50 except: 51 raise RuntimeError , "hfir1d_reader: cannot open %s" % path51 raise RuntimeError("hfir1d_reader: cannot open %s" % path) 52 52 buff = input_f.read() 53 53 lines = buff.split('\n') … … 99 99 if not len(y) == len(dy): 100 100 msg = "hfir1d_reader: y and dy have different length" 101 raise RuntimeError , msg101 raise RuntimeError(msg) 102 102 if not len(x) == len(dx): 103 103 msg = "hfir1d_reader: x and dx have different length" 104 raise RuntimeError , msg104 raise RuntimeError(msg) 105 105 106 106 # If the data length is zero, consider this as 107 107 # though we were not able to read the file. 108 108 if len(x) == 0: 109 raise RuntimeError , "hfir1d_reader: could not load file"109 raise RuntimeError("hfir1d_reader: could not load file") 110 110 111 111 output.x = x … … 126 126 return output 127 127 else: 128 raise RuntimeError , "%s is not a file" % path128 raise RuntimeError("%s is not a file" % path) 129 129 return None -
src/sas/sascalc/dataloader/readers/nexus_reader.py
r959eb01 rb9d74f3 35 35 msg = "Error reading Nexus file: Nexus package is missing.\n" 36 36 msg += " Get it from http://http://www.nexusformat.org/" 37 raise RuntimeError , msg37 raise RuntimeError(msg) 38 38 39 39 # Instantiate data object -
src/sas/sascalc/dataloader/readers/red2d_reader.py
r959eb01 rb9d74f3 70 70 """ Read file """ 71 71 if not os.path.isfile(filename): 72 raise ValueError, \ 73 "Specified file %s is not a regular file" % filename 72 raise ValueError("Specified file %s is not a regular file" % filename) 74 73 75 74 # Read file … … 232 231 except: 233 232 msg = "red2d_reader: Can't read this file: Not a proper file format" 234 raise ValueError , msg233 raise ValueError(msg) 235 234 ## Get the all data: Let's HARDcoding; Todo find better way 236 235 # Defaults -
src/sas/sascalc/dataloader/readers/sesans_reader.py
r9a5097c rb9d74f3 57 57 input_f = open(path,'rb') 58 58 except: 59 raise RuntimeError , "sesans_reader: cannot open %s" % path59 raise RuntimeError("sesans_reader: cannot open %s" % path) 60 60 buff = input_f.read() 61 61 lines = buff.splitlines() … … 158 158 159 159 if len(output.x) < 1: 160 raise RuntimeError , "%s is empty" % path160 raise RuntimeError("%s is empty" % path) 161 161 return output 162 162 163 163 else: 164 raise RuntimeError , "%s is not a file" % path164 raise RuntimeError("%s is not a file" % path) 165 165 return None 166 166 -
src/sas/sascalc/dataloader/readers/tiff_reader.py
r959eb01 rb9d74f3 44 44 except: 45 45 msg = "tiff_reader: could not load file. Missing Image module." 46 raise RuntimeError , msg46 raise RuntimeError(msg) 47 47 48 48 # Instantiate data object … … 54 54 im = Image.open(filename) 55 55 except: 56 raise RuntimeError , "cannot open %s"%(filename)56 raise RuntimeError("cannot open %s"%(filename)) 57 57 data = im.getdata() 58 58 -
src/sas/sascalc/file_converter/cansas_writer.py
r7432acb rb9d74f3 32 32 valid_class = all([issubclass(data.__class__, Data1D) for data in frame_data]) 33 33 if not valid_class: 34 raise RuntimeError ,("The cansas writer expects an array of "34 raise RuntimeError("The cansas writer expects an array of " 35 35 "Data1D instances") 36 36 -
src/sas/sascalc/fit/AbstractFitEngine.py
r7432acb rb9d74f3 250 250 msg = "FitData1D: invalid error array " 251 251 msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 252 raise RuntimeError , msg252 raise RuntimeError(msg) 253 253 return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 254 254 -
src/sas/sascalc/fit/Loader.py
rac07a3a rb9d74f3 57 57 # Sanity check 58 58 if not len(self.x) == len(self.dx): 59 raise ValueError , "x and dx have different length"59 raise ValueError("x and dx have different length") 60 60 if not len(self.y) == len(self.dy): 61 raise ValueError , "y and dy have different length"61 raise ValueError("y and dy have different length") 62 62 63 63 -
src/sas/sascalc/fit/MultiplicationModel.py
r7432acb rb9d74f3 245 245 return 246 246 247 raise ValueError , "Model does not contain parameter %s" % name247 raise ValueError("Model does not contain parameter %s" % name) 248 248 249 249 -
src/sas/sascalc/fit/expression.py
r9a5097c rb9d74f3 237 237 if independent == emptyset: 238 238 cycleset = ", ".join(str(s) for s in left) 239 raise ValueError ,"Cyclic dependencies amongst %s"%cycleset239 raise ValueError("Cyclic dependencies amongst %s"%cycleset) 240 240 241 241 # The possibly resolvable items are those that depend on the independents … … 265 265 n.sort() 266 266 items = list(items); items.sort() 267 raise Exception ,"%s expect %s to contain %s for %s"%(msg,n,items,pairs)267 raise Exception("%s expect %s to contain %s for %s"%(msg,n,items,pairs)) 268 268 for lo,hi in pairs: 269 269 if lo in n and hi in n and n.index(lo) >= n.index(hi): 270 raise Exception ,"%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)270 raise Exception("%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)) 271 271 272 272 def test_deps(): … … 288 288 try: n = order_dependencies(pairs) 289 289 except ValueError: pass 290 else: raise Exception ,"test3 expect ValueError exception for %s"%(pairs,)290 else: raise Exception("test3 expect ValueError exception for %s"%(pairs,)) 291 291 292 292 # large test for gross speed check -
src/sas/sascalc/fit/pluginmodel.py
r5213d22 rb9d74f3 35 35 return self.function(x_val)*self.function(y_val) 36 36 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") 38 38 else: 39 39 return self.function(x) … … 52 52 return self.function(x[0])*self.function(x[1]) 53 53 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") 55 55 else: 56 56 return self.function(x) -
src/sas/sascalc/invariant/invariant.py
r7432acb rb9d74f3 424 424 if not issubclass(data.__class__, LoaderData1D): 425 425 #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") 427 427 #from copy import deepcopy 428 428 new_data = (self._scale * data) - self._background … … 484 484 msg = "Length x and y must be equal" 485 485 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 486 raise ValueError , msg486 raise ValueError(msg) 487 487 else: 488 488 # Take care of smeared data … … 533 533 msg = "Length of data.x and data.y must be equal" 534 534 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 535 raise ValueError , msg535 raise ValueError(msg) 536 536 else: 537 537 #Create error for data without dy error … … 742 742 range = range.lower() 743 743 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'") 745 745 function = function.lower() 746 746 if function not in ['power_law', 'guinier']: 747 747 msg = "Extrapolation function should be 'guinier' or 'power_law'" 748 raise ValueError , msg748 raise ValueError(msg) 749 749 750 750 if range == 'high': 751 751 if function != 'power_law': 752 752 msg = "Extrapolation only allows a power law at high Q" 753 raise ValueError , msg753 raise ValueError(msg) 754 754 self._high_extrapolation_npts = npts 755 755 self._high_extrapolation_power = power … … 852 852 """ 853 853 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") 855 855 856 856 # Make sure Q star is up to date … … 859 859 if self._qstar <= 0: 860 860 msg = "Invalid invariant: Invariant Q* must be greater than zero" 861 raise RuntimeError , msg861 raise RuntimeError(msg) 862 862 863 863 # Compute intermediate constant … … 869 869 if discrim < 0: 870 870 msg = "Could not compute the volume fraction: negative discriminant" 871 raise RuntimeError , msg871 raise RuntimeError(msg) 872 872 elif discrim == 0: 873 873 return 1 / 2 … … 881 881 return volume2 882 882 msg = "Could not compute the volume fraction: inconsistent results" 883 raise RuntimeError , msg883 raise RuntimeError(msg) 884 884 885 885 def get_qstar_with_error(self, extrapolation=None): -
src/sas/sascalc/pr/fit/AbstractFitEngine.py
r7432acb rb9d74f3 250 250 msg = "FitData1D: invalid error array " 251 251 msg += "%d <> %d" % (np.shape(self.dy), np.size(fx)) 252 raise RuntimeError , msg252 raise RuntimeError(msg) 253 253 return (self.y[self.idx] - fx[self.idx]) / self.dy[self.idx], fx[self.idx] 254 254 -
src/sas/sascalc/pr/fit/Loader.py
rac07a3a rb9d74f3 57 57 # Sanity check 58 58 if not len(self.x) == len(self.dx): 59 raise ValueError , "x and dx have different length"59 raise ValueError("x and dx have different length") 60 60 if not len(self.y) == len(self.dy): 61 raise ValueError , "y and dy have different length"61 raise ValueError("y and dy have different length") 62 62 63 63 -
src/sas/sascalc/pr/fit/expression.py
r9a5097c rb9d74f3 237 237 if independent == emptyset: 238 238 cycleset = ", ".join(str(s) for s in left) 239 raise ValueError ,"Cyclic dependencies amongst %s"%cycleset239 raise ValueError("Cyclic dependencies amongst %s"%cycleset) 240 240 241 241 # The possibly resolvable items are those that depend on the independents … … 265 265 n.sort() 266 266 items = list(items); items.sort() 267 raise Exception ,"%s expect %s to contain %s for %s"%(msg,n,items,pairs)267 raise Exception("%s expect %s to contain %s for %s"%(msg,n,items,pairs)) 268 268 for lo,hi in pairs: 269 269 if lo in n and hi in n and n.index(lo) >= n.index(hi): 270 raise Exception ,"%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)270 raise Exception("%s expect %s before %s in %s for %s"%(msg,lo,hi,n,pairs)) 271 271 272 272 def test_deps(): … … 288 288 try: n = order_dependencies(pairs) 289 289 except ValueError: pass 290 else: raise Exception ,"test3 expect ValueError exception for %s"%(pairs,)290 else: raise Exception("test3 expect ValueError exception for %s"%(pairs,)) 291 291 292 292 # large test for gross speed check -
src/sas/sascalc/pr/invertor.py
r45dffa69 rb9d74f3 148 148 msg = "Invertor: one of your q-values is zero. " 149 149 msg += "Delete that entry before proceeding" 150 raise ValueError , msg150 raise ValueError(msg) 151 151 return self.set_x(value) 152 152 elif name == 'y': … … 159 159 msg = "Invertor: d_max must be greater than zero." 160 160 msg += "Correct that entry before proceeding" 161 raise ValueError , msg161 raise ValueError(msg) 162 162 return self.set_dmax(value) 163 163 elif name == 'q_min': … … 181 181 return self.set_has_bck(0) 182 182 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") 184 184 185 185 return Cinvertor.__setattr__(self, name, value) … … 325 325 if self.is_valid() <= 0: 326 326 msg = "Invertor.invert: Data array are of different length" 327 raise RuntimeError , msg327 raise RuntimeError(msg) 328 328 329 329 p = np.ones(nfunc) … … 358 358 if self.is_valid() <= 0: 359 359 msg = "Invertor.invert: Data arrays are of different length" 360 raise RuntimeError , msg360 raise RuntimeError(msg) 361 361 362 362 p = np.ones(nfunc) … … 442 442 if self.is_valid() < 0: 443 443 msg = "Invertor: invalid data; incompatible data lengths." 444 raise RuntimeError , msg444 raise RuntimeError(msg) 445 445 446 446 self.nfunc = nfunc … … 467 467 self._get_matrix(nfunc, nq, a, b) 468 468 except: 469 raise RuntimeError , "Invertor: could not invert I(Q)\n %s" % sys.exc_value469 raise RuntimeError("Invertor: could not invert I(Q)\n %s" % sys.exc_value) 470 470 471 471 # Perform the inversion (least square fit) … … 751 751 except: 752 752 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 753 raise RuntimeError , msg753 raise RuntimeError(msg) 754 754 else: 755 755 msg = "Invertor.from_file: '%s' is not a file" % str(path) 756 raise RuntimeError , msg756 raise RuntimeError(msg) -
src/sas/sasgui/guiframe/data_processor.py
r7432acb rb9d74f3 907 907 msg = "Edit axis doesn't understand this selection.\n" 908 908 msg += "Please select only one column" 909 raise ValueError , msg909 raise ValueError(msg) 910 910 for (_, cell_col) in grid.selected_cells: 911 911 if cell_col != col: … … 913 913 msg += "this operation.\n" 914 914 msg += "Please select elements of the same col.\n" 915 raise ValueError , msg915 raise ValueError(msg) 916 916 917 917 # Finally check the highlighted cell if any cells missing … … 920 920 msg = "No item selected.\n" 921 921 msg += "Please select only one column or one cell" 922 raise ValueError , msg922 raise ValueError(msg) 923 923 return grid.selected_cells 924 924 … … 1324 1324 if sentence.strip() == "": 1325 1325 msg = "Select column values for x axis" 1326 raise ValueError , msg1326 raise ValueError(msg) 1327 1327 except: 1328 1328 msg = "X axis value error." … … 1343 1343 if sentence.strip() == "": 1344 1344 msg = "select value for y axis" 1345 raise ValueError , msg1345 raise ValueError(msg) 1346 1346 except: 1347 1347 msg = "Y axis value error." -
src/sas/sasgui/guiframe/gui_manager.py
r2f22db9 rb9d74f3 2613 2613 wx.PostEvent(self, StatusEvent(status=msg, 2614 2614 info="error")) 2615 raise ValueError , msg2615 raise ValueError(msg) 2616 2616 # text = str(data) 2617 2617 text = data.__str__() -
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
r7432acb rb9d74f3 235 235 msg = "Phi left and phi right are different" 236 236 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 237 raise ValueError , msg237 raise ValueError(msg) 238 238 params["Phi [deg]"] = self.main_line.theta * 180 / math.pi 239 239 params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi) -
src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py
r463e7ffc rb9d74f3 187 187 # Check that the trigger is valid 188 188 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))) 191 191 # Register the trigger callback 192 192 self._actions[trigger][artist] = action … … 203 203 """ 204 204 if action not in self.events: 205 raise ValueError , "Trigger expects " + ", ".join(self.events)205 raise ValueError("Trigger expects " + ", ".join(self.events)) 206 206 # Tag the event with modifiers 207 207 for mod in ('alt', 'control', 'shift', 'meta'): -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py
r7432acb rb9d74f3 152 152 if new_slab is None: 153 153 msg = "post data:cannot average , averager is empty" 154 raise ValueError , msg154 raise ValueError(msg) 155 155 self.averager = new_slab 156 156 if self.direction == "X": … … 168 168 else: 169 169 msg = "post data:no Box Average direction was supplied" 170 raise ValueError , msg170 raise ValueError(msg) 171 171 # # Average data2D given Qx or Qy 172 172 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 199 199 200 200 msg = "1D Panel of group ID %s could not be created" % str(group_id) 201 raise ValueError , msg201 raise ValueError(msg) 202 202 203 203 def create_2d_panel(self, data, group_id): … … 217 217 return new_panel 218 218 msg = "2D Panel of group ID %s could not be created" % str(group_id) 219 raise ValueError , msg219 raise ValueError(msg) 220 220 221 221 def update_panel(self, data, panel): … … 237 237 msg += " to panel %s\n" % str(panel.window_caption) 238 238 msg += "Please edit %s's units, labels" % str(data.name) 239 raise ValueError , msg239 raise ValueError(msg) 240 240 else: 241 241 if panel.group_id not in data.list_group_id: -
src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py
r7432acb rb9d74f3 175 175 msg += "different %f, %f" % (self.left_line.phi, 176 176 self.right_line.phi) 177 raise ValueError , msg177 raise ValueError(msg) 178 178 params["Phi"] = self.main_line.theta 179 179 params["Delta_Phi"] = math.fabs(self.left_line.phi) -
src/sas/sasgui/guiframe/plugin_base.py
r7432acb rb9d74f3 277 277 """ 278 278 msg = "%s plugin: does not support import theory" % str(self.sub_menu) 279 raise ValueError , msg279 raise ValueError(msg) 280 280 281 281 def on_set_state_helper(self, event): -
src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py
r7432acb rb9d74f3 1082 1082 msg = "The numbers must be one or two (separated by ',')..." 1083 1083 self._status_info(msg, 'stop') 1084 raise RuntimeError , msg1084 raise RuntimeError(msg) 1085 1085 1086 1086 return new_string -
src/sas/sasgui/perspectives/calculator/slit_length_calculator_panel.py
r7432acb rb9d74f3 262 262 if x == [] or x is None or y == [] or y is None: 263 263 msg = "The current data is empty please check x and y" 264 raise ValueError , msg264 raise ValueError(msg) 265 265 slit_length_calculator = SlitlengthCalculator() 266 266 slit_length_calculator.set_data(x=x, y=y) -
src/sas/sasgui/perspectives/corfunc/corfunc_state.py
r7432acb rb9d74f3 284 284 root, ext = os.path.splitext(basename) 285 285 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)) 287 287 tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 288 288 root = tree.getroot() … … 300 300 # File not found 301 301 msg = "{} is not a valid file path or doesn't exist".format(path) 302 raise IOError , msg302 raise IOError(msg) 303 303 304 304 if len(output) == 0: … … 324 324 msg = ("The CanSAS writer expects a Data1D instance. {} was " 325 325 "provided").format(datainfo.__class__.__name__) 326 raise RuntimeError , msg326 raise RuntimeError(msg) 327 327 if datainfo.title is None or datainfo.title == '': 328 328 datainfo.title = datainfo.name -
src/sas/sasgui/perspectives/fitting/fit_thread.py
r959eb01 rb9d74f3 54 54 except KeyboardInterrupt: 55 55 msg = "Fitting: terminated by the user." 56 raise KeyboardInterrupt , msg56 raise KeyboardInterrupt(msg) 57 57 58 58 def compute(self): -
src/sas/sasgui/perspectives/fitting/fitpage.py
red2276f rb9d74f3 1847 1847 wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 1848 1848 info="error")) 1849 raise ValueError , msg1849 raise ValueError(msg) 1850 1850 1851 1851 else: … … 1859 1859 wx.PostEvent(self._manager.parent, StatusEvent(status=msg, 1860 1860 info="error")) 1861 raise ValueError , msg1861 raise ValueError(msg) 1862 1862 # Maximum value of data 1863 1863 qmax = math.sqrt(x * x + y * y) … … 2098 2098 self._on_fit_complete() 2099 2099 if out is None or not np.isfinite(chisqr): 2100 raise ValueError , "Fit error occured..."2100 raise ValueError("Fit error occured...") 2101 2101 2102 2102 is_modified = False … … 2173 2173 i += 1 2174 2174 else: 2175 raise ValueError , "onsetValues: Invalid parameters..."2175 raise ValueError("onsetValues: Invalid parameters...") 2176 2176 # Show error title when any errors displayed 2177 2177 if has_error: -
src/sas/sasgui/perspectives/fitting/fitpanel.py
r67b0a99 rb9d74f3 125 125 if uid not in self.opened_pages: 126 126 msg = "Fitpanel cannot find ID: %s in self.opened_pages" % str(uid) 127 raise ValueError , msg127 raise ValueError(msg) 128 128 else: 129 129 return self.opened_pages[uid] … … 389 389 """ 390 390 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") 392 392 else: 393 393 for page in self.opened_pages.values(): -
src/sas/sasgui/perspectives/fitting/fitting.py
r7432acb rb9d74f3 1232 1232 panel = self.plot_panel 1233 1233 if panel is None: 1234 raise ValueError , "Fitting:_onSelect: NonType panel"1234 raise ValueError("Fitting:_onSelect: NonType panel") 1235 1235 Plugin.on_perspective(self, event=event) 1236 1236 self.select_data(panel) -
src/sas/sasgui/perspectives/fitting/model_thread.py
r7432acb rb9d74f3 65 65 if self.data is None: 66 66 msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 67 raise ValueError , msg67 raise ValueError(msg) 68 68 69 69 # Define matrix where data will be plotted -
src/sas/sasgui/perspectives/fitting/models.py
r463e7ffc rb9d74f3 142 142 if type is not None and issubclass(type, py_compile.PyCompileError): 143 143 print "Problem with", repr(value) 144 raise type , value, tb144 raise type(value).with_traceback(tb) 145 145 return 1 146 146 -
src/sas/sasgui/perspectives/fitting/pagestate.py
r959eb01 rb9d74f3 1014 1014 msg = "PageState no longer supports non-CanSAS" 1015 1015 msg += " format for fitting files" 1016 raise RuntimeError , msg1016 raise RuntimeError(msg) 1017 1017 1018 1018 if node.get('version'): … … 1310 1310 else: 1311 1311 self.call_back(format=ext) 1312 raise RuntimeError , "%s is not a file" % path1312 raise RuntimeError("%s is not a file" % path) 1313 1313 1314 1314 # Return output consistent with the loader's api -
src/sas/sasgui/perspectives/invariant/invariant.py
r7432acb rb9d74f3 133 133 name = data.__class__.__name__ 134 134 msg = "Invariant use only Data1D got: [%s] " % str(name) 135 raise ValueError , msg135 raise ValueError(msg) 136 136 self.compute_helper(data=data) 137 137 … … 240 240 msg = "invariant.save_file: the data being saved is" 241 241 msg += " not a sas.sascalc.dataloader.data_info.Data1D object" 242 raise RuntimeError , msg242 raise RuntimeError(msg) 243 243 244 244 def set_state(self, state=None, datainfo=None): … … 258 258 msg = "invariant.set_state: datainfo parameter cannot" 259 259 msg += " be None in standalone mode" 260 raise RuntimeError , msg260 raise RuntimeError(msg) 261 261 # Make sure the user sees the invariant panel after loading 262 262 # self.parent.set_perspective(self.perspective) … … 320 320 else: 321 321 msg = "Scale can not be zero." 322 raise ValueError , msg322 raise ValueError(msg) 323 323 if len(new_plot.x) == 0: 324 324 return -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r7432acb rb9d74f3 318 318 background = self.background_tcl.GetValue().lstrip().rstrip() 319 319 if background == "": 320 raise ValueError , "Need a background"320 raise ValueError("Need a background") 321 321 if check_float(self.background_tcl): 322 322 return float(background) 323 323 else: 324 324 msg = "Receive invalid value for background : %s" % (background) 325 raise ValueError , msg325 raise ValueError(msg) 326 326 327 327 def get_scale(self): … … 331 331 scale = self.scale_tcl.GetValue().lstrip().rstrip() 332 332 if scale == "": 333 raise ValueError , "Need a background"333 raise ValueError("Need a background") 334 334 if check_float(self.scale_tcl): 335 335 if float(scale) <= 0.0: … … 337 337 self.scale_tcl.Refresh() 338 338 msg = "Receive invalid value for scale: %s" % (scale) 339 raise ValueError , msg339 raise ValueError(msg) 340 340 return float(scale) 341 341 else: 342 raise ValueError , "Receive invalid value for scale : %s" % (scale)342 raise ValueError("Receive invalid value for scale : %s" % (scale)) 343 343 344 344 def get_contrast(self): … … 865 865 except: 866 866 logger.error(sys.exc_value) 867 raise ValueError , "No such bookmark exists"867 raise ValueError("No such bookmark exists") 868 868 869 869 # set the parameters -
src/sas/sasgui/perspectives/invariant/invariant_state.py
r7432acb rb9d74f3 365 365 msg = "InvariantSate no longer supports non-CanSAS" 366 366 msg += " format for invariant files" 367 raise RuntimeError , msg367 raise RuntimeError(msg) 368 368 369 369 if node.get('version')\ … … 739 739 output.append(sas_entry) 740 740 else: 741 raise RuntimeError , "%s is not a file" % path741 raise RuntimeError("%s is not a file" % path) 742 742 743 743 # Return output consistent with the loader's api … … 785 785 msg = "The cansas writer expects a Data1D" 786 786 msg += " instance: %s" % str(datainfo.__class__.__name__) 787 raise RuntimeError , msg787 raise RuntimeError(msg) 788 788 # make sure title and data run is filled up. 789 789 if datainfo.title is None or datainfo.title == '': -
src/sas/sasgui/perspectives/pr/inversion_panel.py
r7432acb rb9d74f3 854 854 message += "than the number of points" 855 855 wx.PostEvent(self._manager.parent, StatusEvent(status=message)) 856 raise ValueError , message856 raise ValueError(message) 857 857 self.nfunc_ctl.SetBackgroundColour(wx.WHITE) 858 858 self.nfunc_ctl.Refresh() -
src/sas/sasgui/perspectives/pr/inversion_state.py
r7432acb rb9d74f3 235 235 msg = "InversionState no longer supports non-CanSAS" 236 236 msg += " format for P(r) files" 237 raise RuntimeError , msg237 raise RuntimeError(msg) 238 238 239 239 if node.get('version') and node.get('version') == '1.0': … … 478 478 output.append(sas_entry) 479 479 else: 480 raise RuntimeError , "%s is not a file" % path480 raise RuntimeError("%s is not a file" % path) 481 481 482 482 # Return output consistent with the loader's api … … 522 522 msg = "The cansas writer expects a Data1D " 523 523 msg += "instance: %s" % str(datainfo.__class__.__name__) 524 raise RuntimeError , msg524 raise RuntimeError(msg) 525 525 526 526 # Create basic XML document -
src/sas/sasgui/perspectives/pr/pr.py
r7432acb rb9d74f3 149 149 msg = "Pr.set_state: datainfo parameter cannot " 150 150 msg += "be None in standalone mode" 151 raise RuntimeError , msg151 raise RuntimeError(msg) 152 152 153 153 # Ensuring that plots are coordinated correctly … … 450 450 # Notify the user if we could not read the file 451 451 if dataread is None: 452 raise RuntimeError , "Invalid data"452 raise RuntimeError("Invalid data") 453 453 454 454 x = None … … 470 470 if dataread is None: 471 471 return x, y, err 472 raise RuntimeError , "This tool can only read 1D data"472 raise RuntimeError("This tool can only read 1D data") 473 473 474 474 self._current_file_data.x = x … … 849 849 status = "Problem reading data: %s" % sys.exc_value 850 850 wx.PostEvent(self.parent, StatusEvent(status=status)) 851 raise RuntimeError , status851 raise RuntimeError(status) 852 852 853 853 # If the file contains nothing, just return 854 854 if pr is None: 855 raise RuntimeError , "Loaded data is invalid"855 raise RuntimeError("Loaded data is invalid") 856 856 857 857 self.pr = pr … … 903 903 msg = "pr.save_data: the data being saved is not a" 904 904 msg += " sas.data_info.Data1D object" 905 raise RuntimeError , msg905 raise RuntimeError(msg) 906 906 907 907 def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None, -
src/sas/sasgui/perspectives/simulation/ShapeAdapter.py
r959eb01 rb9d74f3 87 87 self.sim_canvas._model_changed() 88 88 else: 89 raise ValueError , "SimShapeVisitor: Wrong class for visited object"89 raise ValueError("SimShapeVisitor: Wrong class for visited object") 90 90 91 91 … … 115 115 self.sim_canvas._model_changed() 116 116 else: 117 raise ValueError , "SimShapeVisitor: Wrong class for visited object"117 raise ValueError("SimShapeVisitor: Wrong class for visited object") 118 118 119 119 … … 130 130 shape.accept_update(self) 131 131 else: 132 raise ValueError , "ShapeAdapter: Shape [%s] not in list" % shape.name132 raise ValueError("ShapeAdapter: Shape [%s] not in list" % shape.name) 133 133 -
src/sas/sasgui/plottools/LineModel.py
r959eb01 rb9d74f3 82 82 elif x.__class__.__name__ == 'tuple': 83 83 msg = "Tuples are not allowed as input to BaseComponent models" 84 raise ValueError , msg84 raise ValueError(msg) 85 85 else: 86 86 return self._line(x) … … 104 104 elif x.__class__.__name__ == 'tuple': 105 105 msg = "Tuples are not allowed as input to BaseComponent models" 106 raise ValueError , msg106 raise ValueError(msg) 107 107 else: 108 108 return self._line(x) -
src/sas/sasgui/plottools/binder.py
r463e7ffc rb9d74f3 187 187 # Check that the trigger is valid 188 188 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))) 191 191 192 192 # Register the trigger callback … … 203 203 """ 204 204 if action not in self.events: 205 raise ValueError , "Trigger expects " + ", ".join(self.events)205 raise ValueError("Trigger expects " + ", ".join(self.events)) 206 206 207 207 # Tag the event with modifiers -
src/sas/sasgui/plottools/convert_units.py
r959eb01 rb9d74f3 42 42 unit = toks[0] + "^{" + str(powerer) + "}" 43 43 else: 44 raise ValueError , "missing } in unit expression"44 raise ValueError("missing } in unit expression") 45 45 else: # no powerer 46 46 if power != 1: 47 47 unit = "(" + unit + ")" + "^{" + str(power) + "}" 48 48 else: 49 raise ValueError , "empty unit ,enter a powerer different from zero"49 raise ValueError("empty unit ,enter a powerer different from zero") 50 50 return unit 51 51 -
src/sas/sasgui/plottools/fitDialog.py
r7432acb rb9d74f3 671 671 return x 672 672 else: 673 raise ValueError , "cannot compute log of a negative number"673 raise ValueError("cannot compute log of a negative number") 674 674 675 675 def floatInvTransform(self, x): … … 734 734 except: 735 735 msg = "LinearFit.set_fit_region: fit range must be floats" 736 raise ValueError , msg736 raise ValueError(msg) 737 737 self.xminFit.SetValue(format_number(xmin)) 738 738 self.xmaxFit.SetValue(format_number(xmax)) -
src/sas/sasgui/plottools/plottables.py
r45dffa69 rb9d74f3 386 386 387 387 """ 388 raise NotImplemented , "Not a valid transform"388 raise NotImplemented("Not a valid transform") 389 389 390 390 # Related issues … … 686 686 msg = "Plottable.View: Given x and dx are not" 687 687 msg += " of the same length" 688 raise ValueError , msg688 raise ValueError(msg) 689 689 # Check length of y array 690 690 if not len(y) == len(x): 691 691 msg = "Plottable.View: Given y " 692 692 msg += "and x are not of the same length" 693 raise ValueError , msg693 raise ValueError(msg) 694 694 695 695 if dy is not None and not len(dy) == 0 and not len(y) == len(dy): 696 696 msg = "Plottable.View: Given y and dy are not of the same " 697 697 msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 698 raise ValueError , msg698 raise ValueError(msg) 699 699 self.x = [] 700 700 self.y = [] … … 731 731 msg = "Plottable.View: transformed x " 732 732 msg += "and y are not of the same length" 733 raise ValueError , msg733 raise ValueError(msg) 734 734 if has_err_x and not (len(self.x) == len(self.dx)): 735 735 msg = "Plottable.View: transformed x and dx" 736 736 msg += " are not of the same length" 737 raise ValueError , msg737 raise ValueError(msg) 738 738 if has_err_y and not (len(self.y) == len(self.dy)): 739 739 msg = "Plottable.View: transformed y" 740 740 msg += " and dy are not of the same length" 741 raise ValueError , msg741 raise ValueError(msg) 742 742 # Check that negative values are not plot on x and y axis for 743 743 # log10 transformation … … 1105 1105 Plottable.__init__(self) 1106 1106 msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 1107 raise DeprecationWarning , msg1107 raise DeprecationWarning(msg) 1108 1108 1109 1109 class Fit1D(Plottable): -
src/sas/sasgui/plottools/transform.py
r7432acb rb9d74f3 24 24 """ 25 25 if not x > 0: 26 raise ValueError , "Transformation only accepts positive values."26 raise ValueError("Transformation only accepts positive values.") 27 27 else: 28 28 return x … … 50 50 """ 51 51 if not x >= 0: 52 raise ValueError , "square root of a negative value "52 raise ValueError("square root of a negative value ") 53 53 else: 54 54 return math.sqrt(x) … … 76 76 """ 77 77 if not x >= 0: 78 raise ValueError , "double square root of a negative value "78 raise ValueError("double square root of a negative value ") 79 79 else: 80 80 return math.sqrt(math.sqrt(x)) … … 90 90 """ 91 91 if not x > 0: 92 raise ValueError , "Log(x)of a negative value "92 raise ValueError("Log(x)of a negative value ") 93 93 else: 94 94 return math.log(x) … … 100 100 return 1 / x 101 101 else: 102 raise ValueError , "cannot divide by zero"102 raise ValueError("cannot divide by zero") 103 103 104 104 … … 109 109 return 1 / math.sqrt(y) 110 110 else: 111 raise ValueError , "transform.toOneOverSqrtX: cannot be computed"111 raise ValueError("transform.toOneOverSqrtX: cannot be computed") 112 112 113 113 … … 118 118 return math.log(y * (x ** 2)) 119 119 else: 120 raise ValueError , "transform.toLogYX2: cannot be computed"120 raise ValueError("transform.toLogYX2: cannot be computed") 121 121 122 122 … … 127 127 return math.log(math.pow(x, 4) * y) 128 128 else: 129 raise ValueError , "transform.toLogYX4: input error"129 raise ValueError("transform.toLogYX4: input error") 130 130 131 131 … … 149 149 """ 150 150 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 ") 152 152 else: 153 153 return math.log(x * y) … … 211 211 else: 212 212 msg = "transform.errFromX2: can't compute error of negative x" 213 raise ValueError , msg213 raise ValueError(msg) 214 214 215 215 … … 245 245 else: 246 246 msg = "transform.errFromX4: can't compute error of negative x" 247 raise ValueError , msg247 raise ValueError(msg) 248 248 249 249 … … 264 264 msg = "Transformation does not accept" 265 265 msg += " point that are consistent with zero." 266 raise ValueError , msg266 raise ValueError(msg) 267 267 if x != 0: 268 268 dx = dx / (x * math.log(10)) 269 269 else: 270 raise ValueError , "errToLogX: divide by zero"270 raise ValueError("errToLogX: divide by zero") 271 271 return dx 272 272 … … 287 287 dx = dx / x 288 288 else: 289 raise ValueError , "errToLogX: divide by zero"289 raise ValueError("errToLogX: divide by zero") 290 290 return dx 291 291 … … 312 312 msg = "Transformation does not accept point " 313 313 msg += " that are consistent with zero." 314 raise ValueError , msg314 raise ValueError(msg) 315 315 if x != 0 and y != 0: 316 316 if dx is None: … … 320 320 err = (dx / x) ** 2 + (dy / y) ** 2 321 321 else: 322 raise ValueError , "cannot compute this error"322 raise ValueError("cannot compute this error") 323 323 324 324 return math.sqrt(math.fabs(err)) … … 335 335 msg = "Transformation does not accept point" 336 336 msg += " that are consistent with zero." 337 raise ValueError , msg337 raise ValueError(msg) 338 338 if x > 0 and y > 0: 339 339 if dx is None: … … 343 343 err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 344 344 else: 345 raise ValueError , "cannot compute this error"345 raise ValueError("cannot compute this error") 346 346 return math.sqrt(math.fabs(err)) 347 347 … … 357 357 err = dx / x ** 2 358 358 else: 359 raise ValueError , "Cannot compute this error"359 raise ValueError("Cannot compute this error") 360 360 return math.fabs(err) 361 361 … … 371 371 err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 372 372 else: 373 raise ValueError , "Cannot compute this error"373 raise ValueError("Cannot compute this error") 374 374 return math.fabs(err) 375 375 … … 387 387 msg = "Transformation does not accept point " 388 388 msg += " that are consistent with zero." 389 raise ValueError , msg389 raise ValueError(msg) 390 390 if dx is None: 391 391 dx = 0
Note: See TracChangeset
for help on using the changeset viewer.