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


Python IntSet.from_intervals方法代码示例

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


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

示例1: test_sequentially_removing_intervals_yields_empty

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_intervals [as 别名]
def test_sequentially_removing_intervals_yields_empty(ls):
    running = IntSet.from_intervals(ls)
    for i in ls:
        inter = IntSet.interval(*i)
        extra = inter & running
        original = running.size()
        assert (running - inter) == (running - extra)
        running -= inter
        assert running.size() == original - extra.size()
    assert running.size() == 0
开发者ID:tomviner,项目名称:intset,代码行数:12,代码来源:test_intset.py

示例2: test_unioning_a_value_in_includes_it

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_intervals [as 别名]
def test_unioning_a_value_in_includes_it(intervals, i):
    mp = IntSet.from_intervals(intervals)
    assume(i not in mp)
    mp2 = mp | IntSet.interval(i, i + 1)
    assert i in mp2
开发者ID:tomviner,项目名称:intset,代码行数:7,代码来源:test_intset.py

示例3: test_concatenation_of_lists_is_union

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_intervals [as 别名]
def test_concatenation_of_lists_is_union(x, y):
    assert IntSet.from_intervals(x + y) == \
        IntSet.from_intervals(x) | IntSet.from_intervals(y)
开发者ID:DRMacIver,项目名称:intset,代码行数:5,代码来源:test_intset.py

示例4: test_subtracting_a_superset_is_empty

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_intervals [as 别名]
    imper = imp.insert(i)
    assert imp.issubset(imper)


@example(IntSet.empty(), IntSet.empty())
@example(IntSet.single(0), IntSet.from_iterable([0, 2]))
@given(IntSets, IntSets)
def test_subtracting_a_superset_is_empty(x, y):
    assume(x.issubset(y))
    assert (x - y).size() == 0


@example(
    IntSet.interval(4611686018427387904, 4611686018427387907),
    IntSet.from_intervals([
        (0, 4611686018427387904), (4611686018427387904, 4611686018427387905),
        (4611686018427387906, 4611686018427387907)]))
@example(IntSet.single(0), IntSet.empty())
@example(IntSet.interval(0, 2), IntSet.from_iterable([0, 2]))
@example(IntSet.interval(0, 3), IntSet.from_iterable([0, 2]))
@example(IntSet.single(0), IntSet.from_iterable([1, 3]))
@example(IntSet.interval(0, 3), IntSet.from_iterable([0, 2, 3, 4]))
@example(IntSet.interval(0, 5), IntSet.from_iterable([0, 2]))
@example(IntSet.single(1), IntSet.from_iterable([0, 2]))
@example(IntSet.single(3), IntSet.from_iterable([0, 2]))
@given(IntSets, IntSets)
def test_subtracting_a_non_superset_is_non_empty(x, y):
    assume(not x.issubset(y))
    assert (x - y).size() > 0

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

示例5: test_iterable_equivalent_to_intervals_of_length_one

# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_intervals [as 别名]
def test_iterable_equivalent_to_intervals_of_length_one(xs):
    assert IntSet.from_iterable(xs) == \
        IntSet.from_intervals((x, x + 1) for x in xs)
开发者ID:DRMacIver,项目名称:intset,代码行数:5,代码来源:test_intset.py


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