Beispiel #1
0
 def test_apply_pattern_with_memory_skip(self):
     p = RememberingPattern([0, 1])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, 4, skip_left=3))
     t._Timeline__apply_pattern([9], _Span(5, 6))
     t._Timeline__apply_pattern(p, _Span(7, 9))
     assert (t._ws_labels == [1, 0, 1, 0, 1, 9, 9, 0, 1, 0]).all()
Beispiel #2
0
 def test_organize_recursive_with_memory(self):
     f = _Frame(base_unit_freq='D', start='29 Nov 2017', end='06 Dec 2017')
     p = RememberingPattern(['a', 'b', 'c', 'd'])
     org_int = Organizer(marker='W', structure=[[1, 2], p])
     org_ext = Organizer(marker='M', structure=[p, org_int])
     t = _Timeline(frame=f, organizer=org_ext)
     assert t.labels.eq(['a', 'b', 1, 2, 1, 'c', 'd', 'a']).all()
Beispiel #3
0
 def test_apply_pattern_with_memory_long(self):
     p = RememberingPattern([0, 1, 2, 3, 4, 5])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, 4))
     t._Timeline__apply_pattern([9], _Span(5, 6))
     t._Timeline__apply_pattern(p, _Span(7, 9))
     assert (t._ws_labels == [0, 1, 2, 3, 4, 9, 9, 5, 0, 1]).all()
Beispiel #4
0
 def test_organize_pattern_with_memory(self):
     f = _Frame(base_unit_freq='D', start='02 Jan 2017',
                end='22 Jan 2017')
     p = RememberingPattern([1, 2, 3])
     org = Organizer(marker='W', structure=[p, [9], p])
     t = _Timeline(frame=f, organizer=org)
     assert t.labels.eq([1, 2, 3, 1, 2, 3, 1,
                         9, 9, 9, 9, 9, 9, 9,
                         2, 3, 1, 2, 3, 1, 2]).all()
Beispiel #5
0
 def test_apply_pattern_with_memory_skip_2(self):
     # this situation is not natural as dangles do not appear in interior
     # subframes
     p = RememberingPattern([0, 1, 2, 3, 4, 5])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, 4, skip_left=3))
     t._Timeline__apply_pattern([9], _Span(5, 6))
     t._Timeline__apply_pattern(p, _Span(7, 9, skip_left=2))
     assert (t._ws_labels == [3, 4, 5, 0, 1, 9, 9, 4, 5, 0]).all()
Beispiel #6
0
 def test_organize_structure_element_as_empty_rememberingpattern(self):
     f = _Frame(base_unit_freq='D',
                start='02 Oct 2017', end='04 Oct 2017 23:59')
     org = Organizer(marker='W', structure=[RememberingPattern([])])
     t = _Timeline(frame=f, organizer=org, data=0)
     assert t.labels.eq([0, 0, 0]).all()
Beispiel #7
0
 def test_organize_structure_as_rememberingpattern(self):
     f = _Frame(base_unit_freq='H',
                start='02 Oct 2017', end='04 Oct 2017 23:59')
     org = Organizer(marker='D', structure=RememberingPattern([1,2]))
     t = _Timeline(frame=f, organizer=org, data=0)
     assert t.labels.eq([1,2,1]).all()
Beispiel #8
0
 def test_apply_pattern_empty(self):
     p = RememberingPattern([])
     t = timeline_10d(data=100)
     t._Timeline__apply_pattern(p, _Span(0, len(t.frame) - 1))
     assert (t._ws_labels == [100] * 10).all()
Beispiel #9
0
 def test_apply_pattern_toolong_skip_more(self):
     p = RememberingPattern(range(15))
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, len(t.frame) - 1, skip_left=10))
     assert (t._ws_labels == [10, 11, 12, 13, 14, 0, 1, 2, 3, 4]).all()
Beispiel #10
0
 def test_apply_pattern_toolong_skip(self):
     p = RememberingPattern(range(15))
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, len(t.frame) - 1, skip_left=3))
     assert (t._ws_labels == range(3, 13)).all()
Beispiel #11
0
 def test_apply_pattern_short(self):
     p = RememberingPattern([1])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, len(t.frame) - 1))
     assert (t._ws_labels == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]).all()
Beispiel #12
0
 def test_apply_pattern_span_skip(self):
     p = RememberingPattern([1, 2, 3])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(1, 6, skip_left=2))
     assert (t._ws_labels[1:7] == [3, 1, 2, 3, 1, 2]).all()
Beispiel #13
0
 def test_apply_pattern_skip(self):
     p = RememberingPattern([1, 2, 3])
     t = timeline_10d()
     t._Timeline__apply_pattern(p, _Span(0, len(t.frame) - 1, skip_left=2))
     assert (t._ws_labels == [3, 1, 2, 3, 1, 2, 3, 1, 2, 3]).all()