Exemplo n.º 1
0
def test_base_iterator_Count_Inner_List():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, List[List[object]], List[int],
                                term_info('a', List[object]), term_info('a.Count()', int), False)
    r = s._inner_lambda(term_info('b', List[object]), 'Select')
    assert r.term == 'b.Select(lambda e0001: e0001.Count())'
    assert _is_of_type(r.type, List[int])
Exemplo n.º 2
0
def test_base_iterator_obj_to_obj():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, object, object,
                                term_info('a', object), term_info('a', object), False)
    r = s._inner_lambda(term_info('b', object), 'Select')
    assert r.term == 'b'
    assert _is_of_type(r.type, object)
Exemplo n.º 3
0
def test_base_iterator_int_to_int():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, int, int,
                                term_info('a', int), term_info('a+1', int), False)
    r = s._inner_lambda(term_info('b', int), 'Select')
    assert r.term == 'b+1'
    assert _is_of_type(r.type, int)
Exemplo n.º 4
0
def test_base_iterator_List_to_2List():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, List[List[int]], List[List[int]],
                                term_info('a', int), term_info('a+1', int), False)
    r = s._inner_lambda(term_info('b', int), 'Select')
    assert r.term == 'b.Select(lambda e0001: e0001.Select(lambda e0002: e0002+1))'
    assert _is_of_type(r.type, List[List[int]])
Exemplo n.º 5
0
def test_where_copy_monad_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool, ['dude']))
    assert w.has_monad_refs()
Exemplo n.º 6
0
def test_select_copies_monads():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float, ['dude']))
    assert w.has_monad_refs()
Exemplo n.º 7
0
def test_where_obj_apply_notseq(object_stream):
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: eb > 10.0')
Exemplo n.º 8
0
def test_where_obj_apply_seq(object_stream):
    a = ast.Num(n=10)
    rep_type = List[int]

    w = statement_where(a, rep_type, term_info('eb', int),
                        term_info('eb > 10.0', bool))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.Where(lambda e0001: e0001 > 10.0)')
Exemplo n.º 9
0
def test_select_obj_apply_notseq(object_stream):
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.pt()')
Exemplo n.º 10
0
def test_select_obj_apply_seq(object_stream):
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.Select(lambda e0001: e0001.pt())')
Exemplo n.º 11
0
def test_select_obj_apply_func_txt_seq():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))

    r = w.apply_as_function(term_info('e5', List[object]))
    assert r.term == 'e5.Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
Exemplo n.º 12
0
def test_where_apply_func_seq():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))

    trm = w.apply_as_function(term_info('e10', List[object]))
    assert trm.term == 'e10.Where(lambda e0001: e0001 > 10.0)'
    assert _is_of_type(trm.type, List[object])
Exemplo n.º 13
0
def test_select_obj_apply_func_txt_notseq():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float))

    r = w.apply_as_function(term_info('e5', object))
    assert r.term == 'e5.pt()'
    assert _is_of_type(r.type, float)
Exemplo n.º 14
0
def test_where_obj_apply_notseq_prev_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = float
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: eb[0] > 10.0')
Exemplo n.º 15
0
def test_where_pass_through_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    f = term_info('eb > <monad-ref>[1]', bool, ['<monad-ref>'])
    w = statement_where(a, rep_type, eb, f)

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with(
        'lambda eb: eb[0].Where(lambda e0001: e0001 > eb[1])')
Exemplo n.º 16
0
def test_where_obj_add_monad_noseq(object_stream):
    a = ast.Num(n=10)
    rep_type = float
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    index = w.add_monad('em', 'em.jets()')
    assert index == 1

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: (eb > 10.0, eb.jets())')
Exemplo n.º 17
0
def test_where_obj_apply_seq_prev_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = List[int]
    eb = term_info('eb', int)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb[0]'
                                                 '.Where(lambda e0001: e0001 > 10.0)')
Exemplo n.º 18
0
def test_where_apply_func_seq_prev_monad():
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    trm = w.apply_as_function(term_info('e10', List[float]))
    assert trm.term == 'e10[0].Where(lambda e0001: e0001 > 10.0)'
    assert _is_of_type(trm.type, List[float])
Exemplo n.º 19
0
def test_select_obj_apply_func_unwrap():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w_base = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))
    w = w_base.unwrap()

    r = w.apply_as_function(term_info('e5', object))
    assert r.term == 'e5.pt()'
    assert _is_of_type(r.type, float)
Exemplo n.º 20
0
def test_where_pass_func_through_monad():
    a = ast.Num(n=10)
    rep_type = List[int]
    eb = term_info('eb', int)

    f = term_info('eb > <monad-ref>[1]', bool, ['<monad-ref>'])
    w = statement_where(a, rep_type, eb, f)

    trm = w.apply_as_function(term_info('e10', List[int]))
    assert trm.term == 'e10[0].Where(lambda e0001: e0001 > <monad-ref>[1])'
    assert len(trm.monad_refs) == 1
Exemplo n.º 21
0
def test_where_func_add_monad_seq():
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    index = w.add_monad('em', 'em.jets()')
    assert index == 1

    trm = w.apply_as_function(term_info('e10', List[float]))
    assert trm.term == '(e10.Where(lambda e0001: e0001 > 10.0), e10.jets())'
    assert _is_of_type(trm.type, List[float])
Exemplo n.º 22
0
def test_select_apply_pass_monad_ref_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb,
                         term_info('eb.pt()', float))
    r = w.apply_as_function(term_info('e5', List[object], ['<monad-ref>']))

    assert r.term == 'e5.Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
Exemplo n.º 23
0
def test_select_apply_func_monad_passed():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[object], eb,
                         term_info('<monad-ref>[1].pt(eb.index)', object))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref>')
    r = w.apply_as_function(term_info('e5', List[object]))

    assert r.term == 'e5[0].Select(lambda e0001: <monad-ref>[1].pt(e0001.index))'
    assert _is_of_type(r.type, List[object])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
Exemplo n.º 24
0
def test_select_apply_func_monad_new_sequence():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[object], eb,
                         term_info('<monad-ref>[1].jets()', List[object]))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref>')
    r = w.apply_as_function(term_info('e5', object))

    assert r.term == '<monad-ref>[1].jets()'
    assert _is_of_type(r.type, List[object])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
Exemplo n.º 25
0
def test_select_apply_gain_monad_ref_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb,
                         term_info('eb.pt()', float))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref-1>')
    r = w.apply_as_function(term_info('e5', List[object], ['<monad-ref-2>']))

    assert r.term == 'e5[0].Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
    assert '<monad-ref-1>' in r.monad_refs
    assert '<monad-ref-2>' in r.monad_refs
    assert len(r.monad_refs) == 2
Exemplo n.º 26
0
def test_select_apply_func_wrap_monad_passthrough():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb,
                         term_info('eb.pt()+<monad-ref-1>[0]', float))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref-1>')

    unwrapped = w.wrap()

    r = unwrapped.apply_as_function(term_info('e5', List[object], ['<monad-ref-2>']))

    assert len(r.monad_refs) == 2
    assert '<monad-ref-1>' in r.monad_refs
    assert '<monad-ref-2>' in r.monad_refs