mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
fix zerodiv and other errors
This commit is contained in:
parent
a856665824
commit
4be8b9d38c
2 changed files with 17 additions and 13 deletions
|
@ -98,12 +98,15 @@ table * { font-size: 14px; }
|
||||||
else:
|
else:
|
||||||
days = num*30
|
days = num*30
|
||||||
vals = []
|
vals = []
|
||||||
|
try:
|
||||||
vals.append(_("%d/day") % (tot/days))
|
vals.append(_("%d/day") % (tot/days))
|
||||||
if self.type > 0:
|
if self.type > 0:
|
||||||
vals.append(_("%d/week") % (tot/(days/7)))
|
vals.append(_("%d/week") % (tot/(days/7)))
|
||||||
if self.type > 1:
|
if self.type > 1:
|
||||||
vals.append(_("%d/month") % (tot/(days/30)))
|
vals.append(_("%d/month") % (tot/(days/30)))
|
||||||
txt = _("Average reviews: <b>%s</b>") % ", ".join(vals)
|
txt = _("Average reviews: <b>%s</b>") % ", ".join(vals)
|
||||||
|
except ZeroDivisionError:
|
||||||
|
return ""
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def _due(self, start=None, end=None, chunk=1):
|
def _due(self, start=None, end=None, chunk=1):
|
||||||
|
@ -367,6 +370,7 @@ where 1 """ + self._limit())
|
||||||
self._line(i, _("Total Cards"), c)
|
self._line(i, _("Total Cards"), c)
|
||||||
self._line(i, _("Total Facts"), f)
|
self._line(i, _("Total Facts"), f)
|
||||||
(low, avg, high) = self._factors()
|
(low, avg, high) = self._factors()
|
||||||
|
if low:
|
||||||
self._line(i, _("Lowest ease factor"), "%d%%" % low)
|
self._line(i, _("Lowest ease factor"), "%d%%" % low)
|
||||||
self._line(i, _("Average ease factor"), "%d%%" % avg)
|
self._line(i, _("Average ease factor"), "%d%%" % avg)
|
||||||
self._line(i, _("Highest ease factor"), "%d%%" % high)
|
self._line(i, _("Highest ease factor"), "%d%%" % high)
|
||||||
|
|
|
@ -598,7 +598,7 @@ def test_groupCounts():
|
||||||
# and one that's a child
|
# and one that's a child
|
||||||
f = d.newFact()
|
f = d.newFact()
|
||||||
f['Front'] = u"two"
|
f['Front'] = u"two"
|
||||||
f.gid = d.groupId("Default Group::1")
|
f.gid = d.groupId("Default::1")
|
||||||
d.addFact(f)
|
d.addFact(f)
|
||||||
# make it a review card
|
# make it a review card
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
|
@ -619,12 +619,12 @@ def test_groupCounts():
|
||||||
assert d.sched.counts() == (3, 0, 1)
|
assert d.sched.counts() == (3, 0, 1)
|
||||||
assert len(d.groups()) == 4
|
assert len(d.groups()) == 4
|
||||||
cnts = d.sched.groupCounts()
|
cnts = d.sched.groupCounts()
|
||||||
assert cnts[0] == ["Default Group", 1, 1, 0, 1]
|
assert cnts[0] == ["Default", 1, 1, 0, 1]
|
||||||
assert cnts[1] == ["Default Group::1", 2, 1, 1, 0]
|
assert cnts[1] == ["Default::1", 2, 1, 1, 0]
|
||||||
assert cnts[2] == ["foo::bar", 3, 1, 0, 1]
|
assert cnts[2] == ["foo::bar", 3, 1, 0, 1]
|
||||||
assert cnts[3] == ["foo::baz", 4, 1, 0, 1]
|
assert cnts[3] == ["foo::baz", 4, 1, 0, 1]
|
||||||
tree = d.sched.groupCountTree()
|
tree = d.sched.groupCountTree()
|
||||||
assert tree[0][0] == "Default Group"
|
assert tree[0][0] == "Default"
|
||||||
# sum of child and parent
|
# sum of child and parent
|
||||||
assert tree[0][1] == 1
|
assert tree[0][1] == 1
|
||||||
assert tree[0][2] == 2
|
assert tree[0][2] == 2
|
||||||
|
|
Loading…
Reference in a new issue