-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backwards import compat. for python 2
- Loading branch information
Showing
4 changed files
with
39 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Sebastian Raschka 01/25/2014 | ||
# PyPrind - Python Progress Indicator module | ||
|
||
from pyprind.pyprind import ProgBar | ||
from pyprind.pyprind import ProgPercent | ||
from .progbar import ProgBar | ||
from .progpercent import ProgPercent |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import sys | ||
import time | ||
|
||
class ProgPercent(): | ||
""" Prints a progress of an computation as percentage to the standard output.""" | ||
|
||
def __init__(self, iterations): | ||
self.cnt = 0 | ||
self.max_iter = float(iterations) # accommodation for Python 2.x users | ||
self.perc = 0 | ||
self.time = [time.clock(), None, None] | ||
self.__print_percent() | ||
|
||
def __calc_percent(self): | ||
return round(self.cnt/self.max_iter * 100) | ||
|
||
def __print_percent(self): | ||
sys.stdout.write('\r[%3d %%]' % (self.perc)) | ||
|
||
def update(self): | ||
self.cnt += 1 | ||
next_perc = self.__calc_percent() | ||
if next_perc > self.perc: | ||
self.perc = next_perc | ||
self.__print_percent() | ||
sys.stdout.flush() | ||
|
||
def finish(self, cpu_time=True): | ||
self.time[1] = time.clock() | ||
self.time[2] = self.time[1] - self.time[0] | ||
sys.stdout.write('\n') | ||
if cpu_time: | ||
print('Time elapsed: {0:.4f} sec'.format(self.time[2])) | ||
|
||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,5 @@ | |
], | ||
license='GPLv3', | ||
long_description = README_TEXT, | ||
extras_require={'testing': ['pytest']}, | ||
platforms='any', | ||
) |