Skip to content

Commit

Permalink
Adapt progress bar for 0 size data
Browse files Browse the repository at this point in the history
  • Loading branch information
Mithil467 committed Feb 4, 2024
1 parent bc0996b commit 7c98541
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pandarallel/progress_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __remove_displayed_lines(self) -> None:

def __update_line(self, done: int, total: int) -> str:
if total == 0:
percent = 1
percent = 0
else:
percent = done / total
bar = (":" * int(percent * 40)).ljust(40, " ")
Expand Down Expand Up @@ -165,10 +165,8 @@ def update(self, values: List[int]) -> None:
if value >= bar.max:
bar.bar_style = "success"

if bar.max == 0:
bar.max = bar.value = 1

bar.description = "{:.2f}%".format(bar.value / bar.max * 100)
if bar.max != 0:
bar.description = "{:.2f}%".format(bar.value / bar.max * 100)

Check warning on line 169 in pandarallel/progress_bars.py

View check run for this annotation

Codecov / codecov/patch

pandarallel/progress_bars.py#L168-L169

Added lines #L168 - L169 were not covered by tests

def set_error(self, index: int) -> None:
"""Set a bar on error"""
Expand Down

0 comments on commit 7c98541

Please sign in to comment.