From 4fba2645ae03fe986e21ac4236be733bd595d2bb Mon Sep 17 00:00:00 2001 From: ghislainv Date: Sun, 9 Jun 2024 06:45:15 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20ghislain?= =?UTF-8?q?v/geefcc@30d842c9cc60a1c6d93bed9f938aaf408c28ccab=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _modules/geefcc/misc/miscellaneous.html | 41 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/_modules/geefcc/misc/miscellaneous.html b/_modules/geefcc/misc/miscellaneous.html index 05a23bd..5bf6dd7 100644 --- a/_modules/geefcc/misc/miscellaneous.html +++ b/_modules/geefcc/misc/miscellaneous.html @@ -102,7 +102,6 @@

Source code for geefcc.misc.miscellaneous

 
 # Standard library imports
 import os
-import sys
 
 # Third party imports
 import numpy as np
@@ -194,25 +193,43 @@ 

Source code for geefcc.misc.miscellaneous

     return (nblock, nblock_x, nblock_y, x, y, nx, ny)
 
 
-# Progress_bar
 def progress_bar(niter, i):
     """Draw progress_bar
 
+     See results of ``[(100 * i / niter) // 10 * 10 for i in
+     range(niter + 1)]`` to understand how it works.
+
     :param niter: Total number of iterations.
     :param i: Current number of iteration (starts at 1).
 
     """
 
-    step = 1 if niter <= 100 else niter // 100
-    if i == 1:
-        sys.stdout.write("0%")
-        sys.stdout.flush()
-    elif i % step == 0:
-        sys.stdout.write("\r{}%".format((100 * i) // niter))
-        sys.stdout.flush()
-    if i == niter:
-        sys.stdout.write("\r100%\n")
-        sys.stdout.flush()
+    pkg_name = "geefcc"
+
+    if niter >= 40:
+        perc_10 = 100 * i / niter // 10 * 10
+        perc_previous_10 = 100 * (i - 1) / niter // 10 * 10
+        perc_2_5 = 100 * i / niter // 2.5 * 2.5
+        perc_previous_2_5 = 100 * (i - 1) / niter // 2.5 * 2.5
+        if i == 1:
+            print(f"{pkg_name}: 0", end="", flush=True)
+        elif perc_10 != perc_previous_10:
+            if i == niter:
+                print("100 - done", end="\n", flush=True)
+            else:
+                print(f"{int(perc_10)}", end="", flush=True)
+        elif perc_2_5 != perc_previous_2_5:
+            print(".", end="", flush=True)
+    else:
+        perc_10 = 100 * i / niter // 10 * 10
+        perc_previous_10 = 100 * (i - 1) / niter // 10 * 10
+        if i == 0:
+            print(f"{pkg_name}: 0...", end="", flush=True)
+        elif perc_10 != perc_previous_10:
+            if i == niter:
+                print("100 - done", end="\n", flush=True)
+            else:
+                print(f"{int(perc_10)}...", end="", flush=True)
 
 
 # End