def _setup(self): indx = line_indices(self.cachedlines, PRINTLIB5_HEADER) assert len(indx) == 2 # remove title and next empty line self.mean_start_index = indx[0] + 2 self.line_start_index = indx[1] self.nr_of_entries = 0
def _process(self): if not line_indices(self.cachedlines, "Nuclide Nuclide Nuclide"): raise PypactNotPrintLib5FileException( "Not a valid printlib5 file or SAVELINES was not used, as no spectral data exists.") # off set start index to remove header (column titles are 2 lines) self.mean_start_index = self.mean_start_index + 2 self.nr_of_entries = self.line_start_index - self.mean_start_index
def _setup(self): indx = line_indices(self.cachedlines, PRINTLIB5_HEADER) assert len(indx) == 2 # remove title and next empty line self.mean_start_index = indx[0]+ 2 self.line_start_index = indx[1] self.nr_of_entries = 0
def _process(self): if not line_indices(self.cachedlines, "Nuclide Nuclide Nuclide"): raise PypactNotPrintLib5FileException( "Not a valid printlib5 file or SAVELINES was not used, as no spectral data exists." ) # off set start index to remove header (column titles are 2 lines) self.mean_start_index = self.mean_start_index + 2 self.nr_of_entries = self.line_start_index - self.mean_start_index
def _setup(self): indices = line_indices(self.cachedlines, PRINTLIB4_HEADER) if len(indices) != 1: raise PypactNotPrintLib4FileException( "Not a valid printlib4 file.") sindx = line_indices(self.cachedlines, PRINTLIB4_START_HEADER) if len(sindx) != 1: raise PypactNotPrintLib4FileException( "Not a valid printlib4 file.") eindx = line_indices(self.cachedlines, PRINTLIB4_END_HEADER) if len(eindx) != 1: raise PypactNotPrintLib4FileException( "Not a valid printlib4 file.") # remove title and next empty line self.start_index = sindx[0] + 1 self.end_index = eindx[0]
def __init__(self, filename, asstring=''): """ Cache the file content as a list of strings and process the timesteps :param filename: """ self.cachedlines = (asstring if asstring else content_as_str(filename)) self.lineindices = line_indices(self.cachedlines, TIME_STEP_HEADER) self.timesteps = [] self.irradiation_times = [] self.cooling_times = [] self._processtimesteps()
def test_line_indices(self): self.assertEqual(lines.line_indices(self.teststr, 'This'), [0, 2]) self.assertEqual(lines.line_indices(self.teststr, 'another'), [2]) self.assertEqual(lines.line_indices(self.teststr, 'This is a line'), [0]) self.assertEqual(lines.line_indices(self.teststr, 'This is a lines'), []) self.assertEqual(lines.line_indices(self.teststr, 'This is another line after a space'), []) self.assertEqual(lines.line_indices(self.teststr, 'This is another line after a space'), [2]) self.assertEqual(lines.line_indices(self.teststr, 'blah'), [8]) self.assertEqual(lines.line_indices(self.teststr, 'blah blah'), [8]) self.assertEqual(lines.line_indices(self.teststr, '6'), [6, 8, 14, 20, 26]) self.assertEqual(lines.line_indices(self.teststr, '3'), [3, 6, 8, 20, 26]) self.assertEqual(lines.line_indices(self.teststr, '738.9'), [3]) self.assertEqual(lines.line_indices(self.teststr, '(738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9) '), []) self.assertEqual(lines.line_indices(self.teststr, '!'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' !'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' !and'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' ! '), []) self.assertEqual(lines.line_indices(self.teststr, ' some text '), []) self.assertEqual(lines.line_indices(self.teststr, ' some text. '), [3, 6]) self.assertEqual(lines.line_indices(self.teststr, 'HEADER'), [10, 16, 22]) self.assertEqual(lines.line_indices(self.teststr, 'HEADER2'), [22]) self.assertEqual(lines.line_indices(self.teststr, ' '), [0,2,3,6,8,10,12,14,16,18,20,22,24,26,27]) self.assertEqual(lines.line_indices(self.teststr, '\n'), [])
def _setup(self): self.lineindices = line_indices(self.cachedlines, TIME_STEP_HEADER) self.timesteps = [] self.irradiation_times = [] self.cooling_times = [] self.times = []
def test_line_indices(self): self.assertEqual(lines.line_indices(self.teststr, 'This'), [0, 2]) self.assertEqual(lines.line_indices(self.teststr, 'another'), [2]) self.assertEqual(lines.line_indices(self.teststr, 'This is a line'), [0]) self.assertEqual(lines.line_indices(self.teststr, 'This is a lines'), []) self.assertEqual( lines.line_indices(self.teststr, 'This is another line after a space'), []) self.assertEqual( lines.line_indices(self.teststr, 'This is another line after a space'), [2]) self.assertEqual(lines.line_indices(self.teststr, 'blah'), [8]) self.assertEqual(lines.line_indices(self.teststr, 'blah blah'), [8]) self.assertEqual(lines.line_indices(self.teststr, '6'), [6, 8, 14, 20, 26]) self.assertEqual(lines.line_indices(self.teststr, '3'), [3, 6, 8, 20, 26]) self.assertEqual(lines.line_indices(self.teststr, '738.9'), [3]) self.assertEqual(lines.line_indices(self.teststr, '(738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9)'), [3]) self.assertEqual(lines.line_indices(self.teststr, ' (738.9) '), []) self.assertEqual(lines.line_indices(self.teststr, '!'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' !'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' !and'), [6]) self.assertEqual(lines.line_indices(self.teststr, ' ! '), []) self.assertEqual(lines.line_indices(self.teststr, ' some text '), []) self.assertEqual(lines.line_indices(self.teststr, ' some text. '), [3, 6]) self.assertEqual(lines.line_indices(self.teststr, 'HEADER'), [10, 16, 22]) self.assertEqual(lines.line_indices(self.teststr, 'HEADER2'), [22]) self.assertEqual( lines.line_indices(self.teststr, ' '), [0, 2, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27]) self.assertEqual(lines.line_indices(self.teststr, '\n'), [])