from calc.stats import mean, median, mode, variance


def test_mean_basic():
    assert mean([1, 2, 3, 4, 5]) == 3.0


def test_median_odd():
    assert median([1, 2, 3]) == 2


def test_median_even():
    assert median([1, 2, 3, 4]) == 2.5


def test_median_unsorted():
    assert median([3, 1, 4, 1, 5, 9, 2, 6]) == 3.5


def test_median_floats():
    assert median([1.0, 2.0, 3.0, 4.0]) == 2.5


def test_mode_basic():
    assert mode([1, 2, 2, 3]) == 2


def test_variance_basic():
    # sample variance (n-1) of [1, 2, 3, 4, 5] is 10/4 = 2.5
    assert variance([1, 2, 3, 4, 5]) == 2.5
