Changeset 574adc7 in sasview for src/sas/sascalc/pr/fit/Loader.py
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/pr/fit/Loader.py
ra1b8fee r574adc7 18 18 self.dy = dy 19 19 self.filename = None 20 20 21 21 def set_filename(self, path=None): 22 22 """ 23 Store path into a variable.If the user doesn't give 23 Store path into a variable.If the user doesn't give 24 24 a path as a parameter a pop-up 25 25 window appears to select the file. 26 26 27 27 :param path: the path given by the user 28 28 29 29 """ 30 30 self.filename = path 31 31 32 32 def get_filename(self): 33 33 """ return the file's path""" 34 34 return self.filename 35 35 36 36 def set_values(self): 37 37 """ Store the values loaded from file in local variables""" … … 42 42 self.x = [] 43 43 self.y = [] 44 self.dx = [] 44 self.dx = [] 45 45 self.dy = [] 46 46 for line in lines: … … 50 50 y = float(toks[1]) 51 51 dy = float(toks[2]) 52 52 53 53 self.x.append(x) 54 54 self.y.append(y) … … 59 59 # Sanity check 60 60 if not len(self.x) == len(self.dx): 61 raise ValueError , "x and dx have different length"61 raise ValueError("x and dx have different length") 62 62 if not len(self.y) == len(self.dy): 63 raise ValueError , "y and dy have different length"64 65 63 raise ValueError("y and dy have different length") 64 65 66 66 def get_values(self): 67 67 """ Return x, y, dx, dy""" 68 68 return self.x, self.y, self.dx, self.dy 69 69 70 70 def load_data(self, data): 71 71 """ Return plottable""" … … 77 77 #Load its View class 78 78 #plottable.reset_view() 79 80 81 if __name__ == "__main__": 79 80 81 if __name__ == "__main__": 82 82 load = Load() 83 83 load.set_filename("testdata_line.txt") 84 print(load.get_filename()) 84 print(load.get_filename()) 85 85 load.set_values() 86 86 print(load.get_values()) 87 88 87
Note: See TracChangeset
for help on using the changeset viewer.