Whole file
open-spaced-repetition/py-fsrs
The author described this change as “Fix handling of multiple schedulers edge case (#91)”. It counts as a record because the check below fails on the code as it stood at e8b498dcd and passes on a6879266e, with nothing else changed between the two runs.
Fix saved2025-02-09
Sharing licenceMIT · LICENSE
Change size+11 −9
What the code was meant to do, written into the code itself as a save note
Fix handling of multiple schedulers edge case (#91)
The change
| 446 | 446 | ) | |
| 447 | 447 | ||
| 448 | 448 | # calculate the card's next interval | |
| 449 | - | # len(self.learning_steps) == 0: no learning steps defined so move card to Review state | |
| 450 | - | # card.step >= len(self.learning_steps): handles the edge-case when a card was originally scheduled with a scheduler with more | |
| 451 | - | # learning steps than the current scheduler | |
| 452 | - | if len(self.learning_steps) == 0 or card.step >= len(self.learning_steps): | |
| 449 | + | ## first if-clause handles edge case where the Card in the Learning state was previously | |
| 450 | + | ## scheduled with a Scheduler with more learning_steps than the current Scheduler | |
| 451 | + | if len(self.learning_steps) == 0 or ( | |
| 452 | + | card.step >= len(self.learning_steps) | |
| 453 | + | and rating in (Rating.Hard, Rating.Good, Rating.Easy) | |
| 454 | + | ): | |
| 453 | 455 | card.state = State.Review | |
| 454 | 456 | card.step = None | |
| 455 | 457 | ||
| ⋯ | |||
| 558 | 560 | ) | |
| 559 | 561 | ||
| 560 | 562 | # calculate the card's next interval | |
| 561 | - | # len(self.relearning_steps) == 0: no relearning steps defined so move card to Review state | |
| 562 | - | # card.step >= len(self.relearning_steps): handles the edge-case when a card was originally scheduled with a scheduler with more | |
| 563 | - | # relearning steps than the current scheduler | |
| 564 | - | if len(self.relearning_steps) == 0 or card.step >= len( | |
| 565 | - | self.relearning_steps | |
| 563 | + | ## first if-clause handles edge case where the Card in the Relearning state was previously | |
| 564 | + | ## scheduled with a Scheduler with more relearning_steps than the current Scheduler | |
| 565 | + | if len(self.relearning_steps) == 0 or ( | |
| 566 | + | card.step >= len(self.relearning_steps) | |
| 567 | + | and rating in (Rating.Hard, Rating.Good, Rating.Easy) | |
| 566 | 568 | ): | |
| 567 | 569 | card.state = State.Review | |
| 568 | 570 | card.step = None | |
The check that tells the two apart
fail→pass·tests/test_basic.py::TestPyFSRS::test_one_card_multiple_schedulers
Check file tests/test_basic.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before ite8b498dcd9b42fbf732747c2cb8a430bf86a6f83
Broken version dated2025-02-06
Modulefsrs.fsrs
Units changedScheduler
Fingerprintc5424867d1c6c1bc
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.