[yt-svn] commit/yt: 5 new changesets

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


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/60efcc1f65c1/
Changeset:   60efcc1f65c1
Branch:      yt
User:        brittonsmith
Date:        2016-01-26 18:38:57+00:00
Summary:     Making sure args from pbar.update get passed along and adding a parallel option for get_pbar.
Affected #:  2 files

diff -r cd0a29c8ed02c58096e6e0f3f6c7aaa6b8cf6dc3 -r 60efcc1f65c163c6e90ae6d776d14b4942dab557 yt/extern/tqdm/_tqdm.py
--- a/yt/extern/tqdm/_tqdm.py
+++ b/yt/extern/tqdm/_tqdm.py
@@ -446,15 +446,21 @@
             self.n = n
             self.close()
 
-    def update(self, n=1):
+    def update(self, n=None, i=None):
         """
         Manually update the progress bar, useful for streams
         such as reading files.
         E.g.:
         >>> t = tqdm(total=filesize) # Initialise
         >>> for current_buffer in stream:
+        ...    t.update(i=len(current_buffer))
+        >>> t.close()
+        >>>
+        >>> some_list = range(10)
+        >>> t = tqdm(total=len(some_list)) # Initialise
+        >>> for n, val in some_list:
         ...    ...
-        ...    t.update(len(current_buffer))
+        ...    t.update(n)
         >>> t.close()
         The last line is highly recommended, but possibly not necessary if
         `t.update()` will be called in such a way that `filesize` will be
@@ -463,15 +469,23 @@
         Parameters
         ----------
         n  : int
-            Increment to add to the internal counter of iterations
-            [default: 1].
+            The current iteration.
+        i : int
+            The increment
         """
+
+        if n is None and i is None:
+            i = 1
+        if n is not None and i is not None:
+            raise RuntimeError("Must specify either n or i, not both.")
+
         if self.disable:
             return
 
-        if n < 1:
-            n = 1
-        self.n += n
+        if n is not None:
+            self.n = n
+        else:
+            self.n += i
 
         delta_it = self.n - self.last_print_n  # should be n?
         if delta_it >= self.miniters:

diff -r cd0a29c8ed02c58096e6e0f3f6c7aaa6b8cf6dc3 -r 60efcc1f65c163c6e90ae6d776d14b4942dab557 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -340,10 +340,9 @@
     # 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)
+    def update(self,*args, **kwargs):
+        self._pbar.update(*args, **kwargs)
     def finish(self):
         self._pbar.close()
 
@@ -385,7 +384,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 +395,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
 


https://bitbucket.org/yt_analysis/yt/commits/fe50880c9c30/
Changeset:   fe50880c9c30
Branch:      yt
User:        brittonsmith
Date:        2016-01-27 11:52:18+00:00
Summary:     Reverting changes to tqdm source.
Affected #:  1 file

diff -r 60efcc1f65c163c6e90ae6d776d14b4942dab557 -r fe50880c9c30673631cb6a13a81e31c066f096aa yt/extern/tqdm/_tqdm.py
--- a/yt/extern/tqdm/_tqdm.py
+++ b/yt/extern/tqdm/_tqdm.py
@@ -446,21 +446,15 @@
             self.n = n
             self.close()
 
-    def update(self, n=None, i=None):
+    def update(self, n=1):
         """
         Manually update the progress bar, useful for streams
         such as reading files.
         E.g.:
         >>> t = tqdm(total=filesize) # Initialise
         >>> for current_buffer in stream:
-        ...    t.update(i=len(current_buffer))
-        >>> t.close()
-        >>>
-        >>> some_list = range(10)
-        >>> t = tqdm(total=len(some_list)) # Initialise
-        >>> for n, val in some_list:
         ...    ...
-        ...    t.update(n)
+        ...    t.update(len(current_buffer))
         >>> t.close()
         The last line is highly recommended, but possibly not necessary if
         `t.update()` will be called in such a way that `filesize` will be
@@ -469,23 +463,15 @@
         Parameters
         ----------
         n  : int
-            The current iteration.
-        i : int
-            The increment
+            Increment to add to the internal counter of iterations
+            [default: 1].
         """
-
-        if n is None and i is None:
-            i = 1
-        if n is not None and i is not None:
-            raise RuntimeError("Must specify either n or i, not both.")
-
         if self.disable:
             return
 
-        if n is not None:
-            self.n = n
-        else:
-            self.n += i
+        if n < 1:
+            n = 1
+        self.n += n
 
         delta_it = self.n - self.last_print_n  # should be n?
         if delta_it >= self.miniters:


https://bitbucket.org/yt_analysis/yt/commits/5ed7536f3896/
Changeset:   5ed7536f3896
Branch:      yt
User:        brittonsmith
Date:        2016-01-27 12:01:14+00:00
Summary:     Making wrapper progress bar function as before.
Affected #:  1 file

diff -r fe50880c9c30673631cb6a13a81e31c066f096aa -r 5ed7536f3896cff7240b56e6fc8f8736d155226c yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -341,8 +341,11 @@
     # called tqdm
     def __init__(self,title, maxval):
         self._pbar = tqdm(leave=True, total=maxval, desc=title)
-    def update(self,*args, **kwargs):
-        self._pbar.update(*args, **kwargs)
+        self.i = 0
+    def update(self, i):
+        n = i - self.i
+        self.i = i
+        self._pbar.update(n)
     def finish(self):
         self._pbar.close()
 


https://bitbucket.org/yt_analysis/yt/commits/5e772f30fb2d/
Changeset:   5e772f30fb2d
Branch:      yt
User:        brittonsmith
Date:        2016-01-27 12:04:37+00:00
Summary:     Making pbar arg into a kwarg.
Affected #:  1 file

diff -r 5ed7536f3896cff7240b56e6fc8f8736d155226c -r 5e772f30fb2d066d44dd3efadea40869fc4b6945 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -342,7 +342,9 @@
     def __init__(self,title, maxval):
         self._pbar = tqdm(leave=True, total=maxval, desc=title)
         self.i = 0
-    def update(self, i):
+    def update(self, i=None):
+        if i is None:
+            i = self.i + 1
         n = i - self.i
         self.i = i
         self._pbar.update(n)


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