[Python-modules-commits] [pyprind] 01/02: New upstream version 2.11.1
Antoine Beaupré
anarcat at moszumanska.debian.org
Sat Dec 30 16:05:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
anarcat pushed a commit to branch master
in repository pyprind.
commit afbf10af519e50d73b212e304f9b14cd4a55a732
Author: Antoine Beaupré <anarcat at debian.org>
Date: Sat Dec 30 11:01:03 2017 -0500
New upstream version 2.11.1
---
CHANGELOG.md | 223 +++++++++++++++++++++++
CONTRIBUTING.md | 41 +++++
LICENSE | 28 +++
MANIFEST.in | 6 +
PKG-INFO | 34 ++++
PyPrind.egg-info/PKG-INFO | 34 ++++
PyPrind.egg-info/SOURCES.txt | 18 ++
PyPrind.egg-info/dependency_links.txt | 1 +
PyPrind.egg-info/top_level.txt | 1 +
README.md | 328 ++++++++++++++++++++++++++++++++++
pyprind/__init__.py | 20 +++
pyprind/generator_factory.py | 24 +++
pyprind/prog_class.py | 207 +++++++++++++++++++++
pyprind/progbar.py | 97 ++++++++++
pyprind/progpercent.py | 80 +++++++++
requirements.txt | 1 +
setup.cfg | 5 +
setup.py | 61 +++++++
tests/test_percentage_indicator.py | 104 +++++++++++
tests/test_progress_bar.py | 118 ++++++++++++
20 files changed, 1431 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..ae1604d
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,223 @@
+
+Version 2.11.1
+================
+- Flushes both `stdout` and `stderr` prior to `ProgressBar` initialization to avoid cluttering environments with previously cached print statements.
+
+Version 2.11.0
+================
+- Use only 1 line to print the progress bar (instead of the previous too lines)
+
+
+Version 2.10.0
+================
+- Fixes an issue with Jupyter Notebook 4.3.1 when the `ETA` got printed on new lines
+
+
+Version 2.9.9
+================
+- added PyCharm support
+
+
+Version 2.9.8
+================
+- raise `ValueError` if `monitor` is set to `True` and `psutils` is not installed
+
+
+Version 2.9.7
+================
+- requirements.txt for `psutil`, now supports `pip install pyprind -r requirements.txt`
+
+
+Version 2.9.5
+================
+- new `update_interval` parameter to control the update frequency in seconds
+- new `force_flush` parameter to print the progress after every iteration
+
+
+Version 2.9.4
+================
+- new time formatting in hh:mm:ss format (by Divyanshu Sharma, https://github.com/Div44)
+- permissive new BSD license
+
+
+VERSION 2.9.3
+================
+- some PEP8 adjustments and code cleanup
+- new `bar` argument for ProgressBar to use
+ your favorite bar style (by Konstantin Tolstikhin)
+
+
+VERSION 2.9.2
+================
+- support for psutil >= 2.0 and < 2.0.
+- removed psutil from the setup requirements and made it's installation
+ optional via "pip install pyprind -r requirements.txt"
+
+
+VERSION 2.9.1
+================
+- Minor reorganization of the generator interface.
+- Minor changes to the code documentation.
+- Added new test files.
+
+
+VERSION 2.9.0
+================
+- New generator functions for progress bar and percentage indicators via:
+
+ for i in pyprind.prog_bar(range(n)):
+ # do something
+ pass
+
+ for i in pyprind.prog_percent(range(n)):
+ # do something
+ pass
+
+(by Olaf Gladis, https://github.com/hwmrocker)
+
+
+VERSION 2.8.0
+================
+- A new `.stop()` method to stop the progress bar / percentage indicator early.
+- `.update()` method accepts an `item_id` argument now in order to display
+ which item is currently processed next to the progress bar / percentage indicator.
+ E.g.,
+ Job1
+ 0% 100%
+ [####################] | ETA[sec]: 0.000 | Item ID: file_xyz.csv
+
+
+VERSION 2.7.0
+================
+- Version intentionally skipped to not cause confusion that
+ this is a tool exclusively for Python 2.7.
+
+
+VERSION 2.6.2
+================
+- Fixed bug that the report was squeezed after the bar and before the "time elapsed" string if printed immediately after the progress bar has reached 100%.
+
+
+VERSION 2.6.1
+================
+- Small bugfix on some system a warning was printed although
+ a valid output string was provided.
+
+
+VERSION 2.6.0
+================
+- Added IPython Notebook support
+- Fixed to work with most recent psutil v. 0.6 for monitoring CPU and memory usage
+
+
+VERSION 2.5.0
+================
+- New default argument `monitor=False` was added to `ProgBar()` and `ProgPercent()` objects to monitor memory and CPU usage (via `psutil`) if `monitor` is set to True.
+
+
+VERSION 2.4.0
+================
+- Default argument for `.update(iterations=1)` methods to increment the count by more than 1 per
+ iteration.
+
+
+VERSION 2.3.1
+================
+- Minor fix of the output formatting.
+
+
+VERSION 2.3.0
+================
+- Added native print() support
+ prints title and elapsed time of an tracked object after loop completed.
+- Data member self.end stores elapsed time when loop completed.
+- Data member self.title saves title of the tracking objects.
+
+
+VERSION 2.2.0
+================
+- added ETA (estimated time until arrival) tracking to progress bar
+ (by Taylan Aydinli).
+- better support for Python 2.x.
+
+
+
+VERSION 2.1.1
+================
+- Changed visuals of the printed progress for percentage indicators.
+
+
+VERSION 2.1.0
+================
+- added ETA (estimated time until arrival) tracking to percentage indicator
+ (by Taylan Aydinli, https://github.com/taylan)
+
+
+VERSION 2.0.3
+================
+- Accepts a given outputstream for the `stream` parameter.
+
+
+VERSION 2.0.2
+================
+- Fixed bug that occurred for some Python 3.3.3 users
+specifically on Linux Red Hat 4.4.7-1, GCC v. 4.4.7
+that self.max_iter was cast to a float when `ProgBar()`
+object was seeded with n=48.
+
+
+VERSION 2.0.1
+================
+- Fixed packaging of example files.
+
+
+VERSION 2.0.0
+==============
+- ProgBar and ProgPerc inherit data members from parent class Prog
+- Added ProgBar and ProgPerc default argument `stream=2` to write to stderr by
+ default. Set `stream=1` to write to stdout.
+
+ my_prbar = pyprind.ProgBar(n, stream=1) # writes to stdout
+ my_prbar = pyprind.ProgBar(n, stream=2) # writes to stderr, default
+
+- Does not redirect data to the standard output or error stream if program is not
+ outputting to a terminal.
+
+
+VERSION 1.1.1
+==============
+- Fixed problem with packaging of example scripts.
+
+
+VERSION 1.1.0
+===============
+- Added live time tracking to percentage indicator
+- progress bar and percentage indicator complete automatically,
+ .finish() was removed
+
+
+VERSION 1.0.4
+===============
+- Added boundary that .update() can't print over the
+ right progress bar limit.
+- Prints warning when ProgBar seed exits the number of iterations
+ in the loop.
+
+
+VERSION 1.0.3
+===============
+- Reformatting of README files.
+- Minor updates in setup.py file.
+
+
+VERSION 1.0.2
+===============
+- Corrected errors in the README files.
+- Added docstring to the __init__.py
+
+
+VERSION 1.0.1
+===============
+- Added more README formats.
+- Added class descriptions.
+- Added example scripts to the distribution.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..c8f0979
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,41 @@
+# How to Contribute
+
+I would be very happy about any kind of contributions that help to improve and extend the functionality of pyprind.
+
+<br>
+<br>
+
+
+## Getting Started
+
+- If you don't have a [GitHub](https://github.com) account yet, please create one to contribute to this project.
+- Please submit a ticket for your issue to discuss the fix or new feature before too much time and effort is spent for the implementation.
+
+![](./images/contributing/new_issue.png)
+
+- Fork the `pyprind` repository from the GitHub web interface.
+
+![](./images/contributing/fork.png)
+
+- Clone the `pyprind` repository to your local machine
+ - `git clone https://github.com/your_username/pyprind.git`
+
+<br>
+<br>
+
+## Making Changes
+
+- Please avoid working directly on the master branch but create a new feature branch:
+ - `git branch new_feature`
+ - `git checkout new_feature`
+- When you make changes, please provide meaningful `commit` messages:
+ - `git add edited_file`
+ - `git commit -m 'my note'`
+- If it is a new feature, it would be nice (but not necessary) if you could update the documentation.
+- Make an entry in the `CHANGELOG.md` file.
+- Add tests to the `pyprind/tests` directory.
+- Run all tests (e.g., via `nosetests` or `pytest`).
+- Push your changes to a topic branch:
+ - `git push -u origin my_feature`
+- Submit a `pull request` from your forked repository via the GitHub web interface.
+![](./images/contributing/pull_request.png)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..049fbf0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2014-2016, Sebastian Raschka
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of biopandas nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..c5d2188
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+include LICENSE
+include README.md
+include CONTRIBUTING.md
+include CHANGELOG.md
+include requirements.txt
+include tests/*
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..9d8c95a
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,34 @@
+Metadata-Version: 1.1
+Name: PyPrind
+Version: 2.11.1
+Summary: Python Progress Bar and Percent Indicator Utility
+Home-page: https://github.com/rasbt/pyprind
+Author: Sebastian Raschka
+Author-email: mail at sebastianraschka.com
+License: BSD 3-Clause
+Description:
+
+ The PyPrind (Python Progress Indicator) module provides a progress
+ bar and a percentage indicator
+ object that let you track the progress of a loop structure or
+ other iterative computation.
+ Typical applications include the processing of
+ large data sets to provide an intuitive estimate
+ at runtime about the progress of the computation.
+
+ For more details and examples please see the package documentation
+ https://github.com/rasbt/pyprind/blob/master/README.md.
+
+ Contact
+ =============
+
+ If you have any questions or comments about PyPrind,
+ please feel free to contact me via
+ email: mail at sebastianraschka.com
+ or Twitter: https://twitter.com/rasbt
+Platform: any
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Environment :: Console
diff --git a/PyPrind.egg-info/PKG-INFO b/PyPrind.egg-info/PKG-INFO
new file mode 100644
index 0000000..9d8c95a
--- /dev/null
+++ b/PyPrind.egg-info/PKG-INFO
@@ -0,0 +1,34 @@
+Metadata-Version: 1.1
+Name: PyPrind
+Version: 2.11.1
+Summary: Python Progress Bar and Percent Indicator Utility
+Home-page: https://github.com/rasbt/pyprind
+Author: Sebastian Raschka
+Author-email: mail at sebastianraschka.com
+License: BSD 3-Clause
+Description:
+
+ The PyPrind (Python Progress Indicator) module provides a progress
+ bar and a percentage indicator
+ object that let you track the progress of a loop structure or
+ other iterative computation.
+ Typical applications include the processing of
+ large data sets to provide an intuitive estimate
+ at runtime about the progress of the computation.
+
+ For more details and examples please see the package documentation
+ https://github.com/rasbt/pyprind/blob/master/README.md.
+
+ Contact
+ =============
+
+ If you have any questions or comments about PyPrind,
+ please feel free to contact me via
+ email: mail at sebastianraschka.com
+ or Twitter: https://twitter.com/rasbt
+Platform: any
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Environment :: Console
diff --git a/PyPrind.egg-info/SOURCES.txt b/PyPrind.egg-info/SOURCES.txt
new file mode 100644
index 0000000..158768c
--- /dev/null
+++ b/PyPrind.egg-info/SOURCES.txt
@@ -0,0 +1,18 @@
+CHANGELOG.md
+CONTRIBUTING.md
+LICENSE
+MANIFEST.in
+README.md
+requirements.txt
+setup.py
+PyPrind.egg-info/PKG-INFO
+PyPrind.egg-info/SOURCES.txt
+PyPrind.egg-info/dependency_links.txt
+PyPrind.egg-info/top_level.txt
+pyprind/__init__.py
+pyprind/generator_factory.py
+pyprind/prog_class.py
+pyprind/progbar.py
+pyprind/progpercent.py
+tests/test_percentage_indicator.py
+tests/test_progress_bar.py
\ No newline at end of file
diff --git a/PyPrind.egg-info/dependency_links.txt b/PyPrind.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/PyPrind.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/PyPrind.egg-info/top_level.txt b/PyPrind.egg-info/top_level.txt
new file mode 100644
index 0000000..59a87a3
--- /dev/null
+++ b/PyPrind.egg-info/top_level.txt
@@ -0,0 +1 @@
+pyprind
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7382344
--- /dev/null
+++ b/README.md
@@ -0,0 +1,328 @@
+[![Build Status](https://travis-ci.org/rasbt/pyprind.svg?branch=master)](https://travis-ci.org/rasbt/pyprind)
+[![Code Health](https://landscape.io/github/rasbt/pyprind/master/landscape.svg?style=flat)](https://landscape.io/github/rasbt/pyprind/master)
+[![Coverage Status](https://coveralls.io/repos/rasbt/pyprind/badge.svg?branch=master&service=github)](https://coveralls.io/github/rasbt/pyprind?branch=master)
+![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)
+![Python 3.5](https://img.shields.io/badge/python-3.5-blue.svg)
+[![PyPI version](https://badge.fury.io/py/pyprind.svg)](http://badge.fury.io/py/pyprind)
+[![License](https://img.shields.io/badge/license-new%20BSD-blue.svg)](https://github.com/rasbt/pyprind/blob/master/LICENSE.txt)
+
+
+
+# PyPrind (Python Progress Indicator)
+
+
+The `PyPrind` (Python Progress Indicator) module provides a **progress bar** and a
+**percentage indicator** object that let you track the progress of a loop structure or other iterative computation.
+Typical applications include the processing of large data sets to provide an intuitive estimate
+at runtime about the progress of the computation.
+
+
+
+![PyPrind Demo](./images/pyprind-1.gif "PyPrind Demo")
+
+<br>
+
+#### Progress Bars and Percentage Generators
+
+```python
+import pyprind
+
+for i in pyprind.prog_bar(range(n)):
+ time.sleep(timesleep) # your computation here
+```
+```
+0% 100%
+[##############################] | ETA: 00:00:00
+Total time elapsed: 00:00:05
+```
+
+<br>
+<br>
+
+```python
+for i in pyprind.prog_percent(range(n)):
+ time.sleep(timesleep) # your computation here
+```
+
+```
+[10 %] Time elapsed: 00:00:01 | ETA: 00:00:04
+```
+
+#### While-loops
+
+The `ProgBar` and `ProgPercent` classes also support while loops if desired.
+The objects are updated inside the loop using the `update` method as shown below:
+
+```python
+import random
+import pyprind
+import time
+
+timesleep = 0.05
+random.seed(1)
+collection = set()
+
+n = 100
+bar = pyprind.ProgBar(n, track_time=False, title='while example')
+
+while len(collection) < n:
+ r = random.randint(0, 10**5)
+ if r % 7 and r not in collection:
+ collection.add(r)
+ bar.update()
+ time.sleep(timesleep)
+
+print(bar)
+```
+```
+while example
+0% 100%
+[##############################]
+Title: while example
+ Started: 09/07/2016 13:06:58
+ Finished: 09/07/2016 13:07:03
+ Total time elapsed: 00:00:05
+```
+
+
+<br>
+<br>
+
+<a id='advanced_tracking'>
+
+#### Advanced Tracking
+
+If you have the `psutil` package installed, you can set the `monitor=True` to track CPU and memory usage:
+
+```python
+bar = pyprind.ProgBar(n, monitor=True)
+for i in range(n):
+ time.sleep(timesleep) # your computation here
+ bar.update()
+print(bar)
+```
+
+```
+0% 100%
+[##############################] | ETA: 00:00:00
+Total time elapsed: 00:00:05
+Title:
+ Started: 09/07/2016 13:14:09
+ Finished: 09/07/2016 13:14:14
+ Total time elapsed: 00:00:05
+ CPU %: 1.90
+ Memory %: 0.48
+```
+
+<br>
+<br>
+
+#### Choose Your Favorite Bar Style
+
+```python
+bar = pyprind.ProgBar(n, bar_char='█')
+for i in range(n):
+ time.sleep(0.1) # do some computation
+ bar.update()
+```
+
+```
+0% 100%
+[██████████████████████████████] | ETA: 00:00:00
+Total time elapsed: 00:00:10
+```
+
+#### Note to PyCharm users
+
+If you are using the PyCharm IDE, you need to pass the `sys.stdout` or `sys.err`
+as a `stream` argument to display the progress indicators correctly in the IDE. For example,
+
+```python
+import sys
+
+bar = pyprind.ProgBar(n, stream=sys.stdout)
+for i in range(n):
+ time.sleep(0.1) # do some computation
+ bar.update()
+```
+
+<br>
+<br>
+
+###[View more examples in an IPython Demo Notebook](http://nbviewer.ipython.org/github/rasbt/pyprind/blob/master/examples/pyprind_demo.ipynb)
+
+
+<br>
+<br>
+
+
+<a id='sections'>
+
+# Sections
+
+
+- [Installation](#installation)
+- [Documentation](#documentation)
+- [Examples](#examples)
+- [Contact](#contact)
+- [Changelog](https://raw.githubusercontent.com/rasbt/pyprind/master/CHANGELOG.txt)
+
+
+<p><a id="installation"></a></p>
+
+<br>
+<br>
+<br>
+
+# Installation
+
+[[back to top](#sections)]
+
+The most convenient way to install PyPrind is via tools like `pip` or `easy_install`:
+
+- `pip install pyprind`
+
+- `easy_install pyprind`
+
+
+
+PyPrind comes without any dependencies except for the optional [psutil](https://pypi.python.org/pypi/psutil) to [monitor CPU and memory usages](#advanced_tracking). You can install `psutil` via `pip install psutil` or install it automatically with PyPrind:
+ `pip install pyprind -r requirements.txt`
+
+
+
+Alternatively, you can install PyPrind the classic way: Download the package from the Python Package Index [https://pypi.python.org/pypi/PyPrind](https://pypi.python.org/pypi/PyPrind), unzip it,
+navigate into the unzipped directory, and use the command
+
+`python setup.py install`
+
+
+
+
+<p><a id="documentation"></a></p>
+<br>
+<br>
+<br>
+
+# Documentation
+
+[[back to top](#sections)]
+
+
+
+PyPrind consists of two class objects that can visualize the progress of a computation on the output screen.
+Progress bars are available via `ProgBar`, and percentage indicators can be used via a `ProgPercent`.
+
+```python
+ n = 10000000
+ bar = pyprind.ProgBar(n) # 1) initialization with number of iterations
+ for i in range(n):
+ # do some computation
+ bar.update() # 2) update the progress visualization
+```
+
+Alternatively, the progress can be tracked via the equivalent generator functions `prog_bar` and `prog_percent`:
+
+```python
+ for i in pyprind.prog_bar(range(n)):
+ # do something
+ pass
+```
+
+
+<br>
+
+#### Complete Parameter of Parameters and Options
+
+##### ProgBar
+
+*`ProgBar(iterations, track_time=True, width=30, bar_char='#',
+ stream=2, title='', monitor=False, update_interval=None))`*
+
+- iterations : `int`
+ Number of iterations for the iterative computation.
+- track_time : `bool` (default: `True`)
+ Prints elapsed time when loop has finished.
+- width : `int` (default: 30)
+ Sets the progress bar width in characters.
+- stream : `int` (default: 2).
+ Setting the output stream.
+ Takes `1` for stdout, `2` for stderr, or a custom stream object
+- title : `str` (default: `''`)
+ Setting a title for the progress bar.
+- monitor : `bool` (default: `False`)
+ Monitors CPU and memory usage if `True` (requires `psutil` package).
+- update_interval : float or int (default: `None`)
+ The update_interval in seconds controls how often the progress
+ is flushed to the screen.
+ Automatic mode if `update_interval=None`.
+
+##### ProgPercent
+
+*`ProgPercent(iterations, track_time=True,
+ stream=2, title='', monitor=False, update_interval=None)`*
+
+- iterations : `int`
+ Number of iterations for the iterative computation.
+- track_time : `bool` (default: `True`)
+ Prints elapsed time when loop has finished.
+- stream : `int` (default: 2).
+ Setting the output stream.
+ Takes `1` for stdout, `2` for stderr, or a custom stream object
+- title : `str` (default : `''`).
+ Setting a title for the percentage indicator.
+- monitor : `bool` (default: `False`)
+ Monitors CPU and memory usage if `True` (requires `psutil` package).
+- update_interval : float or int (default: `None`)
+ The update_interval in seconds controls how often the progress
+ is flushed to the screen.
+ Automatic mode if `update_interval=None`.
+
+##### update method
+
+*`update(iterations=1, item_id=None, force_flush=False)`*
+
+- iterations : int (default: `1`)
+ default argument can be changed to integer values
+ `>=1` in order to update the progress indicators more than once
+ per iteration.
+- item_id : str (default: `None`)
+ Print an item_id sring behind the progress bar
+- force_flush : bool (default: `False`)
+ If True, flushes the progress indicator to the output screen
+ in each iteration.
+
+<br>
+
+
+<p><a id="examples"></a></p>
+
+<br>
+<br>
+<br>
+
+# Examples
+
+[[back to top](#sections)]
+
+Examples for using the progress bar and percentage indicator objects can be found in the [IPython Demo Notebook](https://github.com/rasbt/pyprind/blob/master/examples/pyprind_demo.ipynb).
+
+<p><a id="contact"></a></p>
+
+<br>
+<br>
+<br>
+
+
+
+
+# Contact
+
+[[back to top](#sections)]
+
+If you have any questions or comments about `PyPrind`, please feel free to contact me via
+eMail: [mail at sebastianraschka.com](mailto:mail at sebastianraschka.com)
+or Twitter: [@rasbt](https://twitter.com/rasbt)
+
+
+The `pyprind` module is available on GitHub at [https://github.com/rasbt/pyprind](https://github.com/rasbt/pyprind).
diff --git a/pyprind/__init__.py b/pyprind/__init__.py
new file mode 100644
index 0000000..ef454f9
--- /dev/null
+++ b/pyprind/__init__.py
@@ -0,0 +1,20 @@
+"""
+Sebastian Raschka 2014-2017
+Python Progress Indicator Utility
+
+Author: Sebastian Raschka <sebastianraschka.com>
+License: BSD 3 clause
+
+Contributors: https://github.com/rasbt/pyprind/graphs/contributors
+Code Repository: https://github.com/rasbt/pyprind
+PyPI: https://pypi.python.org/pypi/PyPrind
+"""
+
+
+from .progbar import ProgBar
+from .progpercent import ProgPercent
+from .generator_factory import prog_percent
+from .generator_factory import prog_bar
+
+
+__version__ = '2.11.1'
diff --git a/pyprind/generator_factory.py b/pyprind/generator_factory.py
new file mode 100755
index 0000000..fb60c1f
--- /dev/null
+++ b/pyprind/generator_factory.py
@@ -0,0 +1,24 @@
+# PyPrind
+# Author: Sebastian Raschka <mail at sebastianraschka.com>
+# Contributors: https://github.com/rasbt/pyprind/graphs/contributors
+# License: BSD 3 clause
+# Code Repository: https://github.com/rasbt/pyprind
+# PyPI: https://pypi.python.org/pypi/PyPrind
+
+from .progbar import ProgBar
+from .progpercent import ProgPercent
+
+
+def generator_factory(mother_class):
+ def generator_progress(iteritem, iterations=None, *args, **kw):
+ if iterations is None:
+ iterations = len(iteritem)
+ assert iterations
+ mbar = mother_class(iterations, *args, **kw)
+ for item in iteritem:
+ yield item
+ mbar.update()
+ return generator_progress
+
+prog_percent = generator_factory(ProgPercent)
+prog_bar = generator_factory(ProgBar)
diff --git a/pyprind/prog_class.py b/pyprind/prog_class.py
new file mode 100644
index 0000000..6047e88
--- /dev/null
+++ b/pyprind/prog_class.py
@@ -0,0 +1,207 @@
+"""
+Sebastian Raschka 2014-2017
+Python Progress Indicator Utility
+
+Author: Sebastian Raschka <sebastianraschka.com>
+License: BSD 3 clause
+
+Contributors: https://github.com/rasbt/pyprind/graphs/contributors
+Code Repository: https://github.com/rasbt/pyprind
+PyPI: https://pypi.python.org/pypi/PyPrind
+"""
+
+
+import time
+import sys
+import os
+from io import UnsupportedOperation
+
+try:
+ import psutil
+ psutil_import = True
+except ImportError:
+ psutil_import = False
+
+
+class Prog():
+ def __init__(self, iterations, track_time, stream, title,
+ monitor, update_interval=None):
+ """ Initializes tracking object. """
+ self.cnt = 0
+ self.title = title
+ self.max_iter = float(iterations) # to support Python 2.x
+ self.track = track_time
+ self.start = time.time()
+ self.end = None
+ self.item_id = None
+ self.eta = None
+ self.total_time = 0.0
+ self.last_time = self.start
+ self.monitor = monitor
+ self.stream = stream
+ self.active = True
+ self._stream_out = self._no_stream
+ self._stream_flush = self._no_stream
+ self._check_stream()
+ self._print_title()
+ self.update_interval = update_interval
+ self._cached_output = ''
+
+ sys.stdout.flush()
+ sys.stderr.flush()
+
+ if monitor:
+ if not psutil_import:
+ raise ValueError('psutil package is required when using'
+ ' the `monitor` option.')
+ else:
+ self.process = psutil.Process()
+ if self.track:
+ self.eta = 1
+
+ def update(self, iterations=1, item_id=None, force_flush=False):
+ """
+ Updates the progress bar / percentage indicator.
+
+ Parameters
+ ----------
+ iterations : int (default: 1)
+ default argument can be changed to integer values
+ >=1 in order to update the progress indicators more than once
+ per iteration.
+ item_id : str (default: None)
+ Print an item_id sring behind the progress bar
+ force_flush : bool (default: False)
+ If True, flushes the progress indicator to the output screen
+ in each iteration.
+
+ """
+ self.item_id = item_id
+ self.cnt += iterations
+ self._print(force_flush=force_flush)
+ self._finish()
+
+ def stop(self):
+ """Stops the progress bar / percentage indicator if necessary."""
+ self.cnt = self.max_iter
+ self._finish()
+
+ def _check_stream(self):
+ """Determines which output stream (stdout, stderr, or custom) to use"""
+ if self.stream:
+
+ try:
+ supported = ('PYCHARM_HOSTED' in os.environ or
+ os.isatty(sys.stdout.fileno()))
+
+ # a fix for IPython notebook "IOStream has no fileno."
+ except(UnsupportedOperation):
+ supported = True
+
+ else:
+ if self.stream is not None and hasattr(self.stream, 'write'):
+ self._stream_out = self.stream.write
+ self._stream_flush = self.stream.flush
+
+ if supported:
+ if self.stream == 1:
+ self._stream_out = sys.stdout.write
+ self._stream_flush = sys.stdout.flush
+ elif self.stream == 2:
+ self._stream_out = sys.stderr.write
+ self._stream_flush = sys.stderr.flush
+ else:
+ if self.stream is not None and hasattr(self.stream, 'write'):
+ self._stream_out = self.stream.write
+ self._stream_flush = self.stream.flush
+ else:
+ print('Warning: No valid output stream.')
+
+ def _elapsed(self):
+ """ Returns elapsed time at update. """
+ self.last_time = time.time()
+ return self.last_time - self.start
+
+ def _calc_eta(self):
+ """ Calculates estimated time left until completion. """
+ elapsed = self._elapsed()
+ if self.cnt == 0 or elapsed < 0.001:
+ return None
+ rate = float(self.cnt) / elapsed
+ self.eta = (float(self.max_iter) - float(self.cnt)) / rate
+
+ def _calc_percent(self):
+ """Calculates the rel. progress in percent with 2 decimal points."""
+ return round(self.cnt / self.max_iter * 100, 2)
... 581 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyprind.git
More information about the Python-modules-commits
mailing list