[yt-svn] commit/yt: ngoldbaum: Merged in brittonsmith/yt (pull request #1961)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jan 27 09:08:09 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/ad95e4751bb2/
Changeset:   ad95e4751bb2
Branch:      yt
User:        ngoldbaum
Date:        2016-01-27 17:08:04+00:00
Summary:     Merged in brittonsmith/yt (pull request #1961)

[BUGFIX] progressbar bug
Affected #:  2 files

diff -r f4b8c48fae306ae64e17e5cad882bda4520f077e -r ad95e4751bb23b3a958b77d67ff779c5546c60f1 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -340,10 +340,14 @@
     # This is a drop in replacement for pbar
     # called tqdm
     def __init__(self,title, maxval):
-        self._pbar = tqdm(leave=True,total=maxval,desc=title)
-
-    def update(self,*args,**kwargs):
-        self._pbar.update()
+        self._pbar = tqdm(leave=True, total=maxval, desc=title)
+        self.i = 0
+    def update(self, i=None):
+        if i is None:
+            i = self.i + 1
+        n = i - self.i
+        self.i = i
+        self._pbar.update(n)
     def finish(self):
         self._pbar.close()
 
@@ -385,7 +389,7 @@
     def finish(self):
         self._pbar.Destroy()
 
-def get_pbar(title, maxval):
+def get_pbar(title, maxval, parallel=False):
     """
     This returns a progressbar of the most appropriate type, given a *title*
     and a *maxval*.
@@ -396,7 +400,14 @@
        ytcfg.getboolean("yt", "__withintesting"):
         return DummyProgressBar()
     elif ytcfg.getboolean("yt", "__parallel"):
-        return ParallelProgressBar(title, maxval)
+        # If parallel is True, update progress on root only.
+        if parallel:
+            if is_root():
+                return TqdmProgressBar(title, maxval)
+            else:
+                return DummyProgressBar()
+        else:
+            return ParallelProgressBar(title, maxval)
     pbar = TqdmProgressBar(title,maxval)
     return pbar

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list