Revisions
-
RyanMillerC revised this gist
May 8, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def __init__( ): """Initialize instance and print process bar at 0 percent completed. :param int total: Total number of cycles to iterate through. :param int iterator: @@ -47,5 +48,4 @@ def update(self): if self.iterator == self.total: sys.stdout.write('\n') sys.stdout.flush() self.iterator += 1 -
RyanMillerC revised this gist
May 7, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def __init__( :param int decimals: Round percent shown to this decimal place. :param int bar_length: Display length of progress bar. """ self.bar_len = bar_length self.decimals = decimals -
RyanMillerC revised this gist
May 7, 2018 . 2 changed files with 50 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ # -*- coding: utf-8 -*- import sys class ProgressBar(): """Printable progress bar. """ def __init__( self, total, iterator=0, prefix='Progress', suffix='Completed', decimals=1, bar_length=50 ): """Initialize instance and print process bar at 0 percent completed. :param int total: Total number of cycles to iterate through. :param int iterator: Current cycle. Typically leave at default value. :param str prefix: Text to prepend before progress bar. :param str suffix: Text to append after progress bar. :param int decimals: Round percent shown to this decimal place. :param int bar_length: """ self.bar_len = bar_length self.decimals = decimals self.iterator = iterator self.prefix = prefix self.suffix = suffix self.total = total self.update() def update(self): """Update progress bar. Call once per cycle. """ str_format = "{0:." + str(self.decimals) + "f}" percents = str_format.format(100 * (self.iterator / float(self.total))) f_length = int(round(self.bar_len * self.iterator / float(self.total))) bar = '█' * f_length + '-' * (self.bar_len - f_length) sys.stdout.write('\r%s |%s| %s%s %s' %(self.prefix, bar, percents, '%', self.suffix)) if self.iterator == self.total: sys.stdout.write('\n') sys.stdout.flush() self.iterator += 1 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +0,0 @@ -
aubricus created this gist
Nov 3, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # -*- coding: utf-8 -*- # Print iterations progress def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100): """ Call in a loop to create terminal progress bar @params: iteration - Required : current iteration (Int) total - Required : total iterations (Int) prefix - Optional : prefix string (Str) suffix - Optional : suffix string (Str) decimals - Optional : positive number of decimals in percent complete (Int) bar_length - Optional : character length of bar (Int) """ str_format = "{0:." + str(decimals) + "f}" percents = str_format.format(100 * (iteration / float(total))) filled_length = int(round(bar_length * iteration / float(total))) bar = '█' * filled_length + '-' * (bar_length - filled_length) sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)), if iteration == total: sys.stdout.write('\n') sys.stdout.flush()