本文整理汇总了Python中pyinter.interval.closed函数的典型用法代码示例。如果您正苦于以下问题:Python closed函数的具体用法?Python closed怎么用?Python closed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了closed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subtract_empty_types
def test_subtract_empty_types():
left = i.closed(datetime(2015, 1, 1), datetime(2020, 1, 1))
right = i.closed(datetime(2010, 1, 1), datetime(2100, 1, 1))
result = left - right
assert result.empty()
assert isinstance(result.lower_value, datetime)
assert isinstance(result.upper_value, datetime)
示例2: test_overlaps_corner_case_closed
def test_overlaps_corner_case_closed():
one = i.closed(1, 5)
two = i.closed(5, 10)
assert one.overlaps(two)
assert two.overlaps(one)
assert one.overlaps(one)
assert two.overlaps(two)
示例3: test_values_in
def test_values_in():
one = i.open(1, 5)
two = i.closed(7, 10)
ivset = IntervalSet((i.open(1, 5), i.closed(7, 10)))
assert 1 not in ivset
assert 1.00000001 in ivset
assert 3 in ivset
assert 7 in ivset
assert 8 in ivset
assert 10.0001 not in ivset
assert one in ivset
assert two in ivset
示例4: test_contains
def test_contains():
small = i.closed(1, 5)
medium = i.closedopen(3, 10)
assert small.lower_value in small
assert small._upper_value in small
assert medium.lower_value in medium
assert medium._upper_value not in medium
示例5: test_non_equality
def test_non_equality():
small, medium = get_intervals()[:2]
assert small != medium
assert small != i.openclosed(1,5)
assert small != i.closedopen(1,5)
assert small != i.closed(1,5)
assert small != i.Interval(i.Interval.OPEN, 1, 7, i.Interval.OPEN)
assert small != i.open(100, 288)
示例6: test_closed_interval_construction_using_helper
def test_closed_interval_construction_using_helper():
expected_lower = i.Interval.CLOSED
expectedlower_value = 10
expected_upper_value = 100
expected_upper = i.Interval.CLOSED
result = i.closed(10, 100)
assert result.lower == expected_lower
assert result.lower_value == expectedlower_value
assert result.upper_value == expected_upper_value
assert result.upper == expected_upper
示例7: test_complement
def test_complement():
one = i.open(3, 6)
two = i.open(7, 10)
intervals = IntervalSet([one, two])
complement = intervals.complement()
(lower, middle, upper) = sorted(complement) # an IntervalSet is not sorted
assert lower == i.openclosed(i.NEGATIVE_INFINITY, 3)
assert middle == i.closed(6, 7)
assert upper == i.closedopen(10, i.INFINITY)
示例8: test_overlaps_empty
def test_overlaps_empty():
assert not i.open(0, 0).overlaps(i.closed(1, 20))
assert not i.open(1, 1).overlaps(i.closed(1, 20))
assert not i.open(2, 2).overlaps(i.closed(1, 20))
assert not i.closed(1, 20).overlaps(i.open(0, 0))
assert not i.closed(1, 20).overlaps(i.open(1, 1))
assert not i.closed(1, 20).overlaps(i.open(2, 2))
示例9: test_len_works_as_expected
def test_len_works_as_expected():
assert len(IntervalSet((i.open(1, 5), i.closed(7, 10)))) == 2
示例10: test_interval_copy
def test_interval_copy():
assert i.open(1, 4).copy() == i.open(1, 4)
assert i.openclosed(1, 4).copy() == i.openclosed(1, 4)
assert i.closedopen(1, 4).copy() == i.closedopen(1, 4)
assert i.closed(1, 4).copy() == i.closed(1, 4)
示例11: test_overlaps_touching
def test_overlaps_touching():
assert not i.openclosed(1, 4).overlaps(i.openclosed(4, 5))
assert not i.closedopen(1, 4).overlaps(i.closedopen(4, 5))
assert not i.open(1, 4).overlaps(i.open(4, 5))
assert i.closed(1, 4).overlaps(i.closed(4, 5))
示例12: test_repr
def test_repr():
assert repr(i.open(1, 2)) == '(1, 2)'
assert repr(i.openclosed(1, 2)) == '(1, 2]'
assert repr(i.closed(1, 2)) == '[1, 2]'
assert repr(i.closedopen(1, 2)) == '[1, 2)'
示例13: test_contains_fully_overlapping
def test_contains_fully_overlapping():
small = i.closed(7, 10)
medium = i.closedopen(7, 21)
assert small in medium
示例14: test_intersection_of_almost_overlapping
def test_intersection_of_almost_overlapping():
first = IntervalSet((i.open(1, 5), i.closedopen(7, 10)))
second = IntervalSet((i.open(1, 5), i.closed(7,23)))
expected = IntervalSet((i.open(1, 5), i.closedopen(7, 10)))
result = first.intersection(second)
assert result == expected
示例15: test_contains_self_closed_open
def test_contains_self_closed_open():
small = i.closedopen(1, 5)
medium = i.closed(7, 10)
assert small in small
assert small not in medium
assert medium not in small