Skip to content

Commit

Permalink
Replacing sys.stdout.write with print in progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainv committed Jun 8, 2024
1 parent f12cafb commit 9d3b42b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 157 deletions.
150 changes: 0 additions & 150 deletions riskmapjnr/benchmark/defrate_per_class_model.py

This file was deleted.

3 changes: 2 additions & 1 deletion riskmapjnr/benchmark/vulnerability_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ def vulnerability_map(
cat_band.ComputeStatistics(False, cb)

# Dereference drivers
forest_band = None
cat_band = None
dist_band = None
subj_band = None
del cat_ds, dist_ds, subj_ds
del forest_ds, cat_ds, dist_ds, subj_ds


# # Test
Expand Down
15 changes: 9 additions & 6 deletions riskmapjnr/misc/miscellaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,17 @@ def progress_bar(niter, i):

step = 1 if niter <= 100 else niter // 100
if i == 1:
sys.stdout.write("0%")
sys.stdout.flush()
print("0%", end="", flush=True)
#sys.stdout.write("0%")
#sys.stdout.flush()
elif i % step == 0:
sys.stdout.write("\r{}%".format((100 * i) // niter))
sys.stdout.flush()
print(f"\r{(100 * i) // niter}%", end="", flush=True)
#sys.stdout.write("\r{}%".format((100 * i) // niter))
#sys.stdout.flush()
if i == niter:
sys.stdout.write("\r100%\n")
sys.stdout.flush()
print("\r100%", flush=True)
#sys.stdout.write("\r100%\n")
#sys.stdout.flush()


# Rescale
Expand Down

0 comments on commit 9d3b42b

Please sign in to comment.