Example #1
0
    def test_intervalleftjoin_prefixes():

        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 = intervalleftjoin(left,
                                  right,
                                  lstart='begin',
                                  lstop='end',
                                  rstart='start',
                                  rstop='stop',
                                  lprefix='l_',
                                  rprefix='r_')
        expect = (('l_begin', 'l_end', 'l_quux', 'r_start', 'r_stop',
                   'r_value'), (1, 2, 'a', 1, 4, 'foo'),
                  (2, 4, 'b', 1, 4, 'foo'), (2, 4, 'b', 3, 7, 'bar'),
                  (2, 5, 'c', 1, 4, 'foo'), (2, 5, 'c', 3, 7, 'bar'),
                  (2, 5, 'c', 4, 9, 'baz'), (9, 14, 'd', None, None, None),
                  (9, 140, 'e', None, None, None), (1, 1, 'f', None, None,
                                                    None), (2, 2, 'g', None,
                                                            None, None),
                  (4, 4, 'h', None, None, None), (5, 5, 'i', None, None, None),
                  (1, 8, 'j', 1, 4, 'foo'), (1, 8, 'j', 3, 7,
                                             'bar'), (1, 8, 'j', 4, 9, 'baz'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #2
0
    def test_intervaljoins_faceted_compound():

        left = (('fruit', 'sort', 'begin', 'end'),
                ('apple', 'cox', 1, 2),
                ('apple', 'fuji', 2, 4))
        right = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'),
                 ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        expect = (('fruit', 'sort', 'begin', 'end', 'type', 'variety', 'start',
                   'stop', 'value'),
                  ('apple', 'cox', 1, 2, 'apple', 'cox', 1, 4, 'foo'),
                  ('apple', 'fuji', 2, 4, 'apple', 'fuji', 3, 7, 'bar'))

        actual = intervaljoin(left, right, lstart='begin', lstop='end',
                              rstart='start', rstop='stop',
                              lkey=('fruit', 'sort'),
                              rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)

        actual = intervalleftjoin(left, right, lstart='begin', lstop='end',
                                  rstart='start', rstop='stop',
                                  lkey=('fruit', 'sort'),
                                  rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #3
0
    def test_intervaljoins_faceted_compound():

        left = (('fruit', 'sort', 'begin', 'end'), ('apple', 'cox', 1, 2),
                ('apple', 'fuji', 2, 4))
        right = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'), ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        expect = (('fruit', 'sort', 'begin', 'end', 'type', 'variety', 'start',
                   'stop', 'value'), ('apple', 'cox', 1, 2, 'apple', 'cox', 1,
                                      4, 'foo'),
                  ('apple', 'fuji', 2, 4, 'apple', 'fuji', 3, 7, 'bar'))

        actual = intervaljoin(left,
                              right,
                              lstart='begin',
                              lstop='end',
                              rstart='start',
                              rstop='stop',
                              lkey=('fruit', 'sort'),
                              rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)

        actual = intervalleftjoin(left,
                                  right,
                                  lstart='begin',
                                  lstop='end',
                                  rstart='start',
                                  rstop='stop',
                                  lkey=('fruit', 'sort'),
                                  rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #4
0
    def test_intervalleftjoin_faceted_rkeymissing():

        left = (('fruit', 'begin', 'end'),
                ('apple', 1, 2),
                ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'),
                 ('apple', 1, 4, 'foo'))

        expect = (('fruit', 'begin', 'end', 'type', 'start', 'stop', 'value'),
                  ('apple', 1, 2, 'apple', 1, 4, 'foo'),
                  ('orange', 5, 5, None, None, None, None))

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

        ieq(expect, actual)
        ieq(expect, actual)
Example #5
0
    def test_intervalleftjoin_prefixes():

        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 = intervalleftjoin(left, right,
                                  lstart='begin', lstop='end',
                                  rstart='start', rstop='stop',
                                  lprefix='l_', rprefix='r_')
        expect = (('l_begin', 'l_end', 'l_quux', 'r_start', 'r_stop', 'r_value'),
                  (1, 2, 'a', 1, 4, 'foo'),
                  (2, 4, 'b', 1, 4, 'foo'),
                  (2, 4, 'b', 3, 7, 'bar'),
                  (2, 5, 'c', 1, 4, 'foo'),
                  (2, 5, 'c', 3, 7, 'bar'),
                  (2, 5, 'c', 4, 9, 'baz'),
                  (9, 14, 'd', None, None, None),
                  (9, 140, 'e', None, None, None),
                  (1, 1, 'f', None, None, None),
                  (2, 2, 'g', None, None, None),
                  (4, 4, 'h', None, None, None),
                  (5, 5, 'i', None, None, None),
                  (1, 8, 'j', 1, 4, 'foo'),
                  (1, 8, 'j', 3, 7, 'bar'),
                  (1, 8, 'j', 4, 9, 'baz'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #6
0
    def test_intervalleftjoin_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', 'type', 'start', 'stop', 'value'),
                  ('apple', 1, 2, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 3, 7, 'bar'),
                  ('apple', 2, 5, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 5, 'apple', 3, 7, 'bar'),
                  ('orange', 2, 5, 'orange', 4, 9, 'baz'),
                  ('orange', 9, 14, None, None, None, None),
                  ('orange', 19, 140, None, None, None, None),
                  ('apple', 1, 1, None, None, None, None),
                  ('apple', 2, 2, None, None, None, None),
                  ('apple', 4, 4, None, None, None, None),
                  ('apple', 5, 5, None, None, None, None),
                  ('orange', 5, 5, None, None, None, None))

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

        ieq(expect, actual)
        ieq(expect, actual)
Example #7
0
    def test_intervalleftjoin_faceted_rkeymissing():

        left = (('fruit', 'begin', 'end'), ('apple', 1, 2), ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'), ('apple', 1, 4, 'foo'))

        expect = (('fruit', 'begin', 'end', 'type', 'start', 'stop', 'value'),
                  ('apple', 1, 2, 'apple', 1, 4, 'foo'), ('orange', 5, 5, None,
                                                          None, None, None))

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

        ieq(expect, actual)
        ieq(expect, actual)
Example #8
0
    def test_intervalleftjoin_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', 'type', 'start', 'stop',
                   'value'), ('apple', 1, 2, 'apple', 1, 4,
                              'foo'), ('apple', 2, 4, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 3, 7,
                   'bar'), ('apple', 2, 5, 'apple', 1, 4,
                            'foo'), ('apple', 2, 5, 'apple', 3, 7, 'bar'),
                  ('orange', 2, 5, 'orange', 4, 9,
                   'baz'), ('orange', 9, 14, None, None, None,
                            None), ('orange', 19, 140, None, None, None, None),
                  ('apple', 1, 1, None, None, None,
                   None), ('apple', 2, 2, None, None, None,
                           None), ('apple', 4, 4, None, None, None, None),
                  ('apple', 5, 5, None, None, None,
                   None), ('orange', 5, 5, None, None, None, None))

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

        ieq(expect, actual)
        ieq(expect, actual)