Beispiel #1
0
    def test_intervalantijoin_faceted():

        left = (('fruit', 'begin', 'end'),
                ('apple', 1, 2),
                ('apple', 2, 4),
                ('apple', 2, 5),
                ('orange', 2, 5),
                ('orange', 9, 14),
                ('orange', 19, 140),
                ('apple', 1, 1),
                ('apple', 2, 2),
                ('apple', 4, 4),
                ('apple', 5, 5),
                ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'),
                 ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'),
                 ('orange', 4, 9, 'baz'))

        expect = (('fruit', 'begin', 'end'),
                  ('orange', 9, 14),
                  ('orange', 19, 140),
                  ('apple', 1, 1),
                  ('apple', 2, 2),
                  ('apple', 4, 4),
                  ('apple', 5, 5),
                  ('orange', 5, 5))

        actual = intervalantijoin(left, right, lstart='begin', lstop='end',
                                  rstart='start', rstop='stop', lkey='fruit',
                                  rkey='type')

        ieq(expect, actual)
        ieq(expect, actual)
Beispiel #2
0
    def test_intervalantijoin_faceted():

        left = (('fruit', 'begin', 'end'), ('apple', 1, 2), ('apple', 2, 4),
                ('apple', 2, 5), ('orange', 2, 5), ('orange', 9, 14),
                ('orange', 19, 140), ('apple', 1, 1), ('apple', 2, 2),
                ('apple', 4, 4), ('apple', 5, 5), ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'), ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'), ('orange', 4, 9, 'baz'))

        expect = (('fruit', 'begin', 'end'), ('orange', 9, 14),
                  ('orange', 19, 140), ('apple', 1, 1), ('apple', 2, 2),
                  ('apple', 4, 4), ('apple', 5, 5), ('orange', 5, 5))

        actual = intervalantijoin(left,
                                  right,
                                  lstart='begin',
                                  lstop='end',
                                  rstart='start',
                                  rstop='stop',
                                  lkey='fruit',
                                  rkey='type')

        ieq(expect, actual)
        ieq(expect, actual)
Beispiel #3
0
    def test_intervalantijoin_include_stop():

        left = (('begin', 'end', 'quux'),
                (1, 2, 'a'),
                (2, 4, 'b'),
                (2, 5, 'c'),
                (9, 14, 'd'),
                (9, 140, 'e'),
                (10, 140, 'e'),
                (1, 1, 'f'),
                (2, 2, 'g'),
                (4, 4, 'h'),
                (5, 5, 'i'),
                (1, 8, 'j'))

        right = (('start', 'stop', 'value'),
                 (1, 4, 'foo'),
                 (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervalantijoin(left, right,
                                  lstart='begin', lstop='end',
                                  rstart='start', rstop='stop',
                                  include_stop=True)
        expect = (('begin', 'end', 'quux'),
                  (10, 140, 'e'))
        debug(lookall(actual))
        ieq(expect, actual)
        ieq(expect, actual)
Beispiel #4
0
    def test_intervalantijoin():

        left = (('begin', 'end', 'quux'), (1, 2, 'a'), (2, 4, 'b'),
                (2, 5, 'c'), (9, 14, 'd'), (9, 140, 'e'), (1, 1, 'f'),
                (2, 2, 'g'), (4, 4, 'h'), (5, 5, 'i'), (1, 8, 'j'))

        right = (('start', 'stop', 'value'), (1, 4, 'foo'), (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervalantijoin(left,
                                  right,
                                  lstart='begin',
                                  lstop='end',
                                  rstart='start',
                                  rstop='stop')
        expect = (('begin', 'end', 'quux'), (9, 14, 'd'), (9, 140, 'e'),
                  (1, 1, 'f'), (2, 2, 'g'), (4, 4, 'h'), (5, 5, 'i'))
        debug(lookall(actual))
        ieq(expect, actual)
        ieq(expect, actual)