Changeset c125e0c in sasview for DataLoader/test
- Timestamp:
- Jul 2, 2008 10:39:39 AM (16 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 9e85792
- Parents:
- 70e9610
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/test/testLoad.py
raa749ac rc125e0c 8 8 from DataLoader.loader import Loader 9 9 from DataLoader.readers import TXT3_Reader,TXT2_Reader 10 from DataLoader.readers import DataReader,danse_reader,tiff_reader10 from DataLoader.readers import IgorReader,danse_reader,tiff_reader 11 11 12 12 class testLoader(unittest.TestCase): 13 13 """ test fitting """ 14 def testLoad(self): 15 """ 16 test module Load 17 """ 18 #Creating a loader 19 L=Loader() 20 21 #creating readers 22 read1=TXT2_Reader.Reader() 23 read2=TXT3_Reader.Reader() 24 read3=DataReader.Reader() 25 read4=danse_reader.Reader() 26 read5=tiff_reader.Reader() 27 #for each readers set an extensions inside the loader 28 L.__setitem__('.txt',read1) 29 L.__setitem__('.dat',read1) 30 L.__setitem__('.txt',read2) 31 L.__setitem__('.dat',read2) 32 L.__setitem__('.ASC',read3) 33 L.__setitem__('.sans',read4) 34 L.__setitem__('.tif',read5) 35 L.__setitem__('.jpg',read5) 36 L.__setitem__('.png',read5) 37 L.__setitem__('.jpeg',read5) 38 L.__setitem__('.gif',read5) 39 L.__setitem__('.bmp',read5) 40 41 #test reading empty file 42 self.assertEqual(L.load('empty.txt'),None) 14 #Creating a loader 15 L=Loader() 16 17 #creating readers 18 read1=TXT2_Reader.Reader() 19 read2=TXT3_Reader.Reader() 20 read3=IgorReader.Reader() 21 read4=danse_reader.Reader() 22 read5=tiff_reader.Reader() 23 #for each readers set an extensions inside the loader 24 L.__setitem__('.txt',read2) 25 L.__setitem__('.txt',read1) 26 L.__setitem__('.dat',read1) 27 28 L.__setitem__('.dat',read2) 29 L.__setitem__('.ASC',read3) 30 L.__setitem__('.sans',read4) 31 L.__setitem__('.tif',read5) 32 L.__setitem__('.jpg',read5) 33 L.__setitem__('.png',read5) 34 L.__setitem__('.jpeg',read5) 35 L.__setitem__('.gif',read5) 36 L.__setitem__('.bmp',read5) 37 38 def testLoad1(self): 39 """test reading empty file, no file can read it""" 40 self.assertEqual(self.L.load('empty.txt'),None) 41 self.assertEqual( self.L.getAcTReader('empty.txt'),None) 43 42 44 # print L.loadData('test_2_columns.txt')45 xload,yload,dyload= L.load('test_2_columns.txt')46 x=[ .83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265]43 #Testing loading a txt file of 2 columns, the only reader should be read1 44 xload,yload,dyload=self.L.load('test_2_columns.txt') 45 x=[2.83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265] 47 46 y=[0.6,3.44938, 5.82026,5.27591,5.2781,5.22531,7.47487,7.85852,10.2278] 48 47 dx=[] … … 50 49 self.assertEqual(len(xload),len(x)) 51 50 self.assertEqual(len(yload),len(y)) 52 self.assertEqual( L.getAcTReader('test_2_columns.txt'),DataLoader.readers.TXT2_Reader.Reader) 51 self.assertEqual(len(dyload),0) 52 for i in range(len(x)): 53 self.assertEqual(xload[i],x[i]) 54 self.assertEqual(yload[i],y[i]) 55 self.assertEqual( self.L.getAcTReader('test_2_columns.txt'),self.read1.__class__) 56 57 def testLoad2(self): 58 """Testing loading a txt file of 3 columns, the only reader should be read2""" 59 xload,yload,dyload= self.L.load('test_3_columns.txt') 60 x=[0,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449] 61 y=[2.83954,3.44938,5.82026,5.27591,5.2781,5.22531,7.47487] 62 dx=[] 63 dy=[0.6,0.676531,0.753061,0.829592,0.906122,0.982653,1.05918] 64 self.assertEqual(len(xload),len(x)) 65 self.assertEqual(len(yload),len(y)) 66 self.assertEqual(len(dyload),len(dy)) 67 for i in range(len(x)): 68 self.assertEqual(xload[i],x[i]) 69 self.assertEqual(yload[i],y[i]) 70 self.assertEqual(dyload[i],dy[i]) 71 self.assertEqual(self.L.getAcTReader('test_3_columns.txt'),self.read2.__class__) 72 73 def testload3(self): 74 """ Testing loading Igor data""" 75 #tested good file.asc 76 Z,xmin, xmax, ymin, ymax= self.L.load('MAR07232_rest.ASC') 77 self.assertEqual(xmin,-0.018558945804750416) 78 self.assertEqual(xmax, 0.016234058202440633,) 79 self.assertEqual(ymin,-0.01684257151702391) 80 self.assertEqual(ymax,0.017950440578015116) 81 self.assertEqual(self.L.getAcTReader('MAR07232_rest.ASC'),self.read3.__class__) 82 #tested corrupted file.asc 83 self.assertEqual(self.L.load('AR07232_rest.ASC') ,None) 84 85 def testload4(self): 86 """ Testing loading danse file""" 87 #tested good file.sans 88 data=self.L.load('MP_New.sans') 89 90 self.assertEqual(data.__class__,danse_reader.ReaderInfo) 91 self.assertEqual(self.L.getAcTReader('MP_New.sans'),self.read4.__class__) 92 #tested corrupted file.sans 93 self.assertEqual(self.L.load('P_New.sans'),None) 94 95 def testload5(self): 96 """ Testing loading image file""" 97 data=self.L.load('angles_flat.png') 98 self.assertEqual(data.__class__,tiff_reader.ReaderInfo) 99 self.assertEqual(self.L.getAcTReader('angles_flat.png'),self.read5.__class__) 53 100 54 101 55 56 57
Note: See TracChangeset
for help on using the changeset viewer.