zeehio / parmap

Easy to use map and starmap python equivalents
Apache License 2.0
144 stars 9 forks source link

fixing progressbar HAVE_TQDM flag #8

Closed DrSensor closed 7 years ago

DrSensor commented 7 years ago

progress and not HAVE_TQDM

True and (not True) = False True and (not False) = True

found some wrong logic here

zeehio commented 7 years ago

Hi,

Thanks for reporting this issue. After reviewing it I see that the current behavior works as expected and your patch would introduce a bug, as it would hide the progress bar when the user wants it and tqdm is available. However, thanks to your report I have simplified the logic to make it easier to read.

User wants progress bar tqdm is available We show progress bar
False False False
False True False
True False False
True True True

The only case when we show the progress bar is when progress == True and HAVE_TQDM == True. Therefore progress is set to False if tqdm is not available.

parmap works as expected in all cases, although I do not know what was going on in my mind when I wrote that line of code.

The code would have been easier to read if I had used progress = progress and HAVE_TQDM. I'm on it.

Feel free to comment (or reopen if you disagree).

Thanks for your code review!