Changeset 9d819e2 in sasview
- Timestamp:
- Oct 28, 2017 4:27:46 PM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 0be6b6b
- Parents:
- c58d856 (diff), 3ca67dcf (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. - Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/source/conf.py
rf80b416e r3ca67dcf 78 78 # 79 79 # The short X.Y version. 80 version = '4. 1'80 version = '4.2' 81 81 # The full version, including alpha/beta/rc tags. 82 release = '4. 1.2'82 release = '4.2.0' 83 83 84 84 # The language for content autogenerated by Sphinx. Refer to documentation -
src/sas/sascalc/dataloader/file_reader_base_class.py
r9e6aeaf r1576693 85 85 86 86 # Return a list of parsed entries that data_loader can manage 87 return self.output 87 final_data = self.output 88 self.reset_state() 89 return final_data 90 91 def reset_state(self): 92 """ 93 Resets the class state to a base case when loading a new data file so previous 94 data files do not appear a second time 95 """ 96 self.current_datainfo = None 97 self.current_dataset = None 98 self.output = [] 88 99 89 100 def nextline(self): -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r2b538cd r61f329f0 68 68 data files do not appear a second time 69 69 """ 70 self.current_datainfo = None 71 self.current_dataset = None 72 self.current_data1d = None 70 super(Reader, self).reset_state() 73 71 self.data = [] 74 72 self.process = Process() … … 79 77 self.names = [] 80 78 self.cansas_defaults = {} 81 self.output = []82 79 self.ns_list = None 83 80 self.logging = [] -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r2b538cd r61f329f0 65 65 """ 66 66 # Reinitialize when loading a new data file to reset all class variables 67 self.reset_ class_variables()67 self.reset_state() 68 68 69 69 filename = self.f_open.name … … 101 101 raise FileContentsException("Fewer than 5 data points found.") 102 102 103 def reset_ class_variables(self):103 def reset_state(self): 104 104 """ 105 105 Create the reader object and define initial states for class variables 106 106 """ 107 self.current_datainfo = None 108 self.current_dataset = None 107 super(Reader, self).reset_state() 109 108 self.data1d = [] 110 109 self.data2d = [] … … 112 111 self.errors = set() 113 112 self.logging = [] 114 self.output = []115 113 self.parent_class = u'' 116 114 self.detector = Detector() -
src/sas/sasview/__init__.py
r6a88ad9 r3ca67dcf 1 __version__ = "4. 1"1 __version__ = "4.2.0" 2 2 __build__ = "GIT_COMMIT" -
test/sasdataloader/test/utest_abs_reader.py
r574adc7 rfe15198 20 20 def setUp(self): 21 21 reader = AbsReader() 22 data= reader.read("jan08002.ABS")23 self.data = data[0]22 self.data_list = reader.read("jan08002.ABS") 23 self.data = self.data_list[0] 24 24 25 25 def test_abs_checkdata(self): … … 76 76 def setUp(self): 77 77 reader = DANSEReader() 78 data= reader.read("MP_New.sans")79 self.data = data[0]78 self.data_list = reader.read("MP_New.sans") 79 self.data = self.data_list[0] 80 80 81 81 def test_checkdata(self): … … 87 87 tests won't pass 88 88 """ 89 self.assertEqual(len(self.data_list), 1) 89 90 self.assertEqual(self.data.filename, "MP_New.sans") 90 91 self.assertEqual(self.data.meta_data['loader'], "DANSE") … … 114 115 # the generic loader should work as well 115 116 data = Loader().load("MP_New.sans") 117 self.assertEqual(len(data), 1) 116 118 self.assertEqual(data[0].meta_data['loader'], "DANSE") 117 119 … … 121 123 def setUp(self): 122 124 reader = CANSASReader() 123 data= reader.read("cansas1d.xml")124 self.data = data[0]125 self.data_list = reader.read("cansas1d.xml") 126 self.data = self.data_list[0] 125 127 126 128 def test_generic_loader(self): 127 129 # the generic loader should work as well 128 130 data = Loader().load("cansas1d.xml") 131 self.assertEqual(len(data), 1) 129 132 self.assertEqual(data[0].meta_data['loader'], "CanSAS XML 1D") 130 133 … … 141 144 tests won't pass 142 145 """ 146 self.assertEqual(len(self.data_list), 1) 143 147 self.assertEqual(self.data.run[0], "1234") 144 148 self.assertEqual(self.data.meta_data['loader'], "CanSAS XML 1D") … … 281 285 data = Loader().load(filename) 282 286 self.data = data[0] 287 self.assertEqual(len(data), 1) 283 288 self.assertEqual(self.data.filename, filename) 284 289 self._checkdata() … … 294 299 data = CANSASReader().read(filename) 295 300 self.data = data[0] 301 self.assertEqual(len(data), 1) 296 302 self.assertEqual(self.data.filename, filename) 297 303 self._checkdata() … … 305 311 data = CANSASReader().read(filename) 306 312 self.data = data[0] 313 self.assertEqual(len(data), 1) 307 314 self.assertEqual(self.data.filename, filename) 308 315 # The followed should not have been loaded … … 321 328 data = CANSASReader().read(filename) 322 329 self.data = data[0] 330 self.assertEqual(len(data), 1) 331 self.assertEqual(len(self.data_list), 1) 323 332 self.assertEqual(self.data.filename, filename) 324 333 self.assertEqual(self.data.run[0], "1234") -
test/sasdataloader/test/utest_ascii.py
ra78a02f rfe15198 29 29 """ 30 30 # The length of the data is 10 31 self.assertEqual(len(self.f1_list), 1) 32 self.assertEqual(len(self.f2_list), 1) 33 self.assertEqual(len(self.f3_list), 1) 34 self.assertEqual(len(self.f4_list), 1) 35 self.assertEqual(len(self.f5_list), 1) 31 36 self.assertEqual(len(self.f1.x), 10) 32 37 self.assertEqual(self.f1.x[0],0.002618) -
test/sasdataloader/test/utest_averaging.py
r2a52b0e rfe15198 104 104 filepath = os.path.join(os.path.dirname( 105 105 os.path.realpath(__file__)), 'MAR07232_rest.h5') 106 self.data = Loader().load(filepath)[0] 106 self.data_list = Loader().load(filepath) 107 self.data = self.data_list[0] 107 108 108 109 def test_ring(self): … … 119 120 filepath = os.path.join(os.path.dirname( 120 121 os.path.realpath(__file__)), 'ring_testdata.txt') 121 answer = Loader().load(filepath)[0] 122 122 answer_list = Loader().load(filepath) 123 answer = answer_list[0] 124 125 self.assertEqual(len(answer_list), 1) 123 126 for i in range(r.nbins_phi - 1): 124 127 self.assertAlmostEqual(o.x[i + 1], answer.x[i], 4) -
test/sasdataloader/test/utest_generic_file_reader_class.py
rbeba407 r3648cbf 17 17 18 18 def setUp(self): 19 self.reader = FileReader()19 self.reader = TestFileReader() 20 20 self.bad_file = "ACB123.txt" 21 21 self.good_file = "123ABC.txt" 22 self.msg = "Unable to find file at: {}\n".format(self.bad_file)23 self.msg += "Please check your file path and try again."24 x = np.zeros(0)25 y = np.zeros(0)26 self.reader.current_dataset = plottable_1D(x, y)27 self.reader.current_datainfo = DataInfo()28 self.reader.send_to_output()29 22 30 23 def test_bad_file_path(self): 31 24 output = self.reader.read(self.bad_file) 32 self.assertEqual(len(output[0].errors), 1) 33 self.assertEqual(output[0].errors[0], self.msg) 25 self.assertEqual(output, []) 34 26 35 27 def test_good_file_path(self): 36 f_open = open(self.good_file, 'w') 37 f_open.close() 28 f = open(self.good_file, 'w') 29 f.write('123ABC exists!') 30 f.close() 38 31 output = self.reader.read(self.good_file) 39 self.assertEqual(len(output [0].errors), 1)40 self.assertEqual(output[0]. errors[0], self.msg)32 self.assertEqual(len(output), 1) 33 self.assertEqual(output[0].meta_data["blah"], '123ABC exists!') 41 34 42 35 def tearDown(self): … … 45 38 if os.path.isfile(self.good_file): 46 39 os.remove(self.good_file) 40 41 class TestFileReader(FileReader): 42 def get_file_contents(self): 43 """ 44 Reader specific class to access the contents of the file 45 All reader classes that inherit from FileReader must implement 46 """ 47 x = np.zeros(0) 48 y = np.zeros(0) 49 self.current_dataset = plottable_1D(x,y) 50 self.current_datainfo = DataInfo() 51 self.current_datainfo.meta_data["blah"] = self.nextline() 52 self.send_to_output() -
test/sasdataloader/test/utest_red2d_reader.py
r248ff73 rfe15198 14 14 def setUp(self): 15 15 self.loader = Loader() 16 self.data_list = self.loader.load("exp18_14_igor_2dqxqy.dat") 16 17 17 18 def test_checkdata(self): … … 19 20 Test .DAT file loaded as IGOR/DAT 2D Q_map 20 21 """ 21 f = self. loader.load("exp18_14_igor_2dqxqy.dat")[0]22 f = self.data_list[0] 22 23 # The length of the data is 10 24 self.assertEqual(len(self.data_list), 1) 23 25 self.assertEqual(len(f.qx_data), 36864) 24 26 self.assertEqual(f.qx_data[0],-0.03573497) -
test/sasdataloader/test/utest_sesans.py
ra78a02f rfe15198 22 22 f = file[0] 23 23 # self.assertEqual(f, 5) 24 self.assertEqual(len(file), 1) 24 25 self.assertEqual(len(f.x), 40) 25 26 self.assertEqual(f.x[0], 391.56) … … 39 40 file = self.loader("sesans_examples/sphere_isis.ses") 40 41 f = file[0] 42 self.assertEqual(len(file), 1) 41 43 self.assertEqual(len(f.x), 57) 42 44 self.assertEqual(f.x[-1], 19303.4)
Note: See TracChangeset
for help on using the changeset viewer.