当前位置: 首页>>代码示例>>Python>>正文


Python SortedSet.clear方法代码示例

本文整理汇总了Python中sortedcontainers.SortedSet.clear方法的典型用法代码示例。如果您正苦于以下问题:Python SortedSet.clear方法的具体用法?Python SortedSet.clear怎么用?Python SortedSet.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sortedcontainers.SortedSet的用法示例。


在下文中一共展示了SortedSet.clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_init

# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import clear [as 别名]
def test_init():
    sst = SortedSet()
    sst._check()

    sst = SortedSet()
    sst._reset(10000)
    assert sst._list._load == 10000
    sst._check()

    sst = SortedSet(range(10000))
    assert all(tup[0] == tup[1] for tup in zip(sst, range(10000)))

    sst.clear()
    assert len(sst) == 0
    assert list(iter(sst)) == []
    sst._check()
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:18,代码来源:test_stress_sortedset.py

示例2: test_clear

# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import clear [as 别名]
def test_clear():
    temp = SortedSet(range(100), load=7)
    temp.clear()
    temp._check()
    assert len(temp) == 0
开发者ID:Muon,项目名称:sorted_containers,代码行数:7,代码来源:test_coverage_sortedset.py

示例3: Chunk

# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import clear [as 别名]
class Chunk(object):
    """
    Represents a chunk of code providing some useful functionality in the system.
    """

    def __init__(self, logical_name, feature, local_content=None):
        self.logical_name = logical_name

        self.feature = feature

        self.local_content = local_content

        self.dependencies = SortedSet(key=lambda d: d.fully_qualified_name)
        self.bugs = SortedSet(key=lambda b: b.logical_name)

        self.bug_count = 0

    def __eq__(self, other):
        if self.local_content != other.local_content:
            return False
        elif self.bugs_logical_names != other.bugs_logical_names:
            return False
        elif self.dependency_logical_names != other.dependency_logical_names:
            return False
        else:
            return True

    def __ne__(self, other):
        return not(self.__eq__(other))

    @property
    def probability_gain_feature_dependency(self):
        return self.feature.software_system.probability_gain_feature_dependency

    @property
    def probability_lose_feature_dependency(self):
        return self.feature.software_system.probability_lose_feature_dependency

    @property
    def probability_gain_system_dependency(self):
        return self.feature.software_system.probability_gain_system_dependency

    @property
    def probability_lose_system_dependency(self):
        return self.feature.software_system.probability_lose_system_dependency

    @property
    def probability_new_bug(self):
        return self.feature.software_system.probability_new_bug

    @property
    def probability_debug_known(self):
        return self.feature.software_system.probability_debug_known

    @property
    def probability_debug_unknown(self):
        return self.feature.software_system.probability_debug_unknown

    @property
    def dependency_logical_names(self):
        return map(lambda d: d.logical_name, self.dependencies)

    @property
    def bugs_logical_names(self):
        return map(lambda b: b.logical_name, self.bugs)

    @property
    def bugs_in_dependencies(self):
        chunk_bug_set = frozenset(map(lambda chunk: frozenset(chunk.bugs), self.dependencies))
        return reduce(lambda bugs_a, bugs_b: bugs_a.union(bugs_b), chunk_bug_set, set())

    @property
    def tests(self):
        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:
#.........这里部分代码省略.........
开发者ID:twsswt,项目名称:softdev-workflow,代码行数:103,代码来源:chunk.py


注:本文中的sortedcontainers.SortedSet.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。