Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes type bug where difficulty became an int if it exceeded the thresholds #74

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "fsrs"
version = "4.1.1"
version = "4.1.2"
description = "Free Spaced Repetition Scheduler"
readme = "README.md"
authors = [{ name = "Jarrett Ye", email = "[email protected]" }]
Expand Down
4 changes: 2 additions & 2 deletions src/fsrs/fsrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def _initial_difficulty(self, rating: Rating) -> float:
)

# bound initial_difficulty between 1 and 10
initial_difficulty = min(max(initial_difficulty, 1), 10)
initial_difficulty = min(max(initial_difficulty, 1.0), 10.0)

return initial_difficulty

Expand Down Expand Up @@ -704,7 +704,7 @@ def _mean_reversion(arg_1: float, arg_2: float) -> float:
next_difficulty = _mean_reversion(arg_1=arg_1, arg_2=arg_2)

# bound next_difficulty between 1 and 10
next_difficulty = min(max(next_difficulty, 1), 10)
next_difficulty = min(max(next_difficulty, 1.0), 10.0)

return next_difficulty

Expand Down
15 changes: 15 additions & 0 deletions tests/test_fsrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ def test_review_card(self):
142,
]

def test_repeated_correct_reviews(self):
scheduler = Scheduler(enable_fuzzing=False)

card = Card()
review_datetimes = [
datetime(2022, 11, 29, 12, 30, 0, i, timezone.utc) for i in range(10)
]

for review_datetime in review_datetimes:
card, _ = scheduler.review_card(
card=card, rating=Rating.Easy, review_datetime=review_datetime
)

assert card.difficulty == 1.0

def test_memo_state(self):
scheduler = Scheduler()

Expand Down
Loading