本文整理汇总了Python中intset.IntSet.from_iterable方法的典型用法代码示例。如果您正苦于以下问题:Python IntSet.from_iterable方法的具体用法?Python IntSet.from_iterable怎么用?Python IntSet.from_iterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intset.IntSet
的用法示例。
在下文中一共展示了IntSet.from_iterable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deepcopy_collapses_reference_equality
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_iterable [as 别名]
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
示例2: test_trying_to_pass_extra_args_to_intset_errors
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_iterable [as 别名]
def test_trying_to_pass_extra_args_to_intset_errors():
with pytest.raises(TypeError):
IntSet.from_iterable(1, 2)
示例3: test_instantiating_with_a_collection_gives_that_collection
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_iterable [as 别名]
@example(set())
@example(set([1, 2, 3]))
@given(st.sets(integers_in_range))
def test_instantiating_with_a_collection_gives_that_collection(xs):
ts = IntSet.from_iterable(xs)
assert len(ts) == len(xs)
assert set(ts) == xs
def test_trying_to_pass_extra_args_to_intset_errors():
with pytest.raises(TypeError):
IntSet.from_iterable(1, 2)
@example(IntSet.from_iterable([]), 1)
@example(IntSet.from_iterable([]), -1)
@example(IntSet.from_iterable([0]), -2)
@example(IntSet.from_iterable([0]), 2)
@given(IntSets, st.integers())
def test_raises_index_error_out_of_bounds(x, i):
assume(abs(i) > x.size())
with pytest.raises(IndexError):
x[i]
SmallIntSets = st.builds(
IntSet.from_intervals,
st.lists(short_intervals,
average_size=5)).filter(lambda x: x.size() <= SMALL)
示例4: test_iterable_equivalent_to_intervals_of_length_one
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import from_iterable [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)