Пример #1
0
def test_empty():
    with pytest.raises(Exception):
        median_of_dict({})
Пример #2
0
def test_multiple2():
    d = {0: 22, 3: 56}
    assert np.median([i for sl in [[k]*v for k, v in d.items()] for i in sl]) == median_of_dict(d) == 3
Пример #3
0
def test_multiple5():
    d = {0.0: 1, 5.0: 1, 2.0: 1, 34.0: 1}
    assert np.median([i for sl in [[k]*v for k, v in d.items()] for i in sl]) == median_of_dict(d) == 3.5
Пример #4
0
def test_single2():
    d = {0: 22}
    assert np.median([i for sl in [[k]*v for k, v in d.items()] for i in sl]) == median_of_dict(d) == 0