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

Refactor/reschedule #127

Merged
merged 24 commits into from
Oct 11, 2024
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
24 changes: 20 additions & 4 deletions __tests__/algorithm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('next_interval', () => {
(_, i) => (i + 1) / 10
)
const intervals: number[] = desired_retentions.map((r) =>
fsrs({ request_retention: r }).next_interval(1.0, 0, false)
fsrs({ request_retention: r }).next_interval(1.0, 0)
)
expect(intervals).toEqual([422, 102, 43, 22, 13, 8, 4, 2, 1, 1])
})
Expand All @@ -284,14 +284,15 @@ describe('next_interval', () => {
const params = generatorParameters({ maximum_interval: 365 })
const intervalModifier =
(Math.pow(params.request_retention, 1 / DECAY) - 1) / FACTOR
const f: FSRS = fsrs(params)
let f: FSRS = fsrs(params)

const s = 737.47
const next_ivl = f.next_interval(s, 0, false)
const next_ivl = f.next_interval(s, 0)
expect(next_ivl).toEqual(params.maximum_interval)

const t_fuzz = 98
const next_ivl_fuzz = f.next_interval(s, t_fuzz, true)
f = fsrs({ ...params, enable_fuzz: true })
const next_ivl_fuzz = fsrs(params).next_interval(s, t_fuzz)
const { min_ivl, max_ivl } = get_fuzz_range(
Math.round(s * intervalModifier),
t_fuzz,
Expand Down Expand Up @@ -331,6 +332,21 @@ describe('FSRS apply_fuzz', () => {
expect(fuzzedInterval).toBeGreaterThanOrEqual(min_ivl)
expect(fuzzedInterval).toBeLessThanOrEqual(max_ivl)
})

test('return original interval when ivl is less than 3', () => {
const ivl = 3
const enable_fuzz = true
const algorithm = new FSRSAlgorithm({ enable_fuzz: enable_fuzz })
algorithm.seed = 'NegativeS2Seed'
L-M-Sherlock marked this conversation as resolved.
Show resolved Hide resolved
const { min_ivl, max_ivl } = get_fuzz_range(
Math.round(ivl),
0,
default_maximum_interval
)
const fuzzedInterval = algorithm.apply_fuzz(ivl, 0)
expect(fuzzedInterval).toBeGreaterThanOrEqual(min_ivl)
expect(fuzzedInterval).toBeLessThanOrEqual(max_ivl)
})
})

describe('change Params', () => {
Expand Down
Loading