ZeroDivisionError: division by zero (osu learning)

huangapple go评论100阅读模式
英文:

ZeroDivisionError: division by zero (osu learning)

问题

无法修复该错误。我尝试在Google上查找,但没有找到解决方法。

英文:

I cant fix that error

  1. ---------------------------------------------------------------------------
  2. ZeroDivisionError Traceback (most recent call last)
  3. Cell In[17], line 1
  4. ----> 1 data_files = osulearn.dataset.all_files(OSU_FOLDER, verbose=True)
  5. 3 if not os.path.exists('.data'):
  6. 4 os.makedirs('.data')
  7. File c:\Users\danil\OneDrive\Desktop\OsuLearn-master\OsuLearn-master\osulearn\dataset.py:41, in all_files(osu_path, limit, verbose)
  8. 39 for i in range(len(replays)-1, -1, -1):
  9. 40 if verbose:
  10. ---> 41 _print_progress_bar(replays, i, reverse=True)
  11. 43 beatmap = _get_replay_beatmap_file(osu_path, replays[i])
  12. 45 if beatmap is None:
  13. File c:\Users\danil\OneDrive\Desktop\OsuLearn-master\OsuLearn-master\osulearn\_cli.py:4, in _print_progress_bar(collection, index, bar_width, buffer_width, reverse)
  14. 1 def _print_progress_bar(collection, index, bar_width=40, buffer_width=80, reverse=False):
  15. 2 bar_format = "\r[{done}>{todo}] {text}"
  16. ----> 4 progress = index / (len(collection) - 1)
  17. 5 if reverse:
  18. 6 progress = 1 - progress
  19. ZeroDivisionError: division by zero

I dont know how to fix it, i tried to find in google but nothing found

答案1

得分: 0

直接部分 len(collection) - 1 是表达式的一部分,如果集合的大小为1,它会导致 ZeroDivisionError。您需要增加集合的大小(大于一个项目),然后一切都会正确。

英文:

It seems that the expression

  1. progress = index / (len(collection) - 1)

directly part this part len(collection) - 1 in case that collection has size 1, it generates ZeroDivisionError.

You have to increate sice of collection (> one item) and all will be correct.

huangapple
  • 本文由 发表于 2023年4月10日 19:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75976568.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定