コード例 #1
0
ファイル: test_circuits.py プロジェクト: gto00002/dit
def test_rdn():
    """ Test the Rdn distribution """
    d = Rdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 1)
    assert_almost_equal(i2, 1)
    assert_almost_equal(i12, 1)
    assert_almost_equal(r, 1)
コード例 #2
0
def test_rdn():
    """ Test the Rdn distribution """
    d = Rdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(1)
    assert i2 == pytest.approx(1)
    assert i12 == pytest.approx(1)
    assert r == pytest.approx(1)
コード例 #3
0
ファイル: test_optimizers.py プロジェクト: zhaofeng-shu33/dit

def test_mincoinfo_1():
    """
    Test mincoinfo
    """
    d = uniform(['000', '111'])
    mcio = MinCoInfoOptimizer(d, [[0], [1], [2]])
    mcio.optimize()
    dp = mcio.construct_dist()
    assert I(dp) == pytest.approx(-1)


@pytest.mark.skip(reason="This method if deprecated.")
@pytest.mark.parametrize(('dist', 'vals'), [
    (Rdn(), (1, 0, 0, 0)),
    (Unq(), (0, 1, 1, 0)),
    (Xor(), (0, 0, 0, 1)),
])
def test_broja_1(dist, vals):
    """
    Test broja.
    """
    with warnings.catch_warnings():
        pid = pid_broja(dist, [[0], [1]], [2])
    assert pid == pytest.approx(vals, abs=1e-4)


@pytest.mark.flaky(reruns=5)
def test_dtc_1():
    """