Changes in / [0a924c6:8c9e65c] in sasview
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/instrument.py
rf4775563 re090ba90 128 128 self.size = 0 129 129 else: 130 self.size = size 130 # TODO: Make sure detector size is number of pixels 131 # Could be detector dimensions in e.g., mm, but 132 # the resolution calculator assumes it is pixels. 133 # Being pixels, it has to be integers rather than float 134 self.size = [int(s) for s in size] 131 135 validate(size[0]) 132 136 -
src/sas/sascalc/calculator/resolution_calculator.py
r574adc7 re090ba90 1007 1007 try: 1008 1008 detector_offset = self.sample2detector_distance[1] 1009 except :1010 logger.error( sys.exc_value)1009 except Exception as exc: 1010 logger.error(exc) 1011 1011 1012 1012 # detector size in [no of pix_x,no of pix_y] … … 1094 1094 output.qx_data = qx_value 1095 1095 output.qy_data = qy_value 1096 except :1097 logger.error( sys.exc_value)1096 except Exception as exc: 1097 logger.error(exc) 1098 1098 1099 1099 return output -
src/sas/sascalc/corfunc/corfunc_calculator.py
ra26f67f re090ba90 30 30 self.start = start 31 31 self.stop = stop 32 self._lastx = []33 self._lasty = []32 self._lastx = np.empty(0, dtype='d') 33 self._lasty = None 34 34 35 35 def __call__(self, x): 36 36 # If input is a single number, evaluate the function at that number 37 37 # and return a single number 38 if type(x) == float or type(x) == int:38 if isinstance(x, (float, int)): 39 39 return self._smoothed_function(np.array([x]))[0] 40 40 # If input is a list, and is different to the last input, evaluate … … 42 42 # the function was called, return the result that was calculated 43 43 # last time instead of explicity evaluating the function again. 44 elif self._lastx == [] or x.tolist() != self._lastx.tolist(): 45 self._lasty = self._smoothed_function(x) 46 self._lastx = x 44 if not np.array_equal(x, self._lastx): 45 self._lastx, self._lasty = x, self._smoothed_function(x) 47 46 return self._lasty 48 47 … … 88 87 # Only process data of the class Data1D 89 88 if not issubclass(data.__class__, Data1D): 90 raise ValueError(" Data must be of the type DataLoader.Data1D")89 raise ValueError("Correlation function cannot be computed with 2D data.") 91 90 92 91 # Prepare the data … … 246 245 """Fit the Guinier region of the curve""" 247 246 A = np.vstack([q**2, np.ones(q.shape)]).T 248 return lstsq(A, np.log(iq) )247 return lstsq(A, np.log(iq), rcond=None) 249 248 250 249 def _fit_porod(self, q, iq): -
src/sas/sascalc/data_util/calcthread.py
r574adc7 re090ba90 6 6 from __future__ import print_function 7 7 8 import traceback9 8 import sys 10 9 import logging 10 import traceback 11 from time import sleep 12 11 13 try: 12 14 import _thread as thread 13 15 except ImportError: # CRUFT: python 2 support 14 16 import thread 15 16 if sys.platform.count("darwin") > 0: 17 import time 18 stime = time.time() 19 20 def clock(): 21 return time.time() - stime 22 23 def sleep(t): 24 return time.sleep(t) 25 else: 26 from time import clock 27 from time import sleep 17 try: 18 from time import perf_counter as clock 19 except ImportError: # CRUFT: python < 3.3 20 if sys.platform.count("darwin") > 0: 21 from time import time as clock 22 else: 23 from time import clock 28 24 29 25 logger = logging.getLogger(__name__) 30 31 26 32 27 class CalcThread: … … 248 243 self.exception_handler(*sys.exc_info()) 249 244 return 250 except Exception :245 except Exception as exc: 251 246 pass 252 247 logger.error(traceback.format_exc()) -
src/sas/sascalc/data_util/nxsunit.py
rb011ecb re090ba90 99 99 Strip '^' from unit names. 100 100 101 * WARNING * this will incorrect transform 10^3 to 103. 102 """ 103 s.update((k.replace('^',''),v) 104 for k, v in list(s.items()) 105 if '^' in k) 101 * WARNING * this will incorrectly transform 10^3 to 103. 102 """ 103 stripped = [(k.replace('^',''),v) for k, v in s.items() if '^' in k] 104 s.update(stripped) 106 105 107 106 def _build_all_units(): -
src/sas/sascalc/data_util/ordereddicttest.py
rb699768 re090ba90 147 147 ]): 148 148 self.assert_(dup is not od) 149 self.assertEqual s(dup, od)150 self.assertEqual s(list(dup.items()), list(od.items()))151 self.assertEqual s(len(dup), len(od))152 self.assertEqual s(type(dup), type(od))149 self.assertEqual(dup, od) 150 self.assertEqual(list(dup.items()), list(od.items())) 151 self.assertEqual(len(dup), len(od)) 152 self.assertEqual(type(dup), type(od)) 153 153 154 154 def test_repr(self): -
src/sas/sascalc/data_util/registry.py
ra26f67f re090ba90 148 148 # If file has associated loader(s) and they;ve failed 149 149 raise last_exc 150 raise NoKnownLoaderException( e.message) # raise generic exception150 raise NoKnownLoaderException(str(message)) # raise generic exception -
src/sas/sascalc/data_util/uncertainty.py
r574adc7 re090ba90 19 19 import numpy as np 20 20 21 from . import err1d21 from . import err1d 22 22 from .formatnum import format_uncertainty 23 23 -
src/sas/sascalc/dataloader/data_info.py
r4fdcc65 re090ba90 26 26 import numpy as np 27 27 import math 28 from math import fabs 28 29 29 30 class plottable_1D(object): … … 656 657 return self._perform_operation(other, operation) 657 658 658 def __ div__(self, other):659 def __truediv__(self, other): 659 660 """ 660 661 Divided a data set by another … … 667 668 return a/b 668 669 return self._perform_operation(other, operation) 669 670 def __rdiv__(self, other): 670 __div__ = __truediv__ 671 672 def __rtruediv__(self, other): 671 673 """ 672 674 Divided a data set by another … … 679 681 return b/a 680 682 return self._perform_operation(other, operation) 683 __rdiv__ = __rtruediv__ 681 684 682 685 def __or__(self, other): … … 800 803 TOLERANCE = 0.01 801 804 for i in range(len(self.x)): 802 if math.fabs((self.x[i] - other.x[i])/self.x[i]) >TOLERANCE:805 if fabs(self.x[i] - other.x[i]) > self.x[i]*TOLERANCE: 803 806 msg = "Incompatible data sets: x-values do not match" 804 807 raise ValueError(msg) … … 1032 1035 raise ValueError(msg) 1033 1036 for ind in range(len(self.data)): 1034 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) >TOLERANCE:1037 if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 1035 1038 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1036 1039 raise ValueError(msg) 1037 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) >TOLERANCE:1040 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 1038 1041 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1039 1042 raise ValueError(msg) -
src/sas/sascalc/dataloader/loader.py
rb1ec23d rb1ec23d 169 169 if self._identify_plugin(module): 170 170 readers_found += 1 171 except :171 except Exception as exc: 172 172 msg = "Loader: Error importing " 173 msg += "%s\n %s" % (item, sys.exc_value)173 msg += "%s\n %s" % (item, exc) 174 174 logger.error(msg) 175 175 … … 191 191 if self._identify_plugin(module): 192 192 readers_found += 1 193 except :193 except Exception as exc: 194 194 msg = "Loader: Error importing" 195 msg += " %s\n %s" % (mfile, sys.exc_value)195 msg += " %s\n %s" % (mfile, exc) 196 196 logger.error(msg) 197 197 198 except :198 except Exception as exc: 199 199 msg = "Loader: Error importing " 200 msg += " %s\n %s" % (item, sys.exc_value)200 msg += " %s\n %s" % (item, exc) 201 201 logger.error(msg) 202 202 … … 242 242 self.writers[ext].append(loader.write) 243 243 244 except :244 except Exception as exc: 245 245 msg = "Loader: Error accessing" 246 msg += " Reader in %s\n %s" % (module.__name__, sys.exc_value)246 msg += " Reader in %s\n %s" % (module.__name__, exc) 247 247 logger.error(msg) 248 248 return reader_found … … 275 275 self.wildcards.append(wcard) 276 276 277 except :277 except Exception as exc: 278 278 msg = "Loader: Error accessing Reader " 279 msg += "in %s\n %s" % (loader.__name__, sys.exc_value)279 msg += "in %s\n %s" % (loader.__name__, exc) 280 280 logger.error(msg) 281 281 return reader_found … … 320 320 self.writers[ext].insert(0, loader.write) 321 321 322 except :322 except Exception as exc: 323 323 msg = "Loader: Error accessing Reader" 324 msg += " in %s\n %s" % (module.__name__, sys.exc_value)324 msg += " in %s\n %s" % (module.__name__, exc) 325 325 logger.error(msg) 326 326 return reader_found -
src/sas/sascalc/dataloader/manipulations.py
r574adc7 re4e9162 928 928 929 929 # Organize the results 930 for i in range(self.nbins): 931 y[i] = y[i] / y_counts[i] 932 y_err[i] = math.sqrt(y_err[i]) / y_counts[i] 933 934 # The type of averaging: phi,q2, or q 935 # Calculate x[i]should be at the center of the bin 930 with np.errstate(divide='ignore', invalid='ignore'): 931 y = y/y_counts 932 y_err = np.sqrt(y_err)/y_counts 933 # The type of averaging: phi, q2, or q 934 # Calculate x values at the center of the bin 936 935 if run.lower() == 'phi': 937 x[i] = (self.phi_max - self.phi_min) / self.nbins * \938 (1.0 * i + 0.5)+ self.phi_min936 step = (self.phi_max - self.phi_min) / self.nbins 937 x = (np.arange(self.nbins) + 0.5) * step + self.phi_min 939 938 else: 940 # We take the center of ring area, not radius. 941 # This is more accurate than taking the radial center of ring. 942 # delta_r = (self.r_max - self.r_min) / self.nbins 943 # r_inner = self.r_min + delta_r * i 944 # r_outer = r_inner + delta_r 945 # x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2) 946 x[i] = x[i] / y_counts[i] 947 y_err[y_err == 0] = np.average(y_err) 939 # set q to the average of the q values within each bin 940 x = x/y_counts 941 942 ### Alternate algorithm 943 ## We take the center of ring area, not radius. 944 ## This is more accurate than taking the radial center of ring. 945 #step = (self.r_max - self.r_min) / self.nbins 946 #r_inner = self.r_min + step * np.arange(self.nbins) 947 #x = math.sqrt((r_inner**2 + (r_inner + step)**2) / 2) 948 948 949 idx = (np.isfinite(y) & np.isfinite(y_err)) 949 950 if x_err is not None: -
src/sas/sascalc/dataloader/readers/associations.py
rc7c8143 rc7c8143 54 54 exec("loader.associate_file_type('%s', %s)" 55 55 % (ext.upper(), reader)) 56 except :56 except Exception as exc: 57 57 msg = "read_associations: skipping association" 58 msg += " for %s\n %s" % (ext.lower(), sys.exc_value)58 msg += " for %s\n %s" % (ext.lower(), exc) 59 59 logger.error(msg) -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r058f6c3 re090ba90 1239 1239 conv = Converter(units) 1240 1240 setattrchain(storage, variable, conv(value, units=local_unit)) 1241 except Exception: 1242 _, exc_value, _ = sys.exc_info() 1241 except Exception as exc: 1243 1242 err_mess = "CanSAS reader: could not convert" 1244 1243 err_mess += " %s unit [%s]; expecting [%s]\n %s" \ 1245 % (variable, units, local_unit, exc _value)1244 % (variable, units, local_unit, exc) 1246 1245 self.errors.add(err_mess) 1247 1246 if optional: -
src/sas/sascalc/fit/expression.py
r574adc7 re090ba90 210 210 211 211 #print("Function: "+functiondef) 212 exec functiondef in globals,locals212 exec(functiondef, globals, locals) 213 213 retfn = locals['eval_expressions'] 214 214 -
src/sas/sascalc/fit/models.py
r0f0fe42 re090ba90 12 12 import py_compile 13 13 import shutil 14 15 from six import reraise 14 16 15 17 from sasmodels.sasview_model import load_custom_model, load_standard_models … … 62 64 try: 63 65 new_instance = model() 64 except Exception: 65 msg = "Plugin %s error in __init__ \n\t: %s %s\n" % (str(name), 66 str(sys.exc_type), 67 sys.exc_info()[1]) 66 except Exception as exc: 67 msg = ("Plugin %s error in __init__ \n\t: %s %s\n" 68 % (name, type(exc), exc)) 68 69 plugin_log(msg) 69 70 return None … … 72 73 try: 73 74 value = new_instance.function() 74 except Exception :75 except Exception as exc: 75 76 msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 76 (str(name), str( sys.exc_type), sys.exc_info()[1])77 (str(name), str(type(exc)), exc) 77 78 plugin_log(msg) 78 79 return None … … 139 140 if type is not None and issubclass(type, py_compile.PyCompileError): 140 141 print("Problem with", repr(value)) 141 r aise type, value, tb142 reraise(type, value, tb) 142 143 return 1 143 144 … … 153 154 compileall.compile_dir(dir=dir, ddir=dir, force=0, 154 155 quiet=report_problem) 155 except Exception :156 return sys.exc_info()[1]156 except Exception as exc: 157 return exc 157 158 return None 158 159 … … 185 186 model.name = PLUGIN_NAME_BASE + model.name 186 187 plugins[model.name] = model 187 except Exception :188 except Exception as exc: 188 189 msg = traceback.format_exc() 189 190 msg += "\nwhile accessing model in %r" % path -
src/sas/sascalc/fit/pagestate.py
r863ac2c re090ba90 650 650 #Truncating string so print doesn't complain of being outside margins 651 651 if sys.platform != "win32": 652 MAX_STRING_LENG HT= 50653 if len(file_value) > MAX_STRING_LENG HT:654 file_value = "File name:.."+file_value[-MAX_STRING_LENG HT+10:]652 MAX_STRING_LENGTH = 50 653 if len(file_value) > MAX_STRING_LENGTH: 654 file_value = "File name:.."+file_value[-MAX_STRING_LENGTH+10:] 655 655 file_name = CENTRE % file_value 656 656 if len(title) == 0: … … 905 905 doc_model = newdoc.createElement('model_list_item') 906 906 doc_model.setAttribute('checked', str(model[0].GetValue())) 907 keys = model[1].keys()907 keys = list(model[1].keys()) 908 908 doc_model.setAttribute('name', str(keys[0])) 909 909 values = model[1].get(keys[0]) … … 964 964 if node.get('version'): 965 965 # Get the version for model conversion purposes 966 x = re.sub( '[^\d.]', '', node.get('version'))966 x = re.sub(r'[^\d.]', '', node.get('version')) 967 967 self.version = tuple(int(e) for e in str.split(x, ".")) 968 968 # The tuple must be at least 3 items long … … 984 984 try: 985 985 self.timestamp = float(entry.get('epoch')) 986 except Exception :986 except Exception as exc: 987 987 msg = "PageState.fromXML: Could not" 988 msg += " read timestamp\n %s" % sys.exc_value988 msg += " read timestamp\n %s" % exc 989 989 logger.error(msg) 990 990 … … 1282 1282 if isinstance(data.run_name, dict): 1283 1283 # Note: key order in dict is not guaranteed, so sort 1284 name = data.run_name.keys()[0]1284 name = list(data.run_name.keys())[0] 1285 1285 else: 1286 1286 name = data.run_name -
src/sas/sascalc/invariant/invariant.py
r574adc7 re090ba90 344 344 else: 345 345 A = np.vstack([linearized_data.x / linearized_data.dy, 1.0 / linearized_data.dy]).T 346 (p, residuals, _, _) = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy) 346 p, residuals, _, _ = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy, 347 rcond=None) 347 348 348 349 # Get the covariance matrix, defined as inv_cov = a_transposed * a -
src/sas/sascalc/pr/distance_explorer.py
r959eb01 re090ba90 99 99 results.pos_err.append(pos_err) 100 100 results.osc.append(osc) 101 except :101 except Exception as exc: 102 102 # This inversion failed, skip this D_max value 103 103 msg = "ExploreDialog: inversion failed for " 104 msg += "D_max=%s\n %s" % (str(d), sys.exc_value)104 msg += "D_max=%s\n %s" % (str(d), exc) 105 105 results.errors.append(msg) 106 106 -
src/sas/sascalc/pr/fit/expression.py
r574adc7 re090ba90 210 210 211 211 #print("Function: "+functiondef) 212 exec functiondef in globals,locals212 exec(functiondef, globals, locals) 213 213 retfn = locals['eval_expressions'] 214 214 -
src/sas/sascalc/pr/num_term.py
r3e6829d r3e6829d 182 182 data_y = np.append(data_y, test_y) 183 183 data_err = np.append(data_err, err) 184 except :185 logger.error( sys.exc_value)184 except Exception as exc: 185 logger.error(exc) 186 186 187 187 return data_x, data_y, data_err -
src/sas/sascalc/realspace/VolumeCanvas.py
r98e3f24 re090ba90 472 472 Return a list of the shapes 473 473 """ 474 return self.shapes.keys()474 return list(self.shapes.keys()) 475 475 476 476 def _addSingleShape(self, shapeDesc): -
test/calculatorview/test/utest_gui_sld.py
r959eb01 r88d2e70 33 33 self.sld_frame.panel.ProcessEvent(clickEvent) 34 34 bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 35 self.assert _(bkg.GetAsString() == 'pink')35 self.assertTrue(bkg.GetAsString() == 'pink') 36 36 #compute invariant without entering a value for compound 37 37 self.sld_frame.panel.compound_ctl.SetValue("") … … 39 39 self.sld_frame.panel.ProcessEvent(clickEvent) 40 40 bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 41 self.assert _(bkg.GetAsString() == 'pink')41 self.assertTrue(bkg.GetAsString() == 'pink') 42 42 #compute invariant without entering a value for compound 43 43 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 45 45 self.sld_frame.panel.ProcessEvent(clickEvent) 46 46 bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 47 self.assert _(bkg.GetAsString() == 'white')47 self.assertTrue(bkg.GetAsString() == 'white') 48 48 49 49 def testDensityTextCtrl(self): … … 59 59 self.sld_frame.panel.ProcessEvent(clickEvent) 60 60 bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 61 self.assert _(bkg.GetAsString() == 'pink')61 self.assertTrue(bkg.GetAsString() == 'pink') 62 62 #compute invariant without entering a value for density 63 63 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 65 65 self.sld_frame.panel.ProcessEvent(clickEvent) 66 66 bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 67 self.assert _(bkg.GetAsString() == 'pink')67 self.assertTrue(bkg.GetAsString() == 'pink') 68 68 #compute invariant without entering a value for density 69 69 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 71 71 self.sld_frame.panel.ProcessEvent(clickEvent) 72 72 bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 73 self.assert _(bkg.GetAsString() == 'white')73 self.assertTrue(bkg.GetAsString() == 'white') 74 74 75 75 def testWavelengthTextCtrl(self): … … 86 86 self.sld_frame.panel.ProcessEvent(clickEvent) 87 87 bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 88 self.assert _(bkg.GetAsString() == 'pink')88 self.assertTrue(bkg.GetAsString() == 'pink') 89 89 #compute invariant without entering a value for wavelegnth 90 90 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 93 93 self.sld_frame.panel.ProcessEvent(clickEvent) 94 94 cp_bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 95 self.assert _(cp_bkg.GetAsString() == 'white')95 self.assertTrue(cp_bkg.GetAsString() == 'white') 96 96 ds_bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 97 self.assert _(ds_bkg.GetAsString() == 'white')97 self.assertTrue(ds_bkg.GetAsString() == 'white') 98 98 wv_bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 99 99 value = self.sld_frame.panel.wavelength_ctl.GetValue() 100 self.assert _(wv_bkg.GetAsString() == 'white')101 self.assert _(float(value) == WAVELENGTH)100 self.assertTrue(wv_bkg.GetAsString() == 'white') 101 self.assertTrue(float(value) == WAVELENGTH) 102 102 sld_real = self.sld_frame.panel.neutron_sld_real_ctl.GetValue() 103 103 sld_im = self.sld_frame.panel.neutron_sld_im_ctl.GetValue() … … 110 110 length = self.sld_frame.panel.neutron_length_ctl.GetValue() 111 111 112 self.assertAlmostEqual s(float(sld_real), 1.04e-6, 1)113 self.assertAlmostEqual s(float(sld_im), -1.5e-7, 1)112 self.assertAlmostEqual(float(sld_real), 1.04e-6, 1) 113 self.assertAlmostEqual(float(sld_im), -1.5e-7, 1) 114 114 #test absorption value 115 self.assertAlmostEqual s(float(abs) , 0.0741, 2)116 self.assertAlmostEqual s(float(incoh), 5.62, 2)115 self.assertAlmostEqual(float(abs) , 0.0741, 2) 116 self.assertAlmostEqual(float(incoh), 5.62, 2) 117 117 #Test length 118 self.assertAlmostEqual s(float(length), 0.1755, 2)118 self.assertAlmostEqual(float(length), 0.1755, 2) 119 119 #test Cu sld 120 self.assertAlmostEqual s(float(cu_real), 9.46e-6, 1)121 self.assertAlmostEqual s(float(cu_im), 3.01e-8)120 self.assertAlmostEqual(float(cu_real), 9.46e-6, 1) 121 self.assertAlmostEqual(float(cu_im), 3.01e-8) 122 122 # test Mo sld 123 self.assertAlmostEqual s(float(mo_real), 9.43e-6)124 self.assertAlmostEqual s(float(mo_im), 5.65e-7, 1)123 self.assertAlmostEqual(float(mo_real), 9.43e-6) 124 self.assertAlmostEqual(float(mo_im), 5.65e-7, 1) 125 125 #compute invariant with all correct inputs value 126 126 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 130 130 bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 131 131 value = self.sld_frame.panel.wavelength_ctl.GetValue() 132 self.assert _(bkg.GetAsString() == 'white')133 self.assert _(float(value) == WAVELENGTH/2)132 self.assertTrue(bkg.GetAsString() == 'white') 133 self.assertTrue(float(value) == WAVELENGTH/2) 134 134 135 135 def testSomeCombination(self): … … 145 145 self.sld_frame.panel.ProcessEvent(clickEvent) 146 146 cp_bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 147 self.assert _(cp_bkg.GetAsString() == 'white')147 self.assertTrue(cp_bkg.GetAsString() == 'white') 148 148 ds_bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 149 self.assert _(ds_bkg.GetAsString() == 'white')149 self.assertTrue(ds_bkg.GetAsString() == 'white') 150 150 wv_bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 151 self.assert _(wv_bkg.GetAsString() == 'pink')151 self.assertTrue(wv_bkg.GetAsString() == 'pink') 152 152 #density, wavelength is invalid 153 153 self.sld_frame.panel.compound_ctl.SetValue("H2O") … … 158 158 self.sld_frame.panel.ProcessEvent(clickEvent) 159 159 cp_bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 160 self.assert _(cp_bkg.GetAsString() == 'white')160 self.assertTrue(cp_bkg.GetAsString() == 'white') 161 161 ds_bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 162 self.assert _(ds_bkg.GetAsString() == 'pink')162 self.assertTrue(ds_bkg.GetAsString() == 'pink') 163 163 wv_bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 164 self.assert _(wv_bkg.GetAsString() == 'pink')164 self.assertTrue(wv_bkg.GetAsString() == 'pink') 165 165 #density, wavelength is invalid 166 166 self.sld_frame.panel.compound_ctl.SetValue("invalid compound") … … 171 171 self.sld_frame.panel.ProcessEvent(clickEvent) 172 172 cp_bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 173 self.assert _(cp_bkg.GetAsString() == 'pink')173 self.assertTrue(cp_bkg.GetAsString() == 'pink') 174 174 ds_bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 175 self.assert _(ds_bkg.GetAsString() == 'pink')175 self.assertTrue(ds_bkg.GetAsString() == 'pink') 176 176 wv_bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 177 self.assert _(wv_bkg.GetAsString() == 'white')177 self.assertTrue(wv_bkg.GetAsString() == 'white') 178 178 value = self.sld_frame.panel.wavelength_ctl.GetValue() 179 self.assert _(float(value) == WAVELENGTH)179 self.assertTrue(float(value) == WAVELENGTH) 180 180 181 181 -
test/pr_inversion/test/utest_explorer.py
rf53d684 r1852b17 3 3 """ 4 4 5 import sys 5 6 import os.path 6 7 import unittest, math, numpy 7 from utest_invertor import load8 8 from sas.sascalc.pr.invertor import Invertor 9 9 from sas.sascalc.pr.distance_explorer import DistExplorer 10 10 11 try: 12 from utest_invertor import load 13 except ImportError: 14 from .utest_invertor import load 11 15 12 16 def find(filename): … … 36 40 self.assertEqual(len(results.errors), 0) 37 41 self.assertEqual(len(results.chi2), 25) 38 42 39 43 if __name__ == '__main__': 40 44 unittest.main() -
test/sascalculator/test/utest_sld.py
ra50da82 r88d2e70 51 51 molecule_formula=self.sld_formula) 52 52 #test sld 53 self.assertAlmostEqual s(sld_real * _SCALE, -5.6e-7, 1)54 self.assertAlmostEqual s(sld_im * _SCALE, 0)53 self.assertAlmostEqual(sld_real * _SCALE, -5.6e-7, 1) 54 self.assertAlmostEqual(sld_im * _SCALE, 0) 55 55 #test absorption value 56 self.assertAlmostEqual s(abs, 0.0741, 2)57 self.assertAlmostEqual s(incoh, 5.62, 2)56 self.assertAlmostEqual(abs, 0.0741, 2) 57 self.assertAlmostEqual(incoh, 5.62, 2) 58 58 #Test length 59 self.assertAlmostEqual s(length, 0.1755, 3)59 self.assertAlmostEqual(length, 0.1755, 3) 60 60 #test Cu sld 61 self.assertAlmostEqual s(cu_real * _SCALE, 9.46e-6, 1)62 self.assertAlmostEqual s(cu_im * _SCALE, 3.01e-8)61 self.assertAlmostEqual(cu_real * _SCALE, 9.46e-6, 1) 62 self.assertAlmostEqual(cu_im * _SCALE, 3.01e-8) 63 63 # test Mo sld 64 self.assertAlmostEqual s(mo_real * _SCALE, 9.43e-6)65 self.assertAlmostEqual s(mo_im * _SCALE, 5.65e-7,1)64 self.assertAlmostEqual(mo_real * _SCALE, 9.43e-6) 65 self.assertAlmostEqual(mo_im * _SCALE, 5.65e-7,1) 66 66 67 67 … … 91 91 molecule_formula=self.sld_formula) 92 92 #test sld 93 self.assertAlmostEqual s(sld_real * _SCALE, 6.33e-6, 1)94 self.assertAlmostEqual s(sld_im * _SCALE, 0)93 self.assertAlmostEqual(sld_real * _SCALE, 6.33e-6, 1) 94 self.assertAlmostEqual(sld_im * _SCALE, 0) 95 95 #test absorption value 96 self.assertAlmostEqual s(abs, 1.35e-4, 2)97 self.assertAlmostEqual s(incoh, 0.138, 2)96 self.assertAlmostEqual(abs, 1.35e-4, 2) 97 self.assertAlmostEqual(incoh, 0.138, 2) 98 98 #Test length 99 self.assertAlmostEqual s(length, 1.549, 3)99 self.assertAlmostEqual(length, 1.549, 3) 100 100 #test Cu sld 101 self.assertAlmostEqual s(cu_real * _SCALE, 9.36e-6, 1)102 self.assertAlmostEqual s(cu_im * _SCALE, 2.98e-8)101 self.assertAlmostEqual(cu_real * _SCALE, 9.36e-6, 1) 102 self.assertAlmostEqual(cu_im * _SCALE, 2.98e-8) 103 103 # test Mo sld 104 self.assertAlmostEqual s(mo_real * _SCALE, 9.33e-6)105 self.assertAlmostEqual s(mo_im * _SCALE, 5.59e-9,1)104 self.assertAlmostEqual(mo_real * _SCALE, 9.33e-6) 105 self.assertAlmostEqual(mo_im * _SCALE, 5.59e-9,1) 106 106 107 107 … … 131 131 molecule_formula=self.sld_formula) 132 132 #test sld 133 self.assertAlmostEqual s(sld_real * _SCALE, 1.04e-6, 1)134 self.assertAlmostEqual s(sld_im * _SCALE, -1.5e-7, 1)133 self.assertAlmostEqual(sld_real * _SCALE, 1.04e-6, 1) 134 self.assertAlmostEqual(sld_im * _SCALE, -1.5e-7, 1) 135 135 #test absorption value 136 self.assertAlmostEqual s(abs, 180.0,0)137 self.assertAlmostEqual s(incoh, 0.0754, 2)136 self.assertAlmostEqual(abs, 180.0,0) 137 self.assertAlmostEqual(incoh, 0.0754, 2) 138 138 #Test length 139 self.assertAlmostEqual s(length, 0.005551, 4)139 self.assertAlmostEqual(length, 0.005551, 4) 140 140 #test Cu sld 141 self.assertAlmostEqual s(cu_real * _SCALE, 2.89e-5, 1)142 self.assertAlmostEqual s(cu_im * _SCALE, 2.81e-6)141 self.assertAlmostEqual(cu_real * _SCALE, 2.89e-5, 1) 142 self.assertAlmostEqual(cu_im * _SCALE, 2.81e-6) 143 143 # test Mo sld 144 self.assertAlmostEqual s(mo_real * _SCALE, 2.84e-5, 1)145 self.assertAlmostEqual s(mo_im * _SCALE, 7.26e-7,1)144 self.assertAlmostEqual(mo_real * _SCALE, 2.84e-5, 1) 145 self.assertAlmostEqual(mo_im * _SCALE, 7.26e-7,1) 146 146 147 147 if __name__ == '__main__': -
test/sasdataloader/plugins/test_reader.py
raaf5e49 r88d2e70 40 40 input_f = open(path,'r') 41 41 except : 42 raise RuntimeError , "ascii_reader: cannot open %s" % path42 raise RuntimeError("ascii_reader: cannot open %s" % path) 43 43 buff = input_f.read() 44 44 lines = buff.split('\n') … … 55 55 return output 56 56 else: 57 raise RuntimeError , "%s is not a file" % path57 raise RuntimeError("%s is not a file" % path) 58 58 return None 59 59 -
test/sasdataloader/test/utest_abs_reader.py
rd96744de r4cbb2f5 357 357 self.assertEqual(self.data.dy[0], 3) 358 358 self.assertEqual(self.data.x[1], 0.03) 359 self.assertAlmostEqual s(self.data.y[1], 1001.0)359 self.assertAlmostEqual(self.data.y[1], 1001.0) 360 360 self.assertEqual(self.data.dxl[1], 0.005) 361 361 self.assertEqual(self.data.dxw[1], 0.001) -
test/sasinvariant/test/utest_data_handling.py
rf53d684 r88d2e70 45 45 46 46 # Test results 47 self.assertAlmostEqual s(p[0], 1.0, 5)48 self.assertAlmostEqual s(p[1], 0.0, 5)47 self.assertAlmostEqual(p[0], 1.0, 5) 48 self.assertAlmostEqual(p[1], 0.0, 5) 49 49 50 50 def test_fit_linear_data_with_noise(self): … … 74 74 75 75 # Test results 76 self.assertAlmostEqual s(p[0], 1.0, 5)77 self.assertAlmostEqual s(p[1], 0.0, 5)76 self.assertAlmostEqual(p[0], 1.0, 5) 77 self.assertAlmostEqual(p[1], 0.0, 5) 78 78 79 79 def test_fit_linear_data_with_noise_and_fixed_par(self): … … 506 506 for i in range(len(self.data.x)): 507 507 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 508 self.assert _(value < 0.001)508 self.assertTrue(value < 0.001) 509 509 510 510 class TestDataExtraLowSlitGuinier(unittest.TestCase): … … 553 553 554 554 test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x[:inv._low_extrapolation_npts]) 555 self.assert _(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts]))555 self.assertTrue(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts])) 556 556 557 557 for i in range(inv._low_extrapolation_npts): 558 558 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 559 self.assert _(value < 0.001)559 self.assertTrue(value < 0.001) 560 560 561 561 def test_low_data(self): … … 589 589 npts = inv._low_extrapolation_npts) 590 590 test_y = data_in_range.y 591 self.assert _(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts]))591 self.assertTrue(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts])) 592 592 for i in range(inv._low_extrapolation_npts): 593 593 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 594 self.assert _(value < 0.001)594 self.assertTrue(value < 0.001) 595 595 596 596 … … 642 642 643 643 test_y = inv._high_extrapolation_function.evaluate_model(x=self.data.x[start: ]) 644 self.assert _(len(test_y) == len(self.data.y[start:]))644 self.assertTrue(len(test_y) == len(self.data.y[start:])) 645 645 646 646 for i in range(len(self.data.x[start:])): 647 647 value = math.fabs(test_y[i]-self.data.y[start+i])/self.data.y[start+i] 648 self.assert _(value < 0.001)648 self.assertTrue(value < 0.001) 649 649 650 650 def test_high_data(self): … … 677 677 npts = inv._high_extrapolation_npts) 678 678 test_y = data_in_range.y 679 self.assert _(len(test_y) == len(self.data.y[start:]))679 self.assertTrue(len(test_y) == len(self.data.y[start:])) 680 680 temp = self.data.y[start:] 681 681 682 682 for i in range(len(self.data.x[start:])): 683 683 value = math.fabs(test_y[i]- temp[i])/temp[i] 684 self.assert _(value < 0.001)684 self.assertTrue(value < 0.001) -
test/sasinvariant/test/utest_use_cases.py
rf53d684 r88d2e70 39 39 40 40 # Test results 41 self.assertAlmostEqual s(p[0], 2.3983,3)42 self.assertAlmostEqual s(p[1], 0.87833,3)41 self.assertAlmostEqual(p[0], 2.3983,3) 42 self.assertAlmostEqual(p[1], 0.87833,3) 43 43 44 44 def test_fit_line_data_fixed(self): … … 54 54 55 55 # Test results 56 self.assertAlmostEqual s(p[0], 4)57 self.assertAlmostEqual s(p[1], -4.0676,3)56 self.assertAlmostEqual(p[0], 4) 57 self.assertAlmostEqual(p[1], -4.0676,3) 58 58 59 59 … … 78 78 79 79 # Test results 80 self.assertAlmostEqual s(p[0], 2.4727,3)81 self.assertAlmostEqual s(p[1], 0.6,3)80 self.assertAlmostEqual(p[0], 2.4727,3) 81 self.assertAlmostEqual(p[1], 0.6,3) 82 82 83 83 def test_fit_line_data_fixed_no_weight(self): … … 93 93 94 94 # Test results 95 self.assertAlmostEqual s(p[0], 4)96 self.assertAlmostEqual s(p[1], -7.8,3)95 self.assertAlmostEqual(p[0], 4) 96 self.assertAlmostEqual(p[1], -7.8,3) 97 97 98 98 … … 132 132 133 133 # Test results 134 self.assertAlmostEqual s(qstar, 7.48959e-5,2)135 self.assertAlmostEqual s(v, 0.005644689, 4)136 self.assertAlmostEqual s(s , 941.7452, 3)134 self.assertAlmostEqual(qstar, 7.48959e-5,2) 135 self.assertAlmostEqual(v, 0.005644689, 4) 136 self.assertAlmostEqual(s , 941.7452, 3) 137 137 138 138 def test_use_case_2(self): … … 153 153 s, ds = inv.get_surface_with_error(contrast=2.6e-6, porod_const=2) 154 154 # Test results 155 self.assertAlmostEqual s(qstar, 7.48959e-5,2)156 self.assertAlmostEqual s(v, 0.005644689, 1)157 self.assertAlmostEqual s(s , 941.7452, 3)155 self.assertAlmostEqual(qstar, 7.48959e-5,2) 156 self.assertAlmostEqual(v, 0.005644689, 1) 157 self.assertAlmostEqual(s , 941.7452, 3) 158 158 159 159 def test_use_case_3(self): … … 190 190 191 191 # Test results 192 self.assertAlmostEqual s(qstar, 7.49e-5, 1)193 self.assertAlmostEqual s(v, 0.005648401, 4)194 self.assertAlmostEqual s(s , 941.7452, 3)192 self.assertAlmostEqual(qstar, 7.49e-5, 1) 193 self.assertAlmostEqual(v, 0.005648401, 4) 194 self.assertAlmostEqual(s , 941.7452, 3) 195 195 196 196 def test_use_case_4(self): … … 218 218 219 219 # Test results 220 self.assertAlmostEqual s(qstar, 7.49e-5,2)221 self.assertAlmostEqual s(v, 0.005952674, 3)222 self.assertAlmostEqual s(s , 941.7452, 3)220 self.assertAlmostEqual(qstar, 7.49e-5,2) 221 self.assertAlmostEqual(v, 0.005952674, 3) 222 self.assertAlmostEqual(s , 941.7452, 3) 223 223 224 224 def test_use_case_5(self): … … 247 247 248 248 # Test results 249 self.assertAlmostEqual s(qstar, 7.88981e-5,2)250 self.assertAlmostEqual s(v, 0.005952674, 3)251 self.assertAlmostEqual s(s , 941.7452, 3)249 self.assertAlmostEqual(qstar, 7.88981e-5,2) 250 self.assertAlmostEqual(v, 0.005952674, 3) 251 self.assertAlmostEqual(s , 941.7452, 3) 252 252 253 253 def test_use_case_6(self): … … 273 273 274 274 # Test results 275 self.assertAlmostEqual s(qstar, 7.49e-5,2)276 self.assertAlmostEqual s(v, 0.005952674, 3)277 self.assertAlmostEqual s(s , 941.7452, 3)275 self.assertAlmostEqual(qstar, 7.49e-5,2) 276 self.assertAlmostEqual(v, 0.005952674, 3) 277 self.assertAlmostEqual(s , 941.7452, 3) 278 278 279 279 … … 297 297 s = inv.get_surface(contrast=2.6e-6, porod_const=2) 298 298 # Test results 299 self.assertAlmostEqual s(qstar, 1.361677e-3, 4)300 self.assertAlmostEqual s(v, 0.115352622, 2)301 self.assertAlmostEqual s(s , 941.7452, 3 )299 self.assertAlmostEqual(qstar, 1.361677e-3, 4) 300 self.assertAlmostEqual(v, 0.115352622, 2) 301 self.assertAlmostEqual(s , 941.7452, 3 ) 302 302 303 303 def test_use_case_2(self): … … 315 315 s, ds = inv.get_surface_with_error(contrast=2.6e-6, porod_const=2) 316 316 # Test results 317 self.assertAlmostEqual s(qstar, 1.361677e-3, 4)318 self.assertAlmostEqual s(v, 0.115352622, 2)319 self.assertAlmostEqual s(s , 941.7452, 3 )317 self.assertAlmostEqual(qstar, 1.361677e-3, 4) 318 self.assertAlmostEqual(v, 0.115352622, 2) 319 self.assertAlmostEqual(s , 941.7452, 3 ) 320 320 321 321 def test_use_case_3(self): … … 336 336 337 337 # Test results 338 self.assertAlmostEqual s(qstar, 0.00138756,2)339 self.assertAlmostEqual s(v, 0.117226896,2)340 self.assertAlmostEqual s(s ,941.7452, 3)338 self.assertAlmostEqual(qstar, 0.00138756,2) 339 self.assertAlmostEqual(v, 0.117226896,2) 340 self.assertAlmostEqual(s ,941.7452, 3) 341 341 342 342 def test_use_case_4(self): … … 354 354 355 355 # Test results 356 self.assertAlmostEqual s(qstar, 0.0045773,2)356 self.assertAlmostEqual(qstar, 0.0045773,2) 357 357 358 358 def test_use_case_5(self): … … 374 374 375 375 # Test results 376 self.assertAlmostEqual s(qstar, 0.00460319,3)376 self.assertAlmostEqual(qstar, 0.00460319,3) 377 377 378 378 -
test/sasrealspace/test/utest_oriented.py
r1cdbcd8 r88d2e70 59 59 ana_val = self.ana.runXY([0.1, 0.1]) 60 60 sim_val = self.model.getIq2D(0.1, 0.1) 61 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.1 )61 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.1 ) 62 62 63 63 class TestCylinderAddObject(unittest.TestCase): … … 101 101 #print ana_val, sim_val, sim_val/ana_val 102 102 103 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )103 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 104 104 105 105 … … 143 143 #print ana_val, sim_val, sim_val/ana_val 144 144 145 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )145 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 146 146 147 147 def testalongZ(self): … … 156 156 #print ana_val, sim_val, sim_val/ana_val 157 157 158 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )158 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 159 159 160 160 def testalongX(self): … … 169 169 #print ana_val, sim_val, sim_val/ana_val 170 170 171 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )171 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 172 172 173 173 class TestEllipsoid(unittest.TestCase): … … 213 213 #print ana_val, sim_val, sim_val/ana_val 214 214 215 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )215 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 216 216 217 217 def testalongZ(self): … … 226 226 #print ana_val, sim_val, sim_val/ana_val 227 227 228 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )228 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 229 229 230 230 def testalongY(self): … … 240 240 241 241 try: 242 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )242 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 243 243 except Exception: 244 244 print("Error", ana_val, sim_val, sim_val/ana_val) … … 295 295 sim_val, err = self.canvas.getIq2DError(0.1, 0.2) 296 296 297 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )297 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 298 298 299 299 class TestCoreShellError(unittest.TestCase): … … 347 347 sim_val, err = self.canvas.getIq2DError(0.1, 0.2) 348 348 349 self.assert _( math.fabs(sim_val-ana_val) < 3.0 * err )349 self.assertTrue( math.fabs(sim_val-ana_val) < 3.0 * err ) 350 350 351 351 class TestRunMethods(unittest.TestCase): … … 392 392 393 393 try: 394 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )394 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 395 395 except Exception: 396 396 print("Error", ana_val, sim_val, sim_val/ana_val) … … 404 404 405 405 try: 406 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )406 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 407 407 except Exception: 408 408 print("Error", ana_val, sim_val, sim_val/ana_val) … … 416 416 417 417 try: 418 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )418 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 419 419 except Exception: 420 420 print("Error", ana_val, sim_val, sim_val/ana_val) … … 428 428 429 429 try: 430 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )430 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 431 431 except Exception: 432 432 print("Error", ana_val, sim_val, sim_val/ana_val) … … 471 471 sim_val = self.model.getIq2D(0.1, 0.2) 472 472 473 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )473 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 474 474 475 475 # Change the radius a re-evaluate … … 479 479 ana_val = self.ana.runXY([0.1, 0.2]) 480 480 sim_val = self.model.getIq2D(0.1, 0.2) 481 self.assert _( math.fabs(sim_val/ana_val-1.0)<0.05 )481 self.assertTrue( math.fabs(sim_val/ana_val-1.0)<0.05 ) 482 482 483 483 -
test/sasrealspace/test/utest_realspace.py
r1cdbcd8 r88d2e70 38 38 self.model.add('ellipsoid','elli2') 39 39 self.model.delete('elli2') 40 self.assert _('elli2' not in self.model.getShapeList())40 self.assertTrue('elli2' not in self.model.getShapeList()) 41 41 42 42 def testsetParam(self): … … 81 81 value_2 = self.canvas.getIq(0.001) 82 82 83 self.assert _( (value_1-value_2)/value_1 < 0.1)83 self.assertTrue( (value_1-value_2)/value_1 < 0.1) 84 84 85 85 def testSetDensityTiming(self): … … 99 99 t_2 = time.time()-t_0 100 100 101 self.assert _( t_2 < t_1 and (t_1-t_2)/t_2 > 2)101 self.assertTrue( t_2 < t_1 and (t_1-t_2)/t_2 > 2) 102 102 103 103 def testGetParamList(self): 104 104 """ Test GetParamList on empty canvas""" 105 self.assert _('lores_density' in self.canvas.getParamList())105 self.assertTrue('lores_density' in self.canvas.getParamList()) 106 106 handle = self.canvas.add('sphere') 107 107 … … 109 109 """ Test GetParamList on filled canvas""" 110 110 self.canvas.add('sphere') 111 self.assert _('lores_density' in self.canvas.getParamList())111 self.assertTrue('lores_density' in self.canvas.getParamList()) 112 112 113 113 def testAdd(self): … … 151 151 # THIS WILL DEPEND ON THE NUMBER OF SPACE POINTS: 152 152 # that why we need some error analysis. 153 self.assert _( (sim_2*ana_1/sim_1 - ana_2)/ana_2 < 0.1)153 self.assertTrue( (sim_2*ana_1/sim_1 - ana_2)/ana_2 < 0.1) 154 154 155 155 # test the absolute amplitude 156 self.assert _( math.fabs(sim_2-ana_2)/ana_2 < 0.1)156 self.assertTrue( math.fabs(sim_2-ana_2)/ana_2 < 0.1) 157 157 158 158 def testGetIq2(self): … … 196 196 sim_2 = self.canvas.getIq(0.01) 197 197 198 self.assert _((sim_2-sim_1)/sim_1<0.05)198 self.assertTrue((sim_2-sim_1)/sim_1<0.05) 199 199 200 200 def testGetIq_time(self): … … 216 216 delta_2 = time.time()-t_0 217 217 218 self.assert _((delta_2-delta_1)/delta_1<0.05)218 self.assertTrue((delta_2-delta_1)/delta_1<0.05) 219 219 220 220 … … 342 342 ana = self.sphere.run(0.05) 343 343 val, err = self.canvas.getIqError(0.05) 344 self.assert _(math.fabs(ana-val)<2.0*err)344 self.assertTrue(math.fabs(ana-val)<2.0*err) 345 345 346 346 def testRightOrder(self): … … 350 350 val, err = self.canvas.getIqError(0.05) 351 351 #print 'right', ana, val, err 352 self.assert _(math.fabs(ana-val)/ana < 1.1)352 self.assertTrue(math.fabs(ana-val)/ana < 1.1) 353 353 354 354 def testWrongOrder(self): … … 365 365 val, err = self.canvas.getIqError(0.05) 366 366 #print 'wrong', ana, val, err 367 self.assert _(math.fabs(ana-val)/ana < 1.1)367 self.assertTrue(math.fabs(ana-val)/ana < 1.1) 368 368 369 369
Note: See TracChangeset
for help on using the changeset viewer.