• Home
  • Raw
  • Download

Lines Matching refs:set

51         self.assertRaises(TypeError, set().__init__, a=1)
78 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
79 self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd'))
80 self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg'))
81 self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc'))
82 self.assertEqual(self.thetype('abcba').union(C('ef')), set('abcef'))
83 self.assertEqual(self.thetype('abcba').union(C('ef'), C('fg')), set('abcefg'))
87 self.assertEqual(x.union(set([1]), x, set([2])), self.thetype([1, 2]))
91 self.assertEqual(self.s | set(self.otherword), i)
107 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
108 self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc'))
109 self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set(''))
110 self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc'))
111 self.assertEqual(self.thetype('abcba').intersection(C('ef')), set(''))
112 self.assertEqual(self.thetype('abcba').intersection(C('cbcf'), C('bag')), set('b'))
123 return not set(s1).intersection(s2)
127 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
136 self.assertEqual(self.s & set(self.otherword), i)
153 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
154 self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab'))
155 self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc'))
156 self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a'))
157 self.assertEqual(self.thetype('abcba').difference(C('ef')), set('abc'))
158 self.assertEqual(self.thetype('abcba').difference(), set('abc'))
159 self.assertEqual(self.thetype('abcba').difference(C('a'), C('b')), set('c'))
163 self.assertEqual(self.s - set(self.otherword), i)
180 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
181 self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd'))
182 self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg'))
183 self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a'))
184 self.assertEqual(self.thetype('abcba').symmetric_difference(C('ef')), set('abcef'))
188 self.assertEqual(self.s ^ set(self.otherword), i)
198 self.assertEqual(self.s, set(self.word))
201 self.assertNotEqual(self.s, set(self.otherword))
224 self.assertTrue(set('a').issubset('abc'))
225 self.assertTrue(set('abc').issuperset('a'))
226 self.assertFalse(set('a').issubset('cbs'))
227 self.assertFalse(set('cbs').issuperset('a'))
234 if type(self.s) not in (set, frozenset):
261 s = set(A() for i in xrange(1000))
265 elem.set = set([elem])
273 f=set()
323 d2 = dict.fromkeys(set(d))
337 container = set([obj, 1])
347 thetype = set
352 self.assertEqual(s, set(self.word))
354 self.assertEqual(s, set(self.otherword))
383 self.assertEqual(self.s, set())
457 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
460 self.assertEqual(s, set(q))
463 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
466 self.assertEqual(s, set(s) | set(p) | set(q))
469 self.s |= set(self.otherword)
484 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
487 self.assertEqual(s, set(q))
492 self.assertEqual(s, set('abcba')&set(p)&set(t))
495 self.s &= set(self.otherword)
514 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
517 self.assertEqual(s, set(q))
532 self.s -= set(self.otherword)
550 for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
553 self.assertEqual(s, set(q))
556 self.s ^= set(self.otherword)
582 @unittest.skipUnless(hasattr(set, "test_c_api"),
585 self.assertEqual(set().test_c_api(), True)
587 class SetSubclass(set):
593 class SetSubclassWithKeywordArgs(set):
595 set.__init__(self, iterable)
609 self.assertEqual(s, set(self.word))
618 self.assertEqual(len(set(map(id, efs))), 1)
632 results = set()
658 hashvalues = set()
694 self.assertEqual(len(set(map(id, efs))), len(efs))
698 empty_set = set()
706 self.assertEqual(repr(self.set), self.repr)
709 text = repr(self.set)
722 print >> fo, self.set,
725 self.assertEqual(fo.read(), repr(self.set))
731 self.assertEqual(len(self.set), self.length)
734 self.assertEqual(self.set, self.set)
737 self.assertEqual(self.set, self.dup)
740 self.assertEqual(self.set.copy(), self.dup)
743 result = self.set | self.set
747 result = self.set | empty_set
751 result = empty_set | self.set
755 result = self.set & self.set
759 result = self.set & empty_set
763 result = empty_set & self.set
767 result = self.set.isdisjoint(self.set)
768 self.assertEqual(result, not self.set)
771 result = self.set.isdisjoint(empty_set)
775 result = empty_set.isdisjoint(self.set)
779 result = self.set ^ self.set
783 result = self.set ^ empty_set
784 self.assertEqual(result, self.set)
787 result = self.set - self.set
791 result = self.set - empty_set
795 result = empty_set - self.set
799 for v in self.set:
801 setiter = iter(self.set)
804 self.assertEqual(setiter.__length_hint__(), len(self.set))
808 p = pickle.dumps(self.set, proto)
810 self.assertEqual(self.set, copy,
811 "%s != %s" % (self.set, copy))
819 self.set = set(self.values)
820 self.dup = set(self.values)
830 self.set = set(self.values)
831 self.dup = set(self.values)
836 self.assertIn(3, self.set)
839 self.assertNotIn(2, self.set)
847 self.set = set(self.values)
848 self.dup = set(self.values)
853 self.assertIn((0, "zero"), self.set)
856 self.assertNotIn(9, self.set)
864 self.set = set(self.values)
865 self.dup = set(self.values)
875 self.set = set(self.values)
876 self.dup = set(self.values)
888 self.set = set(self.values)
889 self.dup = set(self.values)
901 self.set = set(self.values)
902 self.dup = set(self.values)
922 self.assertRaises(TypeError, set, baditer())
926 set([1,2,3])
927 set((1,2,3))
928 set({'one':1, 'two':2, 'three':3})
929 set(xrange(3))
930 set('abc')
931 set(gooditer())
934 s = set([1,2,3])
948 outer = set([inner])
953 self.assertEqual(outer, set()) # Verify that remove worked
960 self.set = set((2, 4, 6))
963 self.assertEqual(self.set, set({2:1,4:3,6:5}))
966 result = self.set | set([2])
967 self.assertEqual(result, set((2, 4, 6)))
970 result = self.set | set([2, 4, 6, 8])
971 self.assertEqual(result, set([2, 4, 6, 8]))
974 result = self.set | set([3, 4, 5])
975 self.assertEqual(result, set([2, 3, 4, 5, 6]))
978 result = self.set | set([8])
979 self.assertEqual(result, set([2, 4, 6, 8]))
982 result = self.set & set((2, 4))
983 self.assertEqual(result, set((2, 4)))
986 result = self.set & set([2, 4, 6, 8])
987 self.assertEqual(result, set([2, 4, 6]))
990 result = self.set & set([3, 4, 5])
991 self.assertEqual(result, set([4]))
994 result = self.set & set([8])
998 result = self.set.isdisjoint(set((2, 4)))
1002 result = self.set.isdisjoint(set([2, 4, 6, 8]))
1006 result = self.set.isdisjoint(set([3, 4, 5]))
1010 result = self.set.isdisjoint(set([8]))
1014 result = self.set ^ set((2, 4))
1015 self.assertEqual(result, set([6]))
1018 result = self.set ^ set((2, 4, 6, 8))
1019 self.assertEqual(result, set([8]))
1022 result = self.set ^ set((3, 4, 5))
1023 self.assertEqual(result, set([2, 3, 5, 6]))
1026 result = self.set ^ set([8])
1027 self.assertEqual(result, set([2, 4, 6, 8]))
1030 a, b = set('a'), set('b')
1044 self.set = set((2, 4, 6))
1047 self.set |= set([2])
1048 self.assertEqual(self.set, set((2, 4, 6)))
1051 self.set |= set([2, 4, 6, 8])
1052 self.assertEqual(self.set, set([2, 4, 6, 8]))
1055 self.set |= set([3, 4, 5])
1056 self.assertEqual(self.set, set([2, 3, 4, 5, 6]))
1059 self.set |= set([8])
1060 self.assertEqual(self.set, set([2, 4, 6, 8]))
1063 self.set.update(set([3, 4, 5]))
1064 self.assertEqual(self.set, set([2, 3, 4, 5, 6]))
1067 self.set &= set((2, 4))
1068 self.assertEqual(self.set, set((2, 4)))
1071 self.set &= set([2, 4, 6, 8])
1072 self.assertEqual(self.set, set([2, 4, 6]))
1075 self.set &= set([3, 4, 5])
1076 self.assertEqual(self.set, set([4]))
1079 self.set &= set([8])
1080 self.assertEqual(self.set, empty_set)
1083 self.set.intersection_update(set([3, 4, 5]))
1084 self.assertEqual(self.set, set([4]))
1087 self.set ^= set((2, 4))
1088 self.assertEqual(self.set, set([6]))
1091 self.set ^= set((2, 4, 6, 8))
1092 self.assertEqual(self.set, set([8]))
1095 self.set ^= set((3, 4, 5))
1096 self.assertEqual(self.set, set([2, 3, 5, 6]))
1099 self.set ^= set([8])
1100 self.assertEqual(self.set, set([2, 4, 6, 8]))
1103 self.set.symmetric_difference_update(set([3, 4, 5]))
1104 self.assertEqual(self.set, set([2, 3, 5, 6]))
1107 self.set -= set((2, 4))
1108 self.assertEqual(self.set, set([6]))
1111 self.set -= set((2, 4, 6, 8))
1112 self.assertEqual(self.set, set([]))
1115 self.set -= set((3, 4, 5))
1116 self.assertEqual(self.set, set([2, 6]))
1119 self.set -= set([8])
1120 self.assertEqual(self.set, set([2, 4, 6]))
1123 self.set.difference_update(set([3, 4, 5]))
1124 self.assertEqual(self.set, set([2, 6]))
1131 self.set = set(self.values)
1134 self.set.add("c")
1135 self.assertEqual(self.set, set("abc"))
1138 self.set.add("d")
1139 self.assertEqual(self.set, set("abcd"))
1142 tmp = set()
1148 self.assertEqual(tmp, self.set)
1151 self.set.remove("b")
1152 self.assertEqual(self.set, set("ac"))
1156 self.set.remove("d")
1162 expected_len = len(self.set)
1164 self.set.remove(v)
1166 self.assertEqual(len(self.set), expected_len)
1169 self.set.discard("c")
1170 self.assertEqual(self.set, set("ab"))
1173 self.set.discard("d")
1174 self.assertEqual(self.set, set("abc"))
1177 self.set.clear()
1178 self.assertEqual(len(self.set), 0)
1182 while self.set:
1183 popped[self.set.pop()] = None
1189 self.set.update(())
1190 self.assertEqual(self.set, set(self.values))
1193 self.set.update(("a",))
1194 self.assertEqual(self.set, set(self.values))
1197 self.set.update(("a", "z"))
1198 self.assertEqual(self.set, set(self.values + ["z"]))
1241 left = set()
1242 right = set()
1249 left = set([1, 2])
1250 right = set([1, 2])
1257 left = set()
1258 right = set([1, 2])
1265 left = set([1])
1266 right = set([1, 2])
1273 left = set([1])
1274 right = set([2])
1284 self.assertEqual(self.other == self.set, False)
1285 self.assertEqual(self.set == self.other, False)
1286 self.assertEqual(self.other != self.set, True)
1287 self.assertEqual(self.set != self.other, True)
1291 self.set |= self.other
1299 self.set.update(self.other)
1301 self.assertRaises(TypeError, self.set.update, self.other)
1304 self.assertRaises(TypeError, lambda: self.set | self.other)
1305 self.assertRaises(TypeError, lambda: self.other | self.set)
1307 self.set.union(self.other)
1309 self.assertRaises(TypeError, self.set.union, self.other)
1313 self.set &= self.other
1321 self.set.intersection_update(self.other)
1324 self.set.intersection_update,
1328 self.assertRaises(TypeError, lambda: self.set & self.other)
1329 self.assertRaises(TypeError, lambda: self.other & self.set)
1331 self.set.intersection(self.other)
1333 self.assertRaises(TypeError, self.set.intersection, self.other)
1337 self.set ^= self.other
1345 self.set.symmetric_difference_update(self.other)
1348 self.set.symmetric_difference_update,
1352 self.assertRaises(TypeError, lambda: self.set ^ self.other)
1353 self.assertRaises(TypeError, lambda: self.other ^ self.set)
1355 self.set.symmetric_difference(self.other)
1357 self.assertRaises(TypeError, self.set.symmetric_difference, self.other)
1361 self.set -= self.other
1369 self.set.difference_update(self.other)
1372 self.set.difference_update,
1376 self.assertRaises(TypeError, lambda: self.set - self.other)
1377 self.assertRaises(TypeError, lambda: self.other - self.set)
1379 self.set.difference(self.other)
1381 self.assertRaises(TypeError, self.set.difference, self.other)
1387 self.set = set((1, 2, 3))
1395 self.set = set((1, 2, 3))
1403 self.set = set((1, 2, 3))
1411 self.set = set((1, 2, 3))
1422 self.set = set((1, 2, 3))
1431 dup = list(self.set.copy())
1432 self.assertEqual(len(dup), len(self.set))
1433 for el in self.set:
1440 dup = copy.deepcopy(self.set)
1441 self.assertSetEqual(dup, self.set)
1447 self.set = set()
1453 self.set = set(["hello"])
1459 self.set = set(["zero", 0, None])
1465 self.set = set([(1, 2)])
1471 self.set = set([((1, 2), (3, 4))])
1477 self.a = set('abracadabra')
1478 self.b = set('alacazam')
1511 a, b, zero = self.a, self.b, set()
1598 for cons in (set, frozenset):
1601 self.assertSetEqual(cons(g(s)), set(g(s)))
1607 s = set('november')
1626 s = set('january')
1632 self.assertRaises(TypeError, getattr(set('january'), methname), X(data))
1633 self.assertRaises(TypeError, getattr(set('january'), methname), N(data))
1634 self.assertRaises(ZeroDivisionError, getattr(set('january'), methname), E(data))
1671 s = set(range(100))
1714 f = set()
1742 vertices1 = set(g)
1746 vertices2 = set(v for edges in g.values() for v in edges)
1764 vertices = set(cuboctahedron)
1767 othervertices = set(edge for edges in cuboctahedron.values() for edge in edges)