Beispiel #1
0
    def test_difference(self):
        ps1 = self.seed_power_set('abcdef', 100, 2)
        ps2 = self.seed_power_set('ghjkl', 100, 2)

        ps = ps1.difference(ps2)
        for val in ps.get_val():
            self.assertEqual(ps1.get(val), True)
            self.assertEqual(ps2.get(val), False)

        ps1 = PowerSet()
        ps2 = self.seed_power_set('ghjkl', 100, 2)
        ps = ps1.difference(ps2)
        self.assertEqual(ps.size(), 0)

        ps1 = self.seed_power_set('ghjkl', 100, 2)
        ps2 = copy.deepcopy(ps1)
        ps = ps1.difference(ps2)
        self.assertEqual(ps.size(), 0)
Beispiel #2
0
    def test_powerSetDiffirenceHundredsElements(self):
        ps = PowerSet()
        ps1 = PowerSet()

        for i in range(1, 101):
            ps.put(i)

        for i in range(50, 151):
            ps1.put(i)

        psDiffirence = ps.difference(ps1)
        self.assertEqual(psDiffirence.size(), 49)
Beispiel #3
0
    def test_powerSetDifferenceManyElements(self):
        ps = PowerSet()
        for i in range(1, 10001):
            ps.put(i)

        ps1 = PowerSet()
        for i in range(9900, 20001):
            ps1.put(i)

        start_time = time.time()
        psDiffirence = ps.difference(ps1)
        self.assertEqual(psDiffirence.size(), 9899)
        print('time to processing', time.time() - start_time)
Beispiel #4
0
    def test_powerSetDiffirence(self):
        ps = PowerSet()
        ps.put(1)
        ps.put(-5)
        ps.put(13)
        ps.put(0)
        ps.put(4)
        ps.put(9)
        ps.put(92)
        ps.put(131)
        ps.put(11)
        ps.put(18)

        ps1 = PowerSet()
        ps1.put(1)
        ps1.put(-5)
        ps1.put(13)
        ps1.put(0)
        ps1.put(4)
        ps1.put(9)
        ps1.put(92)
        ps1.put(131)
        ps1.put(11)
        ps1.put(18)
        psDiffirence = ps.difference(ps1)
        self.assertEqual(psDiffirence.size(), 0)

        ps1 = PowerSet()
        ps1.put(1)
        ps1.put(-5)
        ps1.put(13)
        ps1.put(0)
        ps1.put(4)
        ps1.put(9)
        ps1.put(92)
        ps1.put(131)
        ps1.put(11)
        psDiffirence = ps.difference(ps1)
        self.assertEqual(psDiffirence.size(), 1)