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()
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)')
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')
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')
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])
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])')
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())')
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)')
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
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])
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])