Beispiel #1
0
def test_iterate_non_uniform_large_size():
    M = Duration('1M')
    spans = list(
        M.iterate(util.timespan('2018-05-02', '2018-08-10', start_open=False),
                  size=2,
                  start_open=False))
    assert len(spans) == 2
    assert M.count(spans[0], start_open=False) == 2
    assert M.count(spans[1], start_open=False) == 2
    assert spans[0] == util.timespan('2018-05-01',
                                     '2018-07-01',
                                     start_open=False)
    assert spans[1] == util.timespan('2018-07-01',
                                     '2018-09-01',
                                     start_open=False)

    spans = list(
        M.iterate(util.timespan('2018-05-02', '2018-08-10', start_open=False),
                  size=2,
                  backward=True,
                  start_open=False))
    assert len(spans) == 2
    assert M.count(spans[0], start_open=False) == 2
    assert M.count(spans[1], start_open=False) == 2
    assert spans[0] == util.timespan('2018-07-01',
                                     '2018-09-01',
                                     start_open=False)
    assert spans[1] == util.timespan('2018-05-01',
                                     '2018-07-01',
                                     start_open=False)
Beispiel #2
0
def test_iterate_uniform_large_size():
    d = Duration('1d')
    spans = list(
        d.iterate(util.timespan('2018-05-01', '2018-05-10', start_open=False),
                  size=8,
                  start_open=False))
    assert len(spans) == 2
    assert d.count(spans[0], start_open=False) == 8
    assert d.count(spans[1], start_open=False) == 8
    assert spans[0] == util.timespan('2018-05-01',
                                     '2018-05-09',
                                     start_open=False)
    assert spans[1] == util.timespan('2018-05-09',
                                     '2018-05-17',
                                     start_open=False)

    spans = list(
        d.iterate(util.timespan('2018-05-20', '2018-05-30', start_open=False),
                  size=8,
                  backward=True,
                  start_open=False))
    assert len(spans) == 2
    assert d.count(spans[0], start_open=False) == 8
    assert d.count(spans[1], start_open=False) == 8
    assert spans[0] == util.timespan('2018-05-22',
                                     '2018-05-30',
                                     start_open=False)
    assert spans[1] == util.timespan('2018-05-14',
                                     '2018-05-22',
                                     start_open=False)