In deeptutor/learning/mastery.py, compute_mastery is documented as "recency-weighted accuracy" (newer attempts count more, so recovery after early mistakes is rewarded). But the scoring line binds the loop variables in the wrong order:
score = sum(w * (1.0 if c else 0.0) for w, c in zip(recent, weights, strict=True)) / sum(weights)
recent is the correctness list and weights is the recency weights, so zip(recent, weights) yields (correctness, weight) pairs — but they're unpacked as w, c, binding w to the outcome and c to the weight. Since a weight is always truthy, (1.0 if c else 0.0) is always 1.0, so each term reduces to the raw correctness bit. The result:
- the numerator becomes a plain correct-count (recency weights only affect the denominator), so
- mastery is order-independent — a recovering history scores the same as a declining one.
Minimal repro:
>>> compute_mastery([False, True, True]) # miss then two hits (recovering)
0.714...
>>> compute_mastery([True, True, False]) # two hits then a recent miss
0.714... # identical — recency has no effect
Expected: [F,T,T] should score higher than [T,T,F] (recent attempts weigh more).
Fix — swap the unpack to match zip's order:
score = sum(w * (1.0 if c else 0.0) for c, w in zip(recent, weights, strict=True)) / sum(weights)
After the fix: [F,T,T] = 0.696 vs [T,T,F] = 0.643; the confidence caps are unaffected.
In
deeptutor/learning/mastery.py,compute_masteryis documented as "recency-weighted accuracy" (newer attempts count more, so recovery after early mistakes is rewarded). But the scoring line binds the loop variables in the wrong order:recentis the correctness list andweightsis the recency weights, sozip(recent, weights)yields(correctness, weight)pairs — but they're unpacked asw, c, bindingwto the outcome andcto the weight. Since a weight is always truthy,(1.0 if c else 0.0)is always1.0, so each term reduces to the raw correctness bit. The result:Minimal repro:
Expected:
[F,T,T]should score higher than[T,T,F](recent attempts weigh more).Fix — swap the unpack to match
zip's order:After the fix:
[F,T,T] = 0.696vs[T,T,F] = 0.643; the confidence caps are unaffected.