コード例 #1
0
 def test_attribute_folders_L2(self):
     self.analyzer.attribute_folders(self.L2, 2)
     folders = self.analyzer.L_folders
     self.assertEqual(len(folders[GCA.key_folder(['a'])]), 5)
     self.assertEqual(len(folders[GCA.key_folder(['b'])]), 2)
     self.assertEqual(len(folders[GCA.key_folder(['d'])]), 3)
     self.assertEqual(len(folders[GCA.key_folder(['e'])]), 2)
     self.assertEqual(len(folders[GCA.key_folder(['f'])]), 4)
     self.assertEqual(len(folders[GCA.key_folder(['g'])]), 2)
     self.assertEqual(len(folders[GCA.key_folder(['h'])]), 1)
     self.assertNotIn(GCA.key_folder(['c']), folders)
コード例 #2
0
    def test_EOB_L2(self):
        self.analyzer.attribute_folders(self.L2, 2)
        self.analyzer.extend_merge(self.L2, 2)
        folders = self.analyzer.L_folders

        self.assertEqual(len(self.analyzer.L_folders), 5)

        self.assertEqual(len(folders[GCA.key_folder(['d'])]), 2)
        self.assertEqual(len(folders[GCA.key_folder(['a'])]), 4)
        self.assertEqual(len(folders[GCA.key_folder(['g'])]), 3)
        self.assertEqual(len(folders[GCA.key_folder(['f'])]), 3)
        self.assertEqual(len(folders[GCA.key_folder(['h'])]), 1)

        folder = folders[GCA.key_folder(['d'])]
        self.assertEqual(folder[0].closure,
                         frozenset(('a', 'd', 'f', 'g', 'h', 'e', 'g')))
        self.assertEqual(folder[0].generators, [['d', 'g'], ['d', 'e']])
        self.assertEqual(folder[0].transactions, set([3]))
        self.assertEqual(folder[0].support, 1)
        self.assertEqual(folder[1].closure, frozenset(
            ('a', 'd', 'f', 'h', 'c')))
        self.assertEqual(folder[1].generators, [['d', 'c']])
        self.assertEqual(folder[1].transactions, set([2]))
        self.assertEqual(folder[1].support, 1)

        folder = folders[GCA.key_folder(['a'])]
        self.assertEqual(folder[0].closure, frozenset(('a', 'h', 'f')))
        self.assertEqual(folder[0].generators, [['a', 'f']])
        self.assertEqual(folder[0].transactions, set([2, 3]))
        self.assertEqual(folder[0].support, 2)
        self.assertEqual(folder[1].closure, frozenset(('a', 'h', 'e', 'g')))
        self.assertEqual(folder[1].generators, [['a', 'g'], ['a', 'e']])
        self.assertEqual(folder[1].transactions, set([1, 3]))
        self.assertEqual(folder[1].support, 2)
        self.assertEqual(folder[2].closure,
                         frozenset(('a', 'h', 'b', 'c', 'e', 'g')))
        self.assertEqual(folder[2].generators, [['a', 'b']])
        self.assertEqual(folder[2].transactions, set([1]))
        self.assertEqual(folder[2].support, 1)
        self.assertEqual(folder[3].closure, frozenset(('a', 'h', 'c')))
        self.assertEqual(folder[3].generators, [['a', 'c']])
        self.assertEqual(folder[3].transactions, set([1, 2]))
        self.assertEqual(folder[3].support, 2)

        folder = folders[GCA.key_folder(['g'])]
        self.assertEqual(folder[0].closure, frozenset(
            ('e', 'g', 'h', 'b', 'c')))
        self.assertEqual(folder[0].generators,
                         [['g', 'b'], ['g', 'c'], ['b', 'h']])
        self.assertEqual(folder[0].transactions, set([1, 4]))
        self.assertEqual(folder[0].support, 2)
        self.assertEqual(folder[1].closure, frozenset(('b', 'c', 'e')))
        self.assertEqual(folder[1].generators, [['b', 'e'], ['e', 'c']])
        self.assertEqual(folder[1].transactions, set([1, 4, 5]))
        self.assertEqual(folder[1].support, 3)
        self.assertEqual(folder[2].closure, frozenset(('e', 'h')))
        self.assertEqual(folder[2].generators, [['e', 'h']])
        self.assertEqual(folder[2].transactions, set([1, 3, 4]))
        self.assertEqual(folder[2].support, 3)

        folder = folders[GCA.key_folder(['f'])]
        self.assertEqual(folder[0].closure, frozenset(('f', 'h', 'e', 'g')))
        self.assertEqual(folder[0].generators, [['f', 'g'], ['f', 'e']])
        self.assertEqual(folder[0].transactions, set([3, 4]))
        self.assertEqual(folder[0].support, 2)
        self.assertEqual(folder[1].closure,
                         frozenset(('f', 'h', 'b', 'c', 'e', 'g')))
        self.assertEqual(folder[1].generators, [['f', 'b']])
        self.assertEqual(folder[1].transactions, set([4]))
        self.assertEqual(folder[1].support, 1)
        self.assertEqual(folder[2].closure, frozenset(('f', 'h', 'c')))
        self.assertEqual(folder[2].generators, [['f', 'c']])
        self.assertEqual(folder[2].transactions, set([2, 4]))
        self.assertEqual(folder[2].support, 2)