Skip to content

Commit

Permalink
sorts out prog bar edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed May 24, 2021
1 parent b097a2a commit 8bba88f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions cityseer/algos/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ def progress_bar(current: int, total: int, steps: int = 20):
https://github.com/krishnanlab/PecanPy/commit/9c6ca6f5c6341e84aa080b2936cd59d9d8a37b24
TODO: set cache to True once resolved
'''
if steps == 0:
return
step_size = int(total / steps)
if step_size == 0:
if steps == 0 or current == 0 or total < 2 * steps:
return
step_size = int(total / steps) # round down
if current % step_size == 0:
print('Processed non-sequential checkpoint', round(current / step_size) + 1, 'of', steps + 1)
print('Processed non-sequential checkpoint', int(current / step_size), 'of', steps)


@njit(cache=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/algos/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


def test_progress_bar():
for n in [1, 10, 20, 100]:
for i in range(n):
for n in [1, 11, 27, 101, 271, 5521]:
for i in range(n + 1):
checks.progress_bar(i, n)


Expand Down

0 comments on commit 8bba88f

Please sign in to comment.