Example #1
0
 def test_union(self):
     C = fuzz.FuzzySet()
     C.add('a', 1.0)
     C.add('b', 0.8)
     C.add('c', 0.8)
     C.add('d', 0.6)
     self.assertEqual(self.A | self.B, C)
     D = fuzz.FuzzySet()
     D.add('a', 1.0)
     D.add('b', 0.9)
     D.add('c', 0.84)
     D.add('d', 0.6)
     self.assertEqual(self.A.union(self.B, fuzz.FuzzySet.NORM_ALGEBRAIC), D)
Example #2
0
 def test_complement(self):
     D = fuzz.FuzzySet()
     D.add('b', 0.2)
     D.add('c', 0.8)
     D.add('d', 0.4)
     D.add('e', 1.0)
     self.assertEqual(self.B.complement(), D)
Example #3
0
 def test_pop(self):
     A = [
         fuzz.FuzzyElement('a', 1.0),
         fuzz.FuzzyElement('c', 0.8),
         fuzz.FuzzyElement('b', 0.5)
     ]
     self.assertTrue(self.A.pop() in A)
     self.assertTrue(self.A.pop() in A)
     self.assertTrue(self.A.pop() in A)
     self.assertEqual(self.A, fuzz.FuzzySet())
Example #4
0
 def test_disjoint(self):
     self.assertFalse(self.A.isdisjoint(self.B))
     self.assertFalse(self.B.isdisjoint(self.A))
     C = fuzz.FuzzySet(['e', 'f'])
     self.assertTrue(self.A.isdisjoint(C))
     self.assertTrue(self.B.isdisjoint(C))
Example #5
0
 def test_clear(self):
     self.A.clear()
     self.assertEqual(self.A, fuzz.FuzzySet())
Example #6
0
 def test_to_fuzzy_set(self):
     F = fuzz.FuzzySet()
     F.add(1.5, 0.25)
     F.add(6.0, 0.8)
     self.assertEqual(self.X.to_fuzzy_set([1.5, 6.0]), F)