Commit d3d4801592b6ffdbf8d0e4c820758438cf1e361e

Authored by Jürgen Knödlseder
1 parent 6d5a07ea

Correct main loop bug that led to a double-execution of the trials in cspull and cstsdist (#2421)

cscripts/cspull.py
@@ -401,14 +401,16 @@ class cspull(ctools.csobservation): @@ -401,14 +401,16 @@ class cspull(ctools.csobservation):
401 self._log_string(gammalib.TERSE, poolresults[seed][1]['log'], False) 401 self._log_string(gammalib.TERSE, poolresults[seed][1]['log'], False)
402 402
403 # Otherwise, loop over trials 403 # Otherwise, loop over trials
404 - for seed in range(self['ntrials'].integer()): 404 + else:
  405 +
  406 + for seed in range(self['ntrials'].integer()):
405 407
406 - # Make a trial and add initial seed  
407 - result = self._trial(seed + self['seed'].integer()) 408 + # Make a trial and add initial seed
  409 + result = self._trial(seed + self['seed'].integer())
408 410
409 - # Write out trial result  
410 - ioutils.write_csv_row(self['outfile'].filename().url(), seed,  
411 - result['colnames'], result['values']) 411 + # Write out trial result
  412 + ioutils.write_csv_row(self['outfile'].filename().url(), seed,
  413 + result['colnames'], result['values'])
412 414
413 # Return 415 # Return
414 return 416 return
cscripts/cstsdist.py
@@ -352,13 +352,15 @@ class cstsdist(ctools.csobservation): @@ -352,13 +352,15 @@ class cstsdist(ctools.csobservation):
352 self._log_string(gammalib.TERSE, poolresults[seed][1]['log'], False) 352 self._log_string(gammalib.TERSE, poolresults[seed][1]['log'], False)
353 353
354 # Otherwise, loop over trials 354 # Otherwise, loop over trials
355 - for seed in range(self['ntrials'].integer()): 355 + else:
  356 +
  357 + for seed in range(self['ntrials'].integer()):
356 358
357 - # Make a trial  
358 - result = self._trial(seed) 359 + # Make a trial
  360 + result = self._trial(seed)
359 361
360 - # Write out trial result  
361 - ioutils.write_csv_row(self['outfile'].filename().url(), seed, 362 + # Write out trial result
  363 + ioutils.write_csv_row(self['outfile'].filename().url(), seed,
362 result['colnames'], result['values']) 364 result['colnames'], result['values'])
363 365
364 # Return 366 # Return