- Timestamp:
- Apr 4, 2017 10:00:18 AM (8 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 7b15990
- Parents:
- 9a5097c (diff), 571bf4b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Andrew Jackson <andrew.jackson@…> (04/04/17 10:00:18)
- git-committer:
- GitHub <noreply@…> (04/04/17 10:00:18)
- Location:
- test
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
test/corfunc/test/utest_corfunc.py
racefa2b r253eb6c6 8 8 from sas.sascalc.corfunc.corfunc_calculator import CorfuncCalculator 9 9 from sas.sascalc.dataloader.data_info import Data1D 10 import matplotlib.pyplot as plt 10 11 11 12 12 class TestCalculator(unittest.TestCase): … … 69 69 self.assertLess(abs(params['max']-75), 2.5) # L_p ~= 75 70 70 71 72 71 # Ensure tests are ran in correct order; 73 72 # Each test depends on the one before it -
test/sasdataloader/test/utest_abs_reader.py
r9a5097c red2276f 4 4 5 5 import unittest 6 7 import math 6 8 import numpy as np 7 from sas.sascalc.dataloader.loader import Loader 9 from sas.sascalc.dataloader.loader import Loader 10 from sas.sascalc.dataloader.readers.IgorReader import Reader as IgorReader 8 11 from sas.sascalc.dataloader.data_info import Data1D 9 12 … … 85 88 86 89 def setUp(self): 87 self.data = Loader().load("MAR07232_rest.ASC") 88 90 # the IgorReader should be able to read this filetype 91 # if it can't, stop here. 92 reader = IgorReader() 93 self.data = reader.read("MAR07232_rest.ASC") 94 89 95 def test_igor_checkdata(self): 90 96 """ … … 107 113 108 114 self.assertEqual(self.data.detector[0].beam_center_unit, 'mm') 109 center_x = (68.76 -1)*5.0110 center_y = (62.47 -1)*5.0115 center_x = (68.76 - 1)*5.0 116 center_y = (62.47 - 1)*5.0 111 117 self.assertEqual(self.data.detector[0].beam_center.x, center_x) 112 118 self.assertEqual(self.data.detector[0].beam_center.y, center_y) 113 119 114 120 self.assertEqual(self.data.I_unit, '1/cm') 115 self.assertEqual(self.data.data[0], 0.279783) 116 self.assertEqual(self.data.data[1], 0.28951) 117 self.assertEqual(self.data.data[2], 0.167634) 118 121 # 3 points should be suffcient to check that the data is in column 122 # major order. 123 np.testing.assert_almost_equal(self.data.data[0:3], 124 [0.279783, 0.28951, 0.167634]) 125 np.testing.assert_almost_equal(self.data.qx_data[0:3], 126 [-0.01849072, -0.01821785, -0.01794498]) 127 np.testing.assert_almost_equal(self.data.qy_data[0:3], 128 [-0.01677435, -0.01677435, -0.01677435]) 129 130 def test_generic_loader(self): 131 # the generic loader should direct the file to IgorReader as well 132 data = Loader().load("MAR07232_rest.ASC") 133 self.assertEqual(data.meta_data['loader'], "IGOR 2D") 134 135 119 136 class danse_reader(unittest.TestCase): 120 137 -
test/pr_inversion/test/utest_invertor.py
rb699768 r9a5097c 568 568 569 569 def load(path = "sphere_60_q0_2.txt"): 570 import numpy, math, sys 570 import numpy as np 571 import math 572 import sys 571 573 # Read the data from the data file 572 data_x = n umpy.zeros(0)573 data_y = n umpy.zeros(0)574 data_err = n umpy.zeros(0)574 data_x = np.zeros(0) 575 data_y = np.zeros(0) 576 data_err = np.zeros(0) 575 577 scale = None 576 578 if not path == None: … … 589 591 scale = 0.15*math.sqrt(y) 590 592 err = scale*math.sqrt(y) 591 data_x = n umpy.append(data_x, x)592 data_y = n umpy.append(data_y, y)593 data_err = n umpy.append(data_err, err)593 data_x = np.append(data_x, x) 594 data_y = np.append(data_y, y) 595 data_err = np.append(data_err, err) 594 596 except: 595 597 pass -
test/sascalculator/test/utest_sas_gen.py
ref908db r9a5097c 8 8 from sas.sascalc.calculator import sas_gen 9 9 10 import numpy11 12 import os.path13 10 14 11 class sas_gen_test(unittest.TestCase): … … 51 48 self.assertEqual(output.pos_z[0], 0.0) 52 49 50 53 51 if __name__ == '__main__': 54 52 unittest.main() 55 53 -
test/sasdataloader/plugins/test_reader.py
rb699768 r9a5097c 8 8 copyright 2008, University of Tennessee 9 9 """ 10 import numpy, os 10 import os 11 import numpy as np 11 12 from sas.sascalc.dataloader.data_info import Data1D 12 13 … … 40 41 buff = input_f.read() 41 42 lines = buff.split('\n') 42 x = n umpy.zeros(0)43 y = n umpy.zeros(0)44 dy = n umpy.zeros(0)43 x = np.zeros(0) 44 y = np.zeros(0) 45 dy = np.zeros(0) 45 46 output = Data1D(x, y, dy=dy) 46 47 self.filename = output.filename = basename 47 48 48 49 for line in lines: 49 x = n umpy.append(x, float(line))50 x = np.append(x, float(line)) 50 51 51 52 output.x = x -
test/sasdataloader/test/utest_averaging.py
rb699768 r9a5097c 1 1 2 2 import unittest 3 import math 3 4 4 5 from sas.sascalc.dataloader.loader import Loader 5 6 from sas.sascalc.dataloader.manipulations import Ring, CircularAverage, SectorPhi, get_q,reader2D_converter 6 7 import os.path 8 import numpy, math 7 8 import numpy as np 9 9 import sas.sascalc.dataloader.data_info as data_info 10 10 … … 18 18 should return the predefined height of the distribution (1.0). 19 19 """ 20 x_0 = n umpy.ones([100,100])21 dx_0 = n umpy.ones([100,100])20 x_0 = np.ones([100,100]) 21 dx_0 = np.ones([100,100]) 22 22 23 23 self.data = data_info.Data2D(data=x_0, err_data=dx_0) … … 42 42 43 43 self.qstep = len(x_0) 44 x= n umpy.linspace(start= -1*self.qmax,44 x= np.linspace(start= -1*self.qmax, 45 45 stop= self.qmax, 46 46 num= self.qstep, 47 47 endpoint=True ) 48 y = n umpy.linspace(start= -1*self.qmax,48 y = np.linspace(start= -1*self.qmax, 49 49 stop= self.qmax, 50 50 num= self.qstep, -
test/sasdataloader/test/utest_cansas.py
r1686a333 r9a5097c 15 15 import pylint as pylint 16 16 import unittest 17 import numpy 17 import numpy as np 18 18 import logging 19 19 import warnings -
test/sasguiframe/test/utest_manipulations.py
rd85c194 r9a5097c 5 5 6 6 import unittest 7 import numpy, math 7 import math 8 import numpy as np 8 9 from sas.sascalc.dataloader.loader import Loader 9 10 from sas.sasgui.guiframe.dataFitting import Data1D, Data2D … … 52 53 def setUp(self): 53 54 # Create two data sets to play with 54 x_0 = n umpy.ones(5)55 x_0 = np.ones(5) 55 56 for i in range(5): 56 57 x_0[i] = x_0[i]*(i+1.0) 57 58 58 y_0 = 2.0*n umpy.ones(5)59 dy_0 = 0.5*n umpy.ones(5)59 y_0 = 2.0*np.ones(5) 60 dy_0 = 0.5*np.ones(5) 60 61 self.data = Data1D(x_0, y_0, dy=dy_0) 61 62 62 63 x = self.data.x 63 y = n umpy.ones(5)64 dy = n umpy.ones(5)64 y = np.ones(5) 65 dy = np.ones(5) 65 66 self.data2 = Data1D(x, y, dy=dy) 66 67 … … 155 156 def setUp(self): 156 157 # Create two data sets to play with 157 x_0 = 2.0*n umpy.ones(25)158 dx_0 = 0.5*n umpy.ones(25)159 qx_0 = n umpy.arange(25)160 qy_0 = n umpy.arange(25)161 mask_0 = n umpy.zeros(25)162 dqx_0 = n umpy.arange(25)/100163 dqy_0 = n umpy.arange(25)/100164 q_0 = n umpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0)158 x_0 = 2.0*np.ones(25) 159 dx_0 = 0.5*np.ones(25) 160 qx_0 = np.arange(25) 161 qy_0 = np.arange(25) 162 mask_0 = np.zeros(25) 163 dqx_0 = np.arange(25)/100 164 dqy_0 = np.arange(25)/100 165 q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 165 166 self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 166 167 qy_data=qy_0, q_data=q_0, mask=mask_0, 167 168 dqx_data=dqx_0, dqy_data=dqy_0) 168 169 169 y = n umpy.ones(25)170 dy = n umpy.ones(25)171 qx = n umpy.arange(25)172 qy = n umpy.arange(25)173 mask = n umpy.zeros(25)174 q = n umpy.sqrt(qx * qx + qy * qy)170 y = np.ones(25) 171 dy = np.ones(25) 172 qx = np.arange(25) 173 qy = np.arange(25) 174 mask = np.zeros(25) 175 q = np.sqrt(qx * qx + qy * qy) 175 176 self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy, 176 177 q_data=q, mask=mask) … … 182 183 """ 183 184 # There should be 5 entries in the file 184 self.assertEqual(n umpy.size(self.data.data), 25)185 self.assertEqual(np.size(self.data.data), 25) 185 186 186 187 for i in range(25): … … 263 264 def setUp(self): 264 265 # Create two data sets to play with 265 x_0 = 2.0*n umpy.ones(25)266 dx_0 = 0.5*n umpy.ones(25)267 qx_0 = n umpy.arange(25)268 qy_0 = n umpy.arange(25)269 mask_0 = n umpy.zeros(25)270 dqx_0 = n umpy.arange(25)/100271 dqy_0 = n umpy.arange(25)/100272 q_0 = n umpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0)266 x_0 = 2.0*np.ones(25) 267 dx_0 = 0.5*np.ones(25) 268 qx_0 = np.arange(25) 269 qy_0 = np.arange(25) 270 mask_0 = np.zeros(25) 271 dqx_0 = np.arange(25)/100 272 dqy_0 = np.arange(25)/100 273 q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 273 274 self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 274 275 qy_data=qy_0, q_data=q_0, mask=mask_0, 275 276 dqx_data=dqx_0, dqy_data=dqy_0) 276 277 277 y = n umpy.ones(25)278 dy = n umpy.ones(25)279 qx = n umpy.arange(25)280 qy = n umpy.arange(25)281 mask = n umpy.zeros(25)282 q = n umpy.sqrt(qx * qx + qy * qy)278 y = np.ones(25) 279 dy = np.ones(25) 280 qx = np.arange(25) 281 qy = np.arange(25) 282 mask = np.zeros(25) 283 q = np.sqrt(qx * qx + qy * qy) 283 284 self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy, 284 285 q_data=q, mask=mask) … … 290 291 """ 291 292 # There should be 5 entries in the file 292 self.assertEqual(n umpy.size(self.data.data), 25)293 self.assertEqual(np.size(self.data.data), 25) 293 294 294 295 for i in range(25): -
test/sasinvariant/test/utest_data_handling.py
rb699768 r9a5097c 9 9 """ 10 10 import unittest 11 import numpy, math 11 import math 12 import numpy as np 12 13 from sas.sascalc.dataloader.loader import Loader 13 14 from sas.sascalc.dataloader.data_info import Data1D … … 20 21 """ 21 22 def setUp(self): 22 x = n umpy.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.])23 y = n umpy.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.])23 x = np.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 24 y = np.asarray([1.,2.,3.,4.,5.,6.,7.,8.,9.]) 24 25 dy = y/10.0 25 26 … … 135 136 136 137 def test_error_treatment(self): 137 x = n umpy.asarray(numpy.asarray([0,1,2,3]))138 y = n umpy.asarray(numpy.asarray([1,1,1,1]))138 x = np.asarray(np.asarray([0,1,2,3])) 139 y = np.asarray(np.asarray([1,1,1,1])) 139 140 140 141 # These are all the values of the dy array that would cause … … 340 341 self.scale = 1.5 341 342 self.rg = 30.0 342 x = n umpy.arange(0.0001, 0.1, 0.0001)343 y = n umpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x])343 x = np.arange(0.0001, 0.1, 0.0001) 344 y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 344 345 dy = y*.1 345 346 self.data = Data1D(x=x, y=y, dy=dy) … … 383 384 self.scale = 1.5 384 385 self.m = 3.0 385 x = n umpy.arange(0.0001, 0.1, 0.0001)386 y = n umpy.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x])386 x = np.arange(0.0001, 0.1, 0.0001) 387 y = np.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x]) 387 388 dy = y*.1 388 389 self.data = Data1D(x=x, y=y, dy=dy) … … 427 428 that can't be transformed 428 429 """ 429 x = n umpy.asarray(numpy.asarray([0,1,2,3]))430 y = n umpy.asarray(numpy.asarray([1,1,1,1]))430 x = np.asarray(np.asarray([0,1,2,3])) 431 y = np.asarray(np.asarray([1,1,1,1])) 431 432 g = invariant.Guinier() 432 433 data_in = Data1D(x=x, y=y) … … 438 439 439 440 def test_allowed_bins(self): 440 x = n umpy.asarray(numpy.asarray([0,1,2,3]))441 y = n umpy.asarray(numpy.asarray([1,1,1,1]))442 dy = n umpy.asarray(numpy.asarray([1,1,1,1]))441 x = np.asarray(np.asarray([0,1,2,3])) 442 y = np.asarray(np.asarray([1,1,1,1])) 443 dy = np.asarray(np.asarray([1,1,1,1])) 443 444 g = invariant.Guinier() 444 445 data = Data1D(x=x, y=y, dy=dy) … … 465 466 self.scale = 1.5 466 467 self.rg = 30.0 467 x = n umpy.arange(0.0001, 0.1, 0.0001)468 y = n umpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x])468 x = np.arange(0.0001, 0.1, 0.0001) 469 y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 469 470 dy = y*.1 470 471 self.data = Data1D(x=x, y=y, dy=dy) … … 513 514 self.scale = 1.5 514 515 self.rg = 30.0 515 x = n umpy.arange(0.0001, 0.1, 0.0001)516 y = n umpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x])516 x = np.arange(0.0001, 0.1, 0.0001) 517 y = np.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 517 518 dy = y*.1 518 519 self.data = Data1D(x=x, y=y, dy=dy) … … 600 601 self.scale = 1.5 601 602 self.m = 3.0 602 x = n umpy.arange(0.0001, 0.1, 0.0001)603 y = n umpy.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x])603 x = np.arange(0.0001, 0.1, 0.0001) 604 y = np.asarray([self.scale * math.pow(q ,-1.0*self.m) for q in x]) 604 605 dy = y*.1 605 606 self.data = Data1D(x=x, y=y, dy=dy) -
test/sasinvariant/test/utest_use_cases.py
rb699768 r9a5097c 5 5 #TODO: there's no test for smeared extrapolation 6 6 import unittest 7 import numpy8 7 from sas.sascalc.dataloader.loader import Loader 9 8
Note: See TracChangeset
for help on using the changeset viewer.