Image rebuild (skip scrape) / build (push) Successful in 3m58s
Co-authored-by: claude <[email protected]>
26 lines
743 B
Python
26 lines
743 B
Python
"""Stdlib tests for the permutation test. No Chroma."""
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from eval.pvalue import paired_permutation
|
|
|
|
|
|
class PermutationTests(unittest.TestCase):
|
|
def test_identical_is_not_significant(self) -> None:
|
|
a = [1.0, 0.5, 0.0, 1.0]
|
|
r = paired_permutation(a, list(a), n_resamples=200, seed=0)
|
|
self.assertEqual(r["Diff(A-B)"], 0.0)
|
|
self.assertFalse(r["significant"])
|
|
|
|
def test_large_shift_is_significant(self) -> None:
|
|
a = [1.0] * 20
|
|
b = [0.0] * 20
|
|
r = paired_permutation(a, b, n_resamples=500, seed=0)
|
|
self.assertTrue(r["significant"])
|
|
self.assertLess(r["p_value"], 0.05)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|