本文整理汇总了Python中intset.IntSet.single方法的典型用法代码示例。如果您正苦于以下问题:Python IntSet.single方法的具体用法?Python IntSet.single怎么用?Python IntSet.single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intset.IntSet
的用法示例。
在下文中一共展示了IntSet.single方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validates_bounds
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [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_validates_argument_types
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [as 别名]
def test_validates_argument_types():
with pytest.raises(TypeError):
IntSet.single('foo')
示例3: three_adjacent_values_with_hole
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [as 别名]
def three_adjacent_values_with_hole(self, v):
assume(v + 2 <= 2 ** 64)
return (IntSet.single(v) | IntSet.single(v + 2), [v, v + 2])
示例4: single_value
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [as 别名]
def single_value(self, v):
return (IntSet.single(v), [v])
示例5: test_not_equal_to_other_types
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [as 别名]
def test_not_equal_to_other_types():
assert IntSet.single(1) != 1
示例6: test_discarding_a_solo_gives_the_empty_list
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [as 别名]
def test_discarding_a_solo_gives_the_empty_list(i):
imp = IntSet.single(i)
assert imp.discard(i).size() == 0
示例7: assume
# 需要导入模块: from intset import IntSet [as 别名]
# 或者: from intset.IntSet import single [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
def test_deepcopy_collapses_reference_equality():