本文整理汇总了Python中sortedcontainers.SortedSet.difference_update方法的典型用法代码示例。如果您正苦于以下问题:Python SortedSet.difference_update方法的具体用法?Python SortedSet.difference_update怎么用?Python SortedSet.difference_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedSet
的用法示例。
在下文中一共展示了SortedSet.difference_update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_difference_update
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import difference_update [as 别名]
def test_difference_update():
temp = SortedSet(range(100), load=7)
temp.difference_update(range(0, 10), range(10, 20))
assert all((val + 20) == temp[val] for val in range(80))
示例2: Chunk
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import difference_update [as 别名]
#.........这里部分代码省略.........
return filter(lambda t: self in t.chunks, self.feature.tests)
def modify(self, random):
feature_chunks = self.feature.chunks - {self}
system_chunks = set(self.feature.software_system.chunks.difference(self.feature.chunks))
self._add_dependencies(random, system_chunks, self.probability_gain_system_dependency)
self._add_dependencies(random, feature_chunks, self.probability_gain_feature_dependency)
self.local_content = random.create_local_content()
self._insert_bugs(random)
def merge(self, source_chunk, random):
for dependency in source_chunk.dependencies:
working_copy_dependency = self.feature.software_system.get_chunk(dependency.fully_qualified_name)
self.dependencies.add(working_copy_dependency)
self.modify(random)
def overwrite_with(self, source_chunk):
self.local_content = source_chunk.local_content
self.bugs.clear()
for old_bug in source_chunk.bugs:
new_bug = self.get_bug(old_bug.logical_name)
if new_bug is None:
self.add_bug(old_bug.logical_name)
self.dependencies.clear()
for dependency in source_chunk.dependencies:
new_dependency = self.feature.software_system.get_chunk(dependency.fully_qualified_name)
self.dependencies.add(new_dependency)
def _add_dependencies(self, random, candidate_chunks, threshold):
for candidate in SortedSet(candidate_chunks, key=lambda c: c.logical_name):
if random.dependency_should_be_added(threshold):
self.add_dependency(candidate)
def add_dependency(self, candidate):
self.dependencies.add(candidate)
def _insert_bugs(self, random):
while random.a_bug_should_be_inserted(self):
self.add_bug(self.bug_count)
self.bug_count += 1
def add_bug(self, logical_name):
self.bugs.add(Bug(logical_name, self))
def get_bug(self, logical_name):
result = filter(lambda bug: bug.logical_name == logical_name, self.bugs)
if len(result) is 0:
return None
else:
return result[0]
def refactor(self, random):
to_remove = set()
for dependency in self.dependencies:
if random.dependency_should_be_removed(self, dependency):
to_remove.add(dependency)
self.dependencies.difference_update(to_remove)
def debug(self, random, bug=None):
if len(self.bugs) == 0:
return False
if bug is None or bug not in self.bugs:
if random.unknown_bug_should_be_removed(self):
bug = random.choose_bug(self)
self.bugs.remove(bug)
elif random.known_bug_should_be_removed(self):
self.bugs.remove(bug)
def operate(self, random):
for bug in self.bugs_in_dependencies.union(self.bugs):
bug.manifest(random)
def __str__(self):
def string_repr_set(iterable):
return ",".join(map(lambda e: repr(e), iterable))
feature_dependencies = string_repr_set(filter(lambda c: c.feature == self.feature, self.dependencies))
system_dependencies = string_repr_set(filter(lambda c: c.feature != self.feature, self.dependencies))
bugs = ", ".join(map(lambda bug: str(bug), self.bugs))
return "c_%s:[%s]:[%s]->(in[%s],ex[%s])" % \
(str(self.logical_name), self.local_content, bugs, feature_dependencies, system_dependencies)
@property
def fully_qualified_name(self):
return "%s.%s" % (str(self.feature.logical_name), str(self.logical_name))
def __repr__(self):
return "c%s" % str(self.fully_qualified_name)