def test_progressbar(self): total = 55 percentage_step = 17 for irun in range(total): progressbar(irun, total)
def test_progressbar(self): total = 55 percentage_step = 17 for irun in range(total): time.sleep(0.005) progressbar(irun, total, percentage_step)
def test_progressbar_float(self): total = 55 for irun in range(total): time.sleep(0.005) progressbar(irun, total, 5.1) for irun in range(2 * total): time.sleep(0.005) progressbar(irun, 2 * total, 0.5)
def test_progressbar_resume(self): total = 55 for irun in range(total): time.sleep(0.005) progressbar(irun, total, 5) for irun in range(2 * total): time.sleep(0.005) progressbar(irun, 2 * total, 10)
def test_progressbar_float(self): total = 55 for irun in range(total): time.sleep(0.005) progressbar(irun, total, 5.1) for irun in range(2*total): time.sleep(0.005) progressbar(irun, 2*total, 0.5)
def test_progressbar_resume(self): total = 55 for irun in range(total): time.sleep(0.005) progressbar(irun, total, 5) for irun in range(2*total): time.sleep(0.005) progressbar(irun, 2*total, 10)
def test_progressbar_logging(self): logger = get_root_logger() total = 33 for irun in range(total): time.sleep(0.005) progressbar(irun, total, logger=logger) for irun in range(total): time.sleep(0.005) progressbar(irun, total, logger='GetLogger')
def show_progress(self, n, total_runs): """Displays a progressbar""" if self.report_progress: percentage, logger_name, log_level = self.report_progress if logger_name == 'print': logger = 'print' else: logger = logging.getLogger(logger_name) if n == -1: # Compute the number of digits and avoid log10(0) digits = int(math.log10(total_runs + 0.1)) + 1 self._format_string = 'PROGRESS: Finished %' + '%d' % digits + 'd/%d runs ' fmt_string = self._format_string % (n + 1, total_runs) + '%s' reprint = log_level == 0 progressbar(n, total_runs, percentage_step=percentage, logger=logger, log_level=log_level, fmt_string=fmt_string, reprint=reprint)
def test_progressbar_w_wo_time(self): total = 55 percentage_step = 17 shows_time = False for irun in range(total): time.sleep(0.005) s = progressbar(irun, total, percentage_step, time=True) if s and 'remaining' in s: shows_time = True self.assertTrue(shows_time) shows_time = False for irun in range(total): time.sleep(0.005) s = progressbar(irun, total, percentage_step, time=False) if s and 'remaining' in s: shows_time = True self.assertFalse(shows_time)