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


Python IntSet.empty方法代码示例

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


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

示例1: test_builder_insert_intervals_equivalent_to_successive_union

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_builder_insert_intervals_equivalent_to_successive_union(intervals):
    builder = IntSet.Builder()
    equiv = IntSet.empty()
    for ij in intervals:
        equiv |= IntSet.interval(*ij)
        builder.insert_interval(*ij)
    assert builder.build() == equiv
开发者ID:DRMacIver,项目名称:intset,代码行数:9,代码来源:test_intset.py

示例2: test_is_equal_to_random_insertion

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_is_equal_to_random_insertion(imp, rnd):
    items = list(imp)
    rnd.shuffle(items)
    equiv = IntSet.empty()
    for i in items:
        equiv = equiv.insert(i)
    assert imp == equiv
开发者ID:tomviner,项目名称:intset,代码行数:9,代码来源:test_intset.py

示例3: test_default_intset_is_empty

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_default_intset_is_empty():
    assert IntSet() == IntSet.empty()
开发者ID:tomviner,项目名称:intset,代码行数:4,代码来源:test_intset.py

示例4: test_interval_ending_at_zero_is_zero

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_interval_ending_at_zero_is_zero():
    assert IntSet.interval(0, 0) == IntSet.empty()
开发者ID:tomviner,项目名称:intset,代码行数:4,代码来源:test_intset.py

示例5: test_is_equal_to_reverse_insertion

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_is_equal_to_reverse_insertion(imp):
    equiv = IntSet.empty()
    for i in reversed(list(imp)):
        equiv = equiv.insert(i)
    assert imp == equiv
开发者ID:tomviner,项目名称:intset,代码行数:7,代码来源:test_intset.py

示例6: test_is_equal_to_sequential_insertion

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def test_is_equal_to_sequential_insertion(imp):
    equiv = IntSet.empty()
    for i in imp:
        equiv = equiv.insert(i)
    assert imp == equiv
开发者ID:tomviner,项目名称:intset,代码行数:7,代码来源:test_intset.py

示例7: assume

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
SMALL = 100

short_intervals = st.builds(
    lambda start, length: assume(
        start + length <= 2 ** 64) and (start, start + length),
    integers_in_range, st.integers(0, SMALL))

interval_list = st.lists(intervals, average_size=10)

IntSets = st.builds(
    IntSet.from_intervals, interval_list) | integers_in_range.map(
        IntSet.single) | intervals.map(lambda x: IntSet.interval(*x))


@example(IntSet.empty())
@example(IntSet.single(1))
@example(IntSet([1, 2, 3, 6]))
@given(IntSets)
def test_pickling_works_correctly(x):
    assert pickle.loads(pickle.dumps(x)) == x


@example(IntSet.interval(0, 10))
@example(IntSet([(0, 10), (15, 20)]))
@given(IntSets)
def test_copies_as_self(x):
    assert copy(x) is x
    assert deepcopy(x) is x

开发者ID:tomviner,项目名称:intset,代码行数:30,代码来源:test_intset.py

示例8: result

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
 def result():
     d = IntSet.empty()
     for v in dataset:
         d = d.insert(v)
     return d
开发者ID:DRMacIver,项目名称:intset,代码行数:7,代码来源:test_insertion.py

示例9: __init__

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
 def __init__(self):
     self.builder = IntSet.Builder()
     self.equivalent = IntSet.empty()
开发者ID:DRMacIver,项目名称:intset,代码行数:5,代码来源:test_intset.py


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