ZeroDivisionError: division by zero (osu learning)

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

ZeroDivisionError: division by zero (osu learning)

问题

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

英文:

I cant fix that error

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[17], line 1
----> 1 data_files = osulearn.dataset.all_files(OSU_FOLDER, verbose=True)
      3 if not os.path.exists('.data'):
      4     os.makedirs('.data')

File c:\Users\danil\OneDrive\Desktop\OsuLearn-master\OsuLearn-master\osulearn\dataset.py:41, in all_files(osu_path, limit, verbose)
     39 for i in range(len(replays)-1, -1, -1):
     40     if verbose:
---> 41         _print_progress_bar(replays, i, reverse=True)
     43     beatmap = _get_replay_beatmap_file(osu_path, replays[i])
     45     if beatmap is None:

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)
      1 def _print_progress_bar(collection, index, bar_width=40, buffer_width=80, reverse=False):
      2     bar_format = "\r[{done}>{todo}] {text}"
----> 4     progress = index / (len(collection) - 1)
      5     if reverse:
      6         progress = 1 - progress

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

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:

确定