コード例 #1
0
ファイル: test_cross_entropy.py プロジェクト: psychon7/dit
def test_cross_entropy_3(args):
    """
    Test that when p has outcomes that q doesn't have, that we raise an exception.
    """
    first, second, rvs, crvs = args
    with pytest.raises(ditException):
        cross_entropy(first, second, rvs, crvs)
コード例 #2
0
ファイル: test_cross_entropy.py プロジェクト: Autoplectic/dit
def test_cross_entropy_3(args):
    """
    Test that when p has outcomes that q doesn't have, that we raise an exception.
    """
    first, second, rvs, crvs = args
    with pytest.raises(ditException):
        cross_entropy(first, second, rvs, crvs)
コード例 #3
0
def test_cross_entropy_2():
    """
    Test that xH(d, d) = H(d).
    """
    ds = get_dists()
    for d in ds:
        yield assert_almost_equal, cross_entropy(d, d), entropy(d)
コード例 #4
0
ファイル: test_cross_entropy.py プロジェクト: chebee7i/dit
def test_cross_entropy_2():
    """
    Test that xH(d, d) = H(d).
    """
    ds = get_dists()
    for d in ds:
        yield assert_almost_equal, cross_entropy(d, d), entropy(d)
コード例 #5
0
def test_cross_entropy_1():
    """
    Test against several known values.
    """
    d1, d2, d3, d4, d5 = get_dists()
    tests = [([d1, d3], 1.5849625007211563), ([d1, d4], 1.0294468445267841),
             ([d1, d3, [0]], 1.5849625007211563),
             ([d1, d4, [0]], 1.0294468445267841), ([d4, d1, [0]], 1),
             ([d4, d5], 1), ([d5, d4], 1.0294468445267841),
             ([d4, d5, [0], [1]], 0), ([d4, d5, [1], [0]], 0),
             ([d1, d2], np.inf), ([d2, d1], np.inf), ([d3, d1], np.inf)]
    for args, val in tests:
        yield assert_almost_equal, cross_entropy(*args), val
コード例 #6
0
ファイル: test_cross_entropy.py プロジェクト: chebee7i/dit
def test_cross_entropy_1():
    """
    Test against several known values.
    """
    d1, d2, d3, d4, d5 = get_dists()
    tests = [([d1, d3], 1.5849625007211563),
             ([d1, d4], 1.0294468445267841),
             ([d1, d3, [0]], 1.5849625007211563),
             ([d1, d4, [0]], 1.0294468445267841),
             ([d4, d1, [0]], 1),
             ([d4, d5], 1),
             ([d5, d4], 1.0294468445267841),
             ([d4, d5, [0], [1]], 0),
             ([d4, d5, [1], [0]], 0),
             ([d1, d2], np.inf),
             ([d2, d1], np.inf),
             ([d3, d1], np.inf)]
    for args, val in tests:
        yield assert_almost_equal, cross_entropy(*args), val
コード例 #7
0
ファイル: test_cross_entropy.py プロジェクト: psychon7/dit
def test_cross_entropy_2(d):
    """
    Test that xH(d, d) = H(d).
    """
    assert cross_entropy(d, d) == pytest.approx(entropy(d))
コード例 #8
0
ファイル: test_cross_entropy.py プロジェクト: psychon7/dit
def test_cross_entropy_1(args, expected):
    """
    Test against several known values.
    """
    assert cross_entropy(*args) == pytest.approx(expected)
コード例 #9
0
ファイル: test_cross_entropy.py プロジェクト: Autoplectic/dit
def test_cross_entropy_2(d):
    """
    Test that xH(d, d) = H(d).
    """
    assert cross_entropy(d, d) == pytest.approx(entropy(d))
コード例 #10
0
ファイル: test_cross_entropy.py プロジェクト: Autoplectic/dit
def test_cross_entropy_1(args, expected):
    """
    Test against several known values.
    """
    assert cross_entropy(*args) ==  pytest.approx(expected)