Progress bar fails with ZeroDivisionError using a small number of observations
vc1492a opened this issue · comments
The below line contained within PyNomaly/loop.py
fails with a ZeroDivisionError when the total number of observations is less than the terminal or cell width where the code was executed.
Line 36 in 744fa57
The cause is a block_size of 0, which is not allowable with the current implementation.
This can be resolved by changing the code to the following:
if total < w:
block_size = int(w / total)
else:
block_size = int(total / w)
if index % block_size == 0:
Which will ensure the block_size remains greater than 0 even when the number of observations is less than the width of the terminal / cell window.
A unit test has been written in a separate library to ensure that the progress bar is exhibiting the proper behavior when utilized, and can be included as part of the patch for this issue.
Added as part of version 0.3.3
.