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


Python intset.IntSet类代码示例

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


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

示例1: test_builder_insert_intervals_equivalent_to_successive_union

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,代码行数:7,代码来源:test_intset.py

示例2: test_sequentially_removing_intervals_yields_empty

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,代码行数:10,代码来源:test_intset.py

示例3: test_deepcopy_collapses_reference_equality

def test_deepcopy_collapses_reference_equality():
    x = IntSet.from_iterable([1, 2, 3])
    y = IntSet.from_iterable([1, 2, 3])
    z = IntSet.from_iterable([1, 2, 3, 4])
    assert x == y
    assert x is not y
    w, u, v = deepcopy((x, y, z))
    assert x == w
    assert y == u
    assert z == v
    assert w is u
    assert w is not v
开发者ID:tomviner,项目名称:intset,代码行数:12,代码来源:test_intset.py

示例4: test_insert_into_interval

def test_insert_into_interval(bounds, ints):
    imp = IntSet.interval(*bounds)
    for i in ints:
        imp = imp.insert(i)
        assert i in imp
    for i in ints:
        assert i in imp
开发者ID:tomviner,项目名称:intset,代码行数:7,代码来源:test_intset.py

示例5: test_is_equal_to_random_insertion

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,代码行数:7,代码来源:test_intset.py

示例6: test_validates_bounds

def test_validates_bounds():
    with pytest.raises(ValueError):
        IntSet.single(-1)
    with pytest.raises(ValueError):
        IntSet.single(2 ** 64)
    with pytest.raises(ValueError):
        IntSet.interval(1, 2 ** 65)
    with pytest.raises(ValueError):
        IntSet.interval(2 ** 65, 1)
开发者ID:tomviner,项目名称:intset,代码行数:9,代码来源:test_intset.py

示例7: three_adjacent_values

 def three_adjacent_values(self, v):
     assume(v + 2 <= 2 ** 64)
     return (IntSet.interval(v, v + 3), [v, v + 1, v + 2])
开发者ID:tomviner,项目名称:intset,代码行数:3,代码来源:test_intset.py

示例8: single_value

 def single_value(self, v):
     return (IntSet.single(v), [v])
开发者ID:tomviner,项目名称:intset,代码行数:2,代码来源:test_intset.py

示例9: adjacent_values

 def adjacent_values(self, v):
     assume(v + 1 <= 2 ** 64)
     return (IntSet.interval(v, v + 2), [v, v + 1])
开发者ID:tomviner,项目名称:intset,代码行数:3,代码来源:test_intset.py

示例10: test_not_equal_to_other_types

def test_not_equal_to_other_types():
    assert IntSet.single(1) != 1
开发者ID:tomviner,项目名称:intset,代码行数:2,代码来源:test_intset.py

示例11: build_interval

 def build_interval(self, bounds):
     return (IntSet.interval(*bounds), list(range(*bounds)))
开发者ID:tomviner,项目名称:intset,代码行数:2,代码来源:test_intset.py

示例12: test_can_produce_whole_range_intset

def test_can_produce_whole_range_intset():
    assert IntSet.interval(0, 2 ** 64).size() == 2 ** 64
开发者ID:tomviner,项目名称:intset,代码行数:2,代码来源:test_intset.py

示例13: insert_interval

 def insert_interval(self, ij):
     self.builder.insert_interval(*ij)
     self.equivalent = self.equivalent | IntSet.interval(*ij)
开发者ID:DRMacIver,项目名称:intset,代码行数:3,代码来源:test_intset.py

示例14: three_adjacent_values_with_hole

 def three_adjacent_values_with_hole(self, v):
     assume(v + 2 <= 2 ** 64)
     return (IntSet.single(v) | IntSet.single(v + 2), [v, v + 2])
开发者ID:tomviner,项目名称:intset,代码行数:3,代码来源:test_intset.py

示例15: test_concatenation_of_lists_is_union

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,代码行数:3,代码来源:test_intset.py


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