本文整理汇总了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
示例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
示例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()
示例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()
示例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
示例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
示例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
示例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
示例9: __init__
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import empty [as 别名]
def __init__(self):
self.builder = IntSet.Builder()
self.equivalent = IntSet.empty()