本文整理汇总了Python中intset.IntSet.interval方法的典型用法代码示例。如果您正苦于以下问题:Python IntSet.interval方法的具体用法?Python IntSet.interval怎么用?Python IntSet.interval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intset.IntSet
的用法示例。
在下文中一共展示了IntSet.interval方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validates_bounds
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
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)
示例2: test_insert_into_interval
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
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
示例3: test_builder_insert_intervals_equivalent_to_successive_union
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [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
示例4: test_sequentially_removing_intervals_yields_empty
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [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
示例5: test_interval_ending_at_zero_is_zero
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def test_interval_ending_at_zero_is_zero():
assert IntSet.interval(0, 0) == IntSet.empty()
示例6: test_can_produce_whole_range_intset
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def test_can_produce_whole_range_intset():
assert IntSet.interval(0, 2 ** 64).size() == 2 ** 64
示例7: three_adjacent_values
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def three_adjacent_values(self, v):
assume(v + 2 <= 2 ** 64)
return (IntSet.interval(v, v + 3), [v, v + 1, v + 2])
示例8: adjacent_values
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def adjacent_values(self, v):
assume(v + 1 <= 2 ** 64)
return (IntSet.interval(v, v + 2), [v, v + 1])
示例9: build_interval
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def build_interval(self, bounds):
return (IntSet.interval(*bounds), list(range(*bounds)))
示例10: test_unioning_a_value_in_includes_it
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [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
示例11: test_union_of_two_intervals_contains_each_start
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def test_union_of_two_intervals_contains_each_start(i1, i2):
assume(i1[0] < i1[1])
assume(i2[0] < i2[1])
x = IntSet.interval(*i1) | IntSet.interval(*i2)
assert i1[0] in x
assert i2[0] in x
示例12: sorted
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
intervals = st.tuples(integers_in_range, integers_in_range).map(
lambda x: sorted(tuple(x)))
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
示例13: insert_interval
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def insert_interval(self, ij):
self.builder.insert_interval(*ij)
self.equivalent = self.equivalent | IntSet.interval(*ij)
示例14: test_union_leads_to_extension
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import interval [as 别名]
def test_union_leads_to_extension(x, y):
z = x | y
for u in list(x.intervals()) + list(y.intervals()):
assert IntSet.interval(*u).issubset(z)