当前位置: 首页>>代码示例>>Python>>正文


Python interval.closed函数代码示例

本文整理汇总了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)
开发者ID:intiocean,项目名称:pyinter,代码行数:7,代码来源:test_interval.py

示例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)
    
开发者ID:RedTurtle,项目名称:pyinter,代码行数:7,代码来源:test_interval_comparison.py

示例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
开发者ID:dimonb,项目名称:pyinter,代码行数:12,代码来源:test_interval_set.py

示例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
开发者ID:RedTurtle,项目名称:pyinter,代码行数:7,代码来源:test_interval_comparison.py

示例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)
开发者ID:RedTurtle,项目名称:pyinter,代码行数:8,代码来源:test_interval_comparison.py

示例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
开发者ID:Shopify,项目名称:pyinter,代码行数:10,代码来源:test_interval_construction.py

示例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)
开发者ID:Shopify,项目名称:pyinter,代码行数:10,代码来源:test_interval_set.py

示例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))
开发者ID:intiocean,项目名称:pyinter,代码行数:7,代码来源:test_interval.py

示例9: test_len_works_as_expected

def test_len_works_as_expected():
    assert len(IntervalSet((i.open(1, 5), i.closed(7, 10)))) == 2
开发者ID:dimonb,项目名称:pyinter,代码行数:2,代码来源:test_interval_set.py

示例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)
开发者ID:intiocean,项目名称:pyinter,代码行数:5,代码来源:test_interval.py

示例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))
开发者ID:intiocean,项目名称:pyinter,代码行数:5,代码来源:test_interval.py

示例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)'
开发者ID:intiocean,项目名称:pyinter,代码行数:5,代码来源:test_interval.py

示例13: test_contains_fully_overlapping

def test_contains_fully_overlapping():
    small = i.closed(7, 10)
    medium = i.closedopen(7, 21)
    assert small in medium
开发者ID:RedTurtle,项目名称:pyinter,代码行数:4,代码来源:test_interval_comparison.py

示例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
开发者ID:dimonb,项目名称:pyinter,代码行数:6,代码来源:test_interval_set.py

示例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
开发者ID:RedTurtle,项目名称:pyinter,代码行数:6,代码来源:test_interval_comparison.py


注:本文中的pyinter.interval.closed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。