MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / RandomSet

Class RandomSet

lib/sqlalchemy/testing/util.py:120–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119
120class RandomSet(set):
121 def __iter__(self):
122 l = list(set.__iter__(self))
123 random.shuffle(l)
124 return iter(l)
125
126 def pop(self):
127 index = random.randint(0, len(self) - 1)
128 item = list(set.__iter__(self))[index]
129 self.remove(item)
130 return item
131
132 def union(self, other):
133 return RandomSet(set.union(self, other))
134
135 def difference(self, other):
136 return RandomSet(set.difference(self, other))
137
138 def intersection(self, other):
139 return RandomSet(set.intersection(self, other))
140
141 def copy(self):
142 return RandomSet(self)
143
144
145def 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