MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / RandomSet

Class RandomSet

lib/sqlalchemy/testing/util.py:79–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78
79class RandomSet(set):
80 def __iter__(self):
81 l = list(set.__iter__(self))
82 random.shuffle(l)
83 return iter(l)
84
85 def pop(self):
86 index = random.randint(0, len(self) - 1)
87 item = list(set.__iter__(self))[index]
88 self.remove(item)
89 return item
90
91 def union(self, other):
92 return RandomSet(set.union(self, other))
93
94 def difference(self, other):
95 return RandomSet(set.difference(self, other))
96
97 def intersection(self, other):
98 return RandomSet(set.intersection(self, other))
99
100 def copy(self):
101 return RandomSet(self)
102
103
104def conforms_partial_ordering(tuples, sorted_elements):

Callers 4

unionMethod · 0.85
differenceMethod · 0.85
intersectionMethod · 0.85
copyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected