コード例 #1
0
    def test_sum_counter_L1(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L1.txt"))
        tl_aug = tl.augment()
        target = {
            "[]": 20,
            "[>": 20,
            "a1": 20,
            "a2": 20,
            "a3": 14,
            "a4": 34,
            "a5": 34,
            "a6": 14,
            "a7": 9,
            "a8": 11,
        }

        count = tl_aug.sum_counter()

        for k, v in count.items():
            assert k in target
            assert target[k] == v

        for a, f in target.items():
            assert a in count
            assert count[a] == f
コード例 #2
0
    def test_successors_L1(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L1.txt"))
        tl = tl.augment()

        target = {
            ("[>", "a1"): 20,
            ("a1", "a2"): 10,
            ("a1", "a3"): 3,
            ("a1", "a4"): 7,
            ("a2", "a4"): 13,
            ("a2", "a5"): 7,
            ("a3", "a4"): 8,
            ("a3", "a5"): 6,
            ("a4", "a2"): 7,
            ("a4", "a3"): 6,
            ("a4", "a5"): 21,
            ("a5", "a6"): 14,
            ("a5", "a7"): 9,
            ("a5", "a8"): 11,
            ("a6", "a2"): 3,
            ("a6", "a3"): 5,
            ("a6", "a4"): 6,
            ("a7", "[]"): 9,
            ("a8", "[]"): 11,
        }

        s_tl = tl.follows()

        for k, v in target.items():
            assert k in s_tl
            assert s_tl[k] == v

        for k, v in s_tl.items():
            assert k in target
            assert target[k] == v
コード例 #3
0
    def test_augment(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L2.txt"))
        target = {
            ("[>", "a", "b", "c", "d", "[]"):
            3,
            ("[>", "a", "c", "b", "d", "[]"):
            4,
            ("[>", "a", "b", "c", "e", "f", "b", "c", "d", "[]"):
            2,
            ("[>", "a", "b", "c", "e", "f", "c", "b", "d", "[]"):
            1,
            ("[>", "a", "c", "b", "e", "f", "b", "c", "d", "[]"):
            2,
            ("[>", "a", "c", "b", "e", "f", "b", "c", "e", "f", "c", "b", "d", "[]"):
            1,
        }
        tl_aug = tl.augment()

        for k, v in target.items():
            assert k in tl_aug
            assert tl_aug[k] == v

        for k, v in tl_aug.items():
            assert k in target
            assert target[k] == v
コード例 #4
0
    def test_equivalence_L4(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L4.txt"))
        target = {("[]", "[>")}
        tl_aug = tl.augment()
        R_eq = tl_aug.equivalence()

        for el in target:
            assert el in R_eq or el[::-1] in R_eq

        for el in R_eq:
            assert el in target or el[::-1] in target
コード例 #5
0
ファイル: test_objects.py プロジェクト: brucelit/skelevision
    def test_never_together_L1(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L1.txt"))
        target = {("a7", "a8")}

        nt = tl.never_together()

        for pair in nt:
            assert pair in target

        for pair in target:
            assert pair in nt
コード例 #6
0
    def test_always_after_L1(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L1.txt"))
        target = {("[>", "a1"), ("[>", "a4"), ("[>", "a5"), ("[>", "[]"),
                  ("a1", "a4"), ("a1", "a5"), ("a1", "[]"), ("a2", "a5"),
                  ("a2", "[]"), ("a3", "[]"), ("a3", "a5"), ("a4", "a5"),
                  ("a4", "[]"), ("a5", "[]"), ("a6", "a4"), ("a6", "a5"),
                  ("a6", "[]"), ("a7", "[]"), ("a8", "[]")}
        tl_aug = tl.augment()
        R_aa = tl_aug.always_after()

        for pair in R_aa:
            assert pair in target

        for pair in target:
            assert pair in R_aa
コード例 #7
0
    def test_from_txt(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L2.txt"))
        target = {
            ("a", "b", "c", "d"): 3,
            ("a", "c", "b", "d"): 4,
            ("a", "b", "c", "e", "f", "b", "c", "d"): 2,
            ("a", "b", "c", "e", "f", "c", "b", "d"): 1,
            ("a", "c", "b", "e", "f", "b", "c", "d"): 2,
            ("a", "c", "b", "e", "f", "b", "c", "e", "f", "c", "b", "d"): 1,
        }

        for k, v in target.items():
            assert k in tl
            assert tl[k] == v

        for k, v in tl.items():
            assert k in target
            assert target[k] == v
コード例 #8
0
    def test_equivalence_L2(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L2.txt"))
        target = {
            ("[]", "[>"),
            ("a", "[]"),
            ("a", "[>"),
            ("d", "[]"),
            ("d", "[>"),
            ("a", "d"),
            ("b", "c"),
            ("e", "f"),
        }
        tl_aug = tl.augment()
        R_eq = tl_aug.equivalence()

        for el in target:
            assert el in R_eq or el[::-1] in R_eq

        for el in R_eq:
            assert el in target or el[::-1] in target
コード例 #9
0
    def test_max_counter_L4(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L4.txt"))
        tl_aug = tl.augment()
        target = {
            "[]": 1,
            "[>": 1,
            "a": 1,
            "b": 1,
            "c": 2,
            "d": 1,
            "e": 1,
        }
        count = tl_aug.max_counter()

        for k, v in count.items():
            assert k in target
            assert target[k] == v

        for a, f in target.items():
            assert a in count
            assert count[a] == f
コード例 #10
0
    def test_sum_counter_L4(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L4.txt"))
        tl_aug = tl.augment()
        target = {
            "[]": 255,
            "[>": 255,
            "a": 128,
            "b": 127,
            "c": 363,
            "d": 174,
            "e": 81,
        }

        count = tl_aug.sum_counter()
        print(count)

        for k, v in count.items():
            assert k in target
            assert target[k] == v

        for a, f in target.items():
            assert a in count
            assert count[a] == f
コード例 #11
0
 def test_from_txt_exception_invalid_frequency(self):
     with pytest.raises(IllegalLogAction):
         tl = TraceLog.from_txt(
             os.path.join(DATA, "L2_invalid_frequency.txt"))
コード例 #12
0
 def test_from_txt_exception_duplicate_trace(self):
     with pytest.raises(IllegalLogAction):
         tl = TraceLog.from_txt(os.path.join(DATA,
                                             "L2_duplicate_trace.txt"))
コード例 #13
0
    def test_mine(self):
        tl = TraceLog.from_txt(os.path.join(DATA, "L1.txt"))
        miner = LogSkeleton()
        results = miner.mine(tl, {}, {})

        target_results = {
            "relationships": {
                "equivalence": {("[]", "[>"), ("a1", "[]"), ("a1", "[>"), ("a4", "a5")},
                "alwaysAfter": {
                    ("[>", "a1"),
                    ("[>", "a4"),
                    ("[>", "a5"),
                    ("[>", "[]"),
                    ("a1", "a4"),
                    ("a1", "a5"),
                    ("a1", "[]"),
                    ("a2", "a5"),
                    ("a2", "[]"),
                    ("a3", "[]"),
                    ("a3", "a5"),
                    ("a4", "a5"),
                    ("a4", "[]"),
                    ("a5", "[]"),
                    ("a6", "a4"),
                    ("a6", "a5"),
                    ("a6", "[]"),
                    ("a7", "[]"),
                    ("a8", "[]"),
                },
                "alwaysBefore": {
                    ("a1", "[>"),
                    ("a2", "[>"),
                    ("a3", "[>"),
                    ("a4", "[>"),
                    ("a5", "[>"),
                    ("a6", "[>"),
                    ("a7", "[>"),
                    ("a8", "[>"),
                    ("[]", "[>"),
                    ("a2", "a1"),
                    ("a3", "a1"),
                    ("a4", "a1"),
                    ("a5", "a1"),
                    ("a6", "a1"),
                    ("a7", "a1"),
                    ("a8", "a1"),
                    ("[]", "a1"),
                    ("a5", "a4"),
                    ("a6", "a4"),
                    ("a7", "a4"),
                    ("a8", "a4"),
                    ("[]", "a4"),
                    ("a6", "a5"),
                    ("a7", "a5"),
                    ("a8", "a5"),
                    ("[]", "a5"),
                },
                "neverTogether": {("a7", "a8")},
                "dependency": {
                    ("[>", "a1"),
                    ("a1", "a2"),
                    ("a1", "a3"),
                    ("a1", "a4"),
                    ("a2", "a4"),
                    ("a2", "a5"),
                    ("a3", "a4"),
                    ("a3", "a5"),
                    ("a4", "a2"),
                    ("a4", "a3"),
                    ("a4", "a5"),
                    ("a5", "a6"),
                    ("a5", "a7"),
                    ("a5", "a8"),
                    ("a6", "a2"),
                    ("a6", "a3"),
                    ("a6", "a4"),
                    ("a7", "[]"),
                    ("a8", "[]"),
                },
            },
            "statistics": {
                "dependency": {
                    ("[>", "a1"): 20,
                    ("a1", "a2"): 10,
                    ("a1", "a3"): 3,
                    ("a1", "a4"): 7,
                    ("a2", "a4"): 13,
                    ("a2", "a5"): 7,
                    ("a3", "a4"): 8,
                    ("a3", "a5"): 6,
                    ("a4", "a2"): 7,
                    ("a4", "a3"): 6,
                    ("a4", "a5"): 21,
                    ("a5", "a6"): 14,
                    ("a5", "a7"): 9,
                    ("a5", "a8"): 11,
                    ("a6", "a2"): 3,
                    ("a6", "a3"): 5,
                    ("a6", "a4"): 6,
                    ("a7", "[]"): 9,
                    ("a8", "[]"): 11,
                },
                "sum": {
                    "[]": 20,
                    "[>": 20,
                    "a1": 20,
                    "a2": 20,
                    "a3": 14,
                    "a4": 34,
                    "a5": 34,
                    "a6": 14,
                    "a7": 9,
                    "a8": 11,
                },
                "max": {
                    "[]": 1,
                    "[>": 1,
                    "a1": 1,
                    "a2": 3,
                    "a3": 2,
                    "a4": 4,
                    "a5": 4,
                    "a6": 3,
                    "a7": 1,
                    "a8": 1,
                },
                "min": {
                    "[]": 1,
                    "[>": 1,
                    "a1": 1,
                    "a2": 0,
                    "a3": 0,
                    "a4": 1,
                    "a5": 1,
                    "a6": 0,
                    "a7": 0,
                    "a8": 0,
                },
            },
        }