Changeset 574adc7 in sasview for src/sas/sascalc/calculator
- Timestamp:
- Sep 22, 2017 4:01:32 PM (7 years ago)
- 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
- Location:
- src/sas/sascalc/calculator
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/BaseComponent.py
r9a5097c r574adc7 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 r574adc7 222 222 """ 223 223 # check if the wavelength is in range 224 if min(band) < self.min or\ 225 max(band) > self.max: 226 raise 224 if min(band) < self.min or max(band) > self.max: 225 raise ValueError("band out of range") 227 226 self.band = band 228 227 … … 239 238 """ 240 239 # check if the wavelength is in range 241 if wavelength < min(self.band) or\ 242 wavelength > max(self.band): 243 raise 240 if wavelength < min(self.band) or wavelength > max(self.band): 241 raise ValueError("wavelength out of range") 244 242 self.wavelength = wavelength 245 243 validate(wavelength) … … 324 322 plt.show() 325 323 except: 326 raise RuntimeError , "Can't import matplotlib required to plot..."324 raise RuntimeError("Can't import matplotlib required to plot...") 327 325 328 326 -
src/sas/sascalc/calculator/resolution_calculator.py
r7432acb r574adc7 4 4 instrumental parameters. 5 5 """ 6 from instrument import Sample 7 from instrument import Detector 8 from instrument import TOF as Neutron 9 from instrument import Aperture 10 # import math stuffs 11 from math import pi 12 from math import sqrt 6 import sys 7 from math import pi, sqrt 13 8 import math 9 import logging 10 14 11 import numpy as np 15 import sys 16 import logging 12 13 from .instrument import Sample 14 from .instrument import Detector 15 from .instrument import TOF as Neutron 16 from .instrument import Aperture 17 17 18 18 logger = logging.getLogger(__name__) … … 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 … … 379 379 if qx_min < self.qx_min: 380 380 self.qx_min = qx_min 381 #raise ValueError , msg381 #raise ValueError(msg) 382 382 if qx_max > self.qx_max: 383 383 self.qx_max = qx_max 384 #raise ValueError , msg384 #raise ValueError(msg) 385 385 if qy_min < self.qy_min: 386 386 self.qy_min = qy_min 387 #raise ValueError , msg387 #raise ValueError(msg) 388 388 if qy_max > self.qy_max: 389 389 self.qy_max = qy_max 390 #raise ValueError , msg390 #raise ValueError(msg) 391 391 if not full_cal: 392 392 return None … … 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 … … 706 706 #self.set_wavelength(wavelength) 707 707 else: 708 raise 708 raise TypeError("invalid wavlength---should be list or float") 709 709 710 710 def set_wave_spread(self, wavelength_spread): … … 717 717 self.wave.set_wave_spread_list([wavelength_spread]) 718 718 else: 719 raise 719 raise TypeError("invalid wavelength spread---should be list or float") 720 720 721 721 def set_wavelength(self, wavelength): … … 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
rf2ea95a r574adc7 34 34 factor = MFACTOR_MT 35 35 else: 36 raise ValueError , "Invalid valueunit"36 raise ValueError("Invalid valueunit") 37 37 sld_m = factor * mag 38 38 return sld_m … … 100 100 """ 101 101 if self.data_vol is None: 102 raise 102 raise TypeError("data_vol is missing") 103 103 self.data_vol = volume 104 104 … … 174 174 if len(x[1]) > 0: 175 175 msg = "Not a 1D." 176 raise ValueError , msg176 raise ValueError(msg) 177 177 i_out = np.zeros_like(x[0]) 178 178 # 1D I is found at y =0 in the 2D pattern … … 181 181 else: 182 182 msg = "Q must be given as list of qx's and qy's" 183 raise ValueError , msg183 raise ValueError(msg) 184 184 185 185 def runXY(self, x=0.0): … … 196 196 else: 197 197 msg = "Q must be given as list of qx's and qy's" 198 raise ValueError , msg198 raise ValueError(msg) 199 199 200 200 def evalDistribution(self, qdist): … … 214 214 mesg = "evalDistribution is expecting an ndarray of " 215 215 mesg += "a list [qx,qy] where qx,qy are arrays." 216 raise RuntimeError , mesg216 raise RuntimeError(mesg) 217 217 218 218 class OMF2SLD(object): … … 313 313 :Params length: data length 314 314 """ 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.") 328 318 329 319 def remove_null_points(self, remove=False, recenter=False): … … 415 405 msg = "Error: \n" 416 406 msg += "We accept only m as meshunit" 417 raise ValueError , msg407 raise ValueError(msg) 418 408 if s_line[0].lower().count("xbase") > 0: 419 409 xbase = s_line[1].lstrip() … … 485 475 msg = "%s is not supported: \n" % path 486 476 msg += "We accept only Text format OMF file." 487 raise RuntimeError , msg477 raise RuntimeError(msg) 488 478 489 479 class PDBReader(object): … … 605 595 return output 606 596 except: 607 raise RuntimeError , "%s is not a sld file" % path597 raise RuntimeError("%s is not a sld file" % path) 608 598 609 599 def write(self, path, data): … … 697 687 return output 698 688 except: 699 raise RuntimeError , "%s is not a sld file" % path689 raise RuntimeError("%s is not a sld file" % path) 700 690 701 691 def write(self, path, data): … … 706 696 """ 707 697 if path is None: 708 raise ValueError , "Missing the file path."698 raise ValueError("Missing the file path.") 709 699 if data is None: 710 raise ValueError , "Missing the data to save."700 raise ValueError("Missing the data to save.") 711 701 x_val = data.pos_x 712 702 y_val = data.pos_y
Note: See TracChangeset
for help on using the changeset viewer.