Beispiel #1
0
def test_raises_exception_for_non_numeric_weight():
    with pytest.raises(TypeError):
        ProbabilityMassFunction(items=[1, 2, 3], weights=[1, "a", 3])
Beispiel #2
0
def constant_pmf(request):
    if request.param:
        return (ProbabilityMassFunction(items=[True, False],
                                        weights=[1, 0]), request.param)
    return (ProbabilityMassFunction(items=[True, False],
                                    weights=[0, 1]), request.param)
Beispiel #3
0
def test_raises_exception_for_non_listlike_init():
    with pytest.raises(AttributeError):
        pmf = ProbabilityMassFunction(items="happy")
        pmf.add_item("sad")
Beispiel #4
0
def test_raises_exception_for_uneven_init():
    with pytest.raises(ValueError):
        ProbabilityMassFunction(items=[1, 2, 3], weights=[
            1,
        ])
Beispiel #5
0
def equal_pmf():
    return ProbabilityMassFunction(items=[True, False])
Beispiel #6
0
def sample_pmf():
    return ProbabilityMassFunction(items=[1.0, 2.0, 3.0, 4.0],
                                   weights=[4.0, 3.0, 2.0, 1.0])
Beispiel #7
0
def empty_pmf():
    return ProbabilityMassFunction()