open-spaced-repetition / fsrs-rs

FSRS for Rust, including Optimizer and Scheduler
https://crates.io/crates/fsrs
BSD 3-Clause "New" or "Revised" License
185 stars 19 forks source link

Fix/filter rating_stability to match rating_count keys #225

Closed L-M-Sherlock closed 1 month ago

L-M-Sherlock commented 1 month ago

Prevents processing non-existent rating data, improving data consistency and avoiding potential errors when working with unmatched ratings.

Source: https://forums.ankiweb.net/t/anki-24-10-beta/49989/51?u=l.m.sherlock

Error:

[/Users/jarrettye/Codes/open-spaced-repetition/fsrs-rs/src/pre_training.rs:171:5] &rating_stability = {
    2: 0.9449276,
    1: 0.057034113,
    4: 0.7255576,
    3: 1.1028688,
}
[/Users/jarrettye/Codes/open-spaced-repetition/fsrs-rs/src/pre_training.rs:172:5] &rating_count = {
    2: 303,
    3: 567,
}
thread '<unnamed>' panicked at /Users/jarrettye/Codes/open-spaced-repetition/fsrs-rs/src/pre_training.rs:179:62:
no entry found for key