Skip to content

Commit

Permalink
added native print() support
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Feb 17, 2014
1 parent 397acd2 commit 809ce77
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
VERSION 2.3.0
================

- data member self.end stores elapsed time when loop completed


VERSION 2.2.0
================

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ or Twitter: [@rasbt](https://twitter.com/rasbt)
Changelog
==========

**VERSION 2.3.0**

-

**VERSION 2.2.0**

Expand Down
19 changes: 19 additions & 0 deletions examples/ex2_percent_indicator_allargs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sebastian Raschka 01/25/2014
# Progress Bar Examples

import pyprind


def example_2():
n = 1000000
my_per = pyprind.ProgPercent(n, stream=1, track_time=True)
for i in range(n):
# do some computation
my_per.update()
print('Print elapsed time again ...')
print(my_per)

if __name__ == '__main__':
example_2()


19 changes: 19 additions & 0 deletions examples/ex2_progressbar_allargs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sebastian Raschka 01/25/2014
# Progress Bar Examples

import pyprind


def example_2():
n = 1000000
my_bar = pyprind.ProgBar(n, stream=1, track_time=True)
for i in range(n):
# do some computation
my_bar.update()
print('Print elapsed time again ...')
print(my_bar)

if __name__ == '__main__':
example_2()


2 changes: 1 addition & 1 deletion pyprind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
from .progbar import ProgBar
from .progpercent import ProgPercent

__version__ = '2.2.0'
__version__ = '2.3.0'
11 changes: 9 additions & 2 deletions pyprind/prog_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import sys
import os


class Prog():
def __init__(self, iterations, track_time, stream):
self.cnt = 0
self.max_iter = float(iterations) # to support Python 2.x
self.track = track_time
self.start = time.time()
self.end = 0.0
self.stream = stream
self._stream_out = self._no_stream
self._stream_flush = self._no_stream
Expand Down Expand Up @@ -46,6 +46,13 @@ def _no_stream(self, text=None):

def _finish(self):
if self.cnt == self.max_iter:
self.end = self._elapsed()
if self.track:
self._stream_out('\nTotal time elapsed: {:.3f} sec'.format(self._elapsed()))
self._stream_out('\n{}'.format(self.__repr__()))
self._stream_out('\n')

def __repr__(self):
return 'Total time elapsed: {:.3f} sec'.format(self.end)

def __str__(self):
return self.__repr__()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup

setup(name='PyPrind',
version='2.2.0',
version='2.3.0',
description='Python Progress Indicator Utility',
author='Sebastian Raschka',
author_email='[email protected]',
Expand Down

0 comments on commit 809ce77

Please sign in to comment.