Skip to content

Commit

Permalink
add tests for predictDraw to mirror python
Browse files Browse the repository at this point in the history
  • Loading branch information
philihp committed Jul 30, 2024
1 parent 40c4cb4 commit 5cd160e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/__tests__/predict-draw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,33 @@ describe('predictDraw', () => {
).toBeCloseTo(0.11489223845523855, 7)
})
})

it('mirrors results from python', () => {

Check failure on line 95 in src/__tests__/predict-draw.test.ts

View workflow job for this annotation

GitHub Actions / lint

Test title is used multiple times in the same describe block
// from https://github.com/philihp/openskill.js/issues/599
const t1 = [rating({ mu: 25, sigma: 1 }), rating({ mu: 25, sigma: 1 })]
const t2 = [rating({ mu: 25, sigma: 1 }), rating({ mu: 25, sigma: 1 })]
expect(predictDraw([t1, t2])).toBeCloseTo(0.6608263448857606)
})

it('gives a low probability in a 5 team match', () => {

Check failure on line 102 in src/__tests__/predict-draw.test.ts

View workflow job for this annotation

GitHub Actions / lint

Test title is used multiple times in the same describe block
// from https://openskill.me/en/stable/manual.html
const p1 = rating({ mu: 35, sigma: 1.0 })
const p2 = rating({ mu: 35, sigma: 1.0 })
const p3 = rating({ mu: 35, sigma: 1.0 })
const p4 = rating({ mu: 35, sigma: 1.0 })
const p5 = rating({ mu: 35, sigma: 1.0 })

const team1 = [p1, p2]
const team2 = [p3, p4, p5]
expect(predictDraw([team1, team2])).toBeCloseTo(0.0002807397636509501, 10)
})

it('gives a higher probability with fewer players', () => {

Check failure on line 115 in src/__tests__/predict-draw.test.ts

View workflow job for this annotation

GitHub Actions / lint

Test title is used multiple times in the same describe block
// from https://openskill.me/en/stable/manual.html
const p1 = rating({ mu: 35, sigma: 1.0 })
const p2 = rating({ mu: 35, sigma: 1.1 })
const team1 = [p1]
const team2 = [p2]
expect(predictDraw([team1, team2])).toBeCloseTo(0.4868868769871696)
})
})

0 comments on commit 5cd160e

Please sign in to comment.