コード例 #1
0
def test_ped_cs2():
    """
    Test iccs on SUM.
    """
    d = D(['000','011','101','112'], [1/4.0]*4)
    pid = PED_CS(d)
    for atom in pid._lattice:
        if atom in [((1,),(2,)), ((0,),(2,)), ((0,),(1,2)), ((1,),(0,2)), ((2,),(0,1))]:
            assert pid[atom] == pytest.approx(0.5)
        elif atom == ((0,1),(0,2),(1,2)):
            assert pid[atom] == pytest.approx(-0.5)
        else:
            assert pid[atom] == pytest.approx(0.0)
コード例 #2
0
def test_ped_cs4():
    d = D(['00', '01', '10', '11'], [0.4, 0.1, 0.1, 0.4])
    ped = PED_CS(d)
    string = """\
+--------+--------+--------+
|  H_cs  |  H_r   |  H_d   |
+--------+--------+--------+
| {0:1}  | 1.7219 | 0.2644 |
|  {0}   | 1.0000 | 0.4575 |
|  {1}   | 1.0000 | 0.4575 |
| {0}{1} | 0.5425 | 0.5425 |
+--------+--------+--------+"""
    assert str(ped) == string
コード例 #3
0
def test_ped_cs2():
    """
    Test iccs on AND.
    """
    d = bivariates['and']
    pid = PED_CS(d, inputs=((0, ), (1, ), (2, )))
    for atom in pid._lattice:
        if atom == ((0, ), (1, ), (2, )):
            assert pid[atom] == pytest.approx(0.10375937481971094)
        elif atom == ((0, ), (1, )):
            assert pid[atom] == pytest.approx(-0.10375937481971098)
        elif atom in [((0, ), (2, )), ((1, ), (2, ))]:
            assert pid[atom] == pytest.approx(0.35375937481971098)
        elif atom in [((0, ), (1, 2)), ((1, ), (0, 2))]:
            assert pid[atom] == pytest.approx(0.14624062518028902)
        elif atom in [((0, ), ), ((1, ), )]:
            assert pid[atom] == pytest.approx(0.5)
        else:
            assert pid[atom] == pytest.approx(0.0)
コード例 #4
0
ファイル: test_hcs.py プロジェクト: psychon7/dit
def test_ped_cs1():
    """
    Test iccs on AND.
    """
    d = bivariates['and']
    pid = PED_CS(d)
    zero, one, two = [frozenset([i]) for i in range(3)]
    for atom in pid._lattice:
        if atom == ((0, ), (1, ), (2, )):
            assert pid[atom] == pytest.approx(0.10375937481971094)
        elif atom == ((0, ), (1, )):
            assert pid[atom] == pytest.approx(-0.10375937481971098)
        elif atom in [((0, ), (2, )), ((1, ), (2, ))]:
            assert pid[atom] == pytest.approx(0.35375937481971098)
        elif atom in [((0, ), (1, 2)), ((1, ), (0, 2))]:
            assert pid[atom] == pytest.approx(0.14624062518028902)
        elif atom in [((0, ), ), ((1, ), )]:
            assert pid[atom] == pytest.approx(0.5)
        else:
            assert pid[atom] == pytest.approx(0.0)