Esempio n. 1
0
def test_statistic_moment_evaluation():
    st = Statistic([1])
    assert st.moment(1) == 1
    assert st.moment(2) == 1

    st.extend([2, 3, 4])
    assert st.moment(1) == 2.5
    assert st.moment(2) == 7.5
Esempio n. 2
0
def test_statistic_moment_raises_error_when_passed_zero_negative_or_float():
    st = Statistic([1, 2, 3])
    with pytest.raises(ValueError) as excinfo:
        st.moment(0)
    assert 'positive integer expected' in str(excinfo.value).lower()

    with pytest.raises(ValueError) as excinfo:
        st.moment(-1)
    assert 'positive integer expected' in str(excinfo.value).lower()

    with pytest.raises(ValueError) as excinfo:
        st.moment(1.5)
    assert 'positive integer expected' in str(excinfo.value).lower()
Esempio n. 3
0
def test_statistic_moment_raises_error_when_called_for_empty_statistic():
    st = Statistic()
    with pytest.raises(ValueError) as excinfo:
        st.moment(1)
    assert 'no data' in str(excinfo.value).lower()