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

to 2024 #46

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 1 addition & 13 deletions .github/workflows/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@

set -eux -o pipefail

cargo fmt --check || (
printf "
Please run 'cargo fmt' to format the code.
"
exit 1
)

cargo clippy -- -D clippy::nursery || (
printf "
run 'cargo clippy -- -D clippy::nursery' to check the code.
"
exit 1
)
cargo fmt --check

cargo install cargo-llvm-cov --locked
SKIP_TRAINING=1 cargo llvm-cov --release
2 changes: 1 addition & 1 deletion src/algo.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::ImplScheduler;
use crate::models::{Card, Rating, RecordLog, SchedulingInfo};
use crate::parameters::Parameters;
use crate::scheduler_basic::BasicScheduler;
use crate::scheduler_longterm::LongtermScheduler;
use crate::ImplScheduler;

use chrono::{DateTime, Utc};

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![deny(warnings)]
#![deny(clippy::all)]
mod algo;
pub use algo::FSRS;

mod alea;
pub use alea::{alea, Alea, AleaState, Prng};
pub use alea::{Alea, AleaState, Prng, alea};

mod scheduler;
pub use scheduler::{ImplScheduler, Scheduler};
Expand Down
4 changes: 2 additions & 2 deletions src/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::Utc;

use crate::alea;
use crate::Rating;
use crate::alea;

type Weights = [f64; 19];
const DEFAULT_WEIGHTS: Weights = [
Expand Down Expand Up @@ -36,7 +36,7 @@ impl Parameters {
(self.w[4] - f64::exp(self.w[5] * (rating_int as f64 - 1.0)) + 1.0).clamp(1.0, 10.0)
}

pub fn init_stability(&self, rating: Rating) -> f64 {
pub const fn init_stability(&self, rating: Rating) -> f64 {
let rating_int: i32 = rating as i32;
self.w[(rating_int - 1) as usize].max(0.1)
}
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use chrono::{DateTime, Utc};

use crate::models::State::*;
use crate::Seed;
use crate::models::State::*;
use crate::{
models::{RecordLog, SchedulingInfo},
Card, Parameters, Rating, ReviewLog,
models::{RecordLog, SchedulingInfo},
};

#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler_basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chrono::{DateTime, Duration, Utc};

use crate::{scheduler::Scheduler, Card, ImplScheduler, Parameters, Rating, SchedulingInfo};
use crate::{Card, ImplScheduler, Parameters, Rating, SchedulingInfo, scheduler::Scheduler};
use crate::{Rating::*, State::*};
pub struct BasicScheduler {
pub scheduler: Scheduler,
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(test)]
use {
crate::{
alea::{alea, AleaState},
alea::{AleaState, alea},
algo::FSRS,
models::{Card, Rating, State},
parameters::{Parameters, Seed},
Expand Down Expand Up @@ -204,7 +204,7 @@ fn test_alea_int32() {
#[test]
fn test_alea_import_state() {
let mut rng = rand::thread_rng();
let mut prng_1 = alea(Seed::new(rng.gen::<i32>()));
let mut prng_1 = alea(Seed::new(rng.r#gen::<i32>()));
prng_1.gen_next();
prng_1.gen_next();
prng_1.gen_next();
Expand Down
Loading