本文整理汇总了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
示例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
示例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)
示例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
示例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)