Пример #1
0
def test_disequilibrium6(n):
    """
    Test that peaked Distributions have non-zero disequilibrium.
    """
    d = ScalarDistribution([1] + [0] * (n - 1))
    d.make_dense()
    d = Distribution.from_distribution(d)
    assert disequilibrium(d) >= 0
Пример #2
0
def test_disequilibrium6(n):
    """
    Test that peaked Distributions have non-zero disequilibrium.
    """
    d = ScalarDistribution([1] + [0]*(n-1))
    d.make_dense()
    d = Distribution.from_distribution(d)
    assert disequilibrium(d) >= 0
Пример #3
0
def test_LMPR_complexity5(n):
    """
    Test that peaked Distributions have zero complexity.
    """
    d = ScalarDistribution([1] + [0] * (n - 1))
    d.make_dense()
    d = Distribution.from_distribution(d)
    assert LMPR_complexity(d) == pytest.approx(0)
Пример #4
0
def test_LMPR_complexity5(n):
    """
    Test that peaked Distributions have zero complexity.
    """
    d = ScalarDistribution([1] + [0]*(n-1))
    d.make_dense()
    d = Distribution.from_distribution(d)
    assert LMPR_complexity(d) == pytest.approx(0)
Пример #5
0
def test_disequilibrium6():
    """
    Test that peaked Distributions have non-zero disequilibrium.
    """
    for n in range(2, 11):
        d = ScalarDistribution([1] + [0]*(n-1))
        d.make_dense()
        d = Distribution.from_distribution(d)
        yield assert_greater, disequilibrium(d), 0
Пример #6
0
def test_LMPR_complexity4():
    """
    Test that peaked Distributions have zero complexity.
    """
    for n in range(2, 11):
        d = ScalarDistribution([1] + [0]*(n-1))
        d.make_dense()
        d = Distribution.from_distribution(d)
        yield assert_almost_equal, LMPR_complexity(d), 0
Пример #7
0
def test_is_approx_equal2():
    d1 = ScalarDistribution([1 / 2, 1 / 2, 0])
    d1.make_dense()
    d2 = ScalarDistribution([1 / 2, 0, 1 / 2])
    d2.make_dense()
    assert not d1.is_approx_equal(d2)
Пример #8
0
def test_del2():
    d = ScalarDistribution([1 / 2, 1 / 2])
    d.make_dense()
    del d[1]
    d.normalize()
    assert d[0] == pytest.approx(1)
Пример #9
0
def test_is_approx_equal2():
    d1 = ScalarDistribution([1 / 2, 1 / 2, 0])
    d1.make_dense()
    d2 = ScalarDistribution([1 / 2, 0, 1 / 2])
    d2.make_dense()
    assert_false(d1.is_approx_equal(d2))
Пример #10
0
def test_del2():
    d = ScalarDistribution([1 / 2, 1 / 2])
    d.make_dense()
    del d[1]
    d.normalize()
    assert_almost_equal(d[0], 1)
Пример #11
0
def test_is_approx_equal1():
    d1 = ScalarDistribution([1 / 2, 1 / 2, 0])
    d1.make_dense()
    d2 = ScalarDistribution([1 / 2, 1 / 2, 0])
    d2.make_dense()
    assert_true(d1.is_approx_equal(d2))
Пример #12
0
def test_del2():
    d = ScalarDistribution([1 / 2, 1 / 2])
    d.make_dense()
    del d[1]
    d.normalize()
    assert_almost_equal(d[0], 1)