diff --git a/pythia/seo/tests/test_classifications.csv b/pythia/seo/tests/test_classifications.csv new file mode 100644 index 0000000..e3e8fb4 --- /dev/null +++ b/pythia/seo/tests/test_classifications.csv @@ -0,0 +1,6 @@ +,image_id_0,image_id_1,image0_more_complex_image1 +0,1,6,1 +1,2,7,0 +2,3,8,0 +3,4,9,1 +4,5,10,1 diff --git a/pythia/seo/tests/test_elo.py b/pythia/seo/tests/test_elo.py new file mode 100644 index 0000000..66ab332 --- /dev/null +++ b/pythia/seo/tests/test_elo.py @@ -0,0 +1,34 @@ +import pytest +from pythia.seo.elo import ELO +from pathlib import Path + +path = Path(__file__).parent + +@pytest.fixture +def elo(): + return ELO(classifications=path / "test_classifications.csv", delimiter=',') + + +@pytest.mark.parametrize('rating_0,rating_1,expected_score', + [(1400, 1400.0, 0.5), + (1450, 1450.5, 0.49928044265518673), + (1500, 1602.0, 0.3572869311673796), + (1550, 1854.5, 0.14768898365874825), + (1600, 2208.0, 0.029314241270450396)]) +def test_expected_score(elo, rating_0, rating_1, expected_score): + assert elo.expected_score(rating_0, rating_1) == expected_score + + +@pytest.mark.parametrize('rating_for_image,k_value,score_for_image,image_expected_score,new_rating', + [(1400.0, 32, 1, 0.5, 1416.0), + (1450.0, 32, 0, 0.49928044265518673, 1434.023025835034), + (1500.0, 32, 0, 0.3572869311673796, 1488.5668182026438), + (1550.0, 32, 1, 0.14768898365874825, 1577.2739525229201), + (1600.0, 32, 1, 0.029314241270450396, 1631.0619442793457), + (1400.0, 32, 0, 0.5, 1384.0), + (1450.5, 32, 1, 0.5007195573448133, 1466.476974164966), + (1602.0, 32, 1, 0.6427130688326204, 1613.4331817973562), + (1854.5, 32, 0, 0.8523110163412517, 1827.2260474770799), + (2208.0, 32, 0, 0.9706857587295497, 2176.9380557206546)]) +def test_new_rating(elo, rating_for_image, k_value, score_for_image, image_expected_score, new_rating): + assert elo.new_rating(rating_for_image, k_value, score_for_image, image_expected_score) == new_rating diff --git a/pythia/seo/tests/test_rankings.csv b/pythia/seo/tests/test_rankings.csv new file mode 100644 index 0000000..bf11d4d --- /dev/null +++ b/pythia/seo/tests/test_rankings.csv @@ -0,0 +1,11 @@ +,image_id,score,k_value,count,std_dev +0,1,1400.0,32,0,32 +1,2,1450.0,32,0,32 +2,3,1500.0,32,0,32 +3,4,1550.0,32,0,32 +4,5,1600.0,32,0,32 +5,6,1400.0,32,0,32 +6,7,1450.5,32,0,32 +7,8,1602.0,32,0,32 +8,9,1854.5,32,0,32 +9,10,2208.0,32,0,32