Ejemplo n.º 1
0
    def test_multiple_stmts_with_pipeline(self, dataframe, csv_file_comma):
        path = str(csv_file_comma)

        src = """
        df = read_file("%s")
        pipeline(df): {
        drop(.name)}
        """ % path

        df_res = read_file(path)
        result = drop(df_res, Col('name'))

        assert run(src).equals(result)
Ejemplo n.º 2
0
    def test_attr_call_on_var(self, dataframe):
        e = env()
        e[Symbol('df')] = dataframe

        assert run('df.columns').equals(dataframe.columns)
Ejemplo n.º 3
0
 def test_sugar_col_returns_Col_instance(self):
     assert isinstance(run('.col'), Col)
Ejemplo n.º 4
0
 def test_sugar_col_returns_Col_with_right_name(self):
     col = run('.col')
     assert col.name == 'col'
Ejemplo n.º 5
0
    def test_pipeline_execute_stmts(self, dataframe):
        e = env()
        e[Symbol('df')] = dataframe

        assert run('pipeline(df): {drop(.name)}', env=e).equals(
                drop(dataframe, Col('name')))
Ejemplo n.º 6
0
    def test_pipeline_execute_multiple_stmts(self, dataframe):
        e = env()
        e[Symbol('df')] = dataframe

        assert run('pipeline(df): {drop(.name) drop(.floats)}', env=e).equals(
                drop(dataframe, [Col('name'), Col('floats')]))
Ejemplo n.º 7
0
 def test_precedence_with_parentheses_number_expression(self):
     assert run('(2 + 3) * 5') == 25
     assert run('(6 / 2) * 6') == 18
Ejemplo n.º 8
0
 def test_pipeline_raise_error_on_undeclared_dataframe(self):
     with pytest.raises(NameError):
         run('pipeline(df): {drop(.name)}')
Ejemplo n.º 9
0
 def test_number_div_expression(self):
     assert run('6 / 2') == 3
     assert run('12 / 2 / 3') == 2
Ejemplo n.º 10
0
 def test_precedence_number_expression(self):
     assert run('2 * 3 + 5') == 11
     assert run('2 / 2 + 3') == 4
Ejemplo n.º 11
0
 def test_number_mult_expression(self):
     assert run('2 * 3') == 6
     assert run('2 * 3 * 4') == 24
Ejemplo n.º 12
0
 def test_number_sub_expression(self):
     assert run('1 - 2') == -1
     assert run('10 - 2 - 1') == 7
Ejemplo n.º 13
0
 def test_number_sum_expressions(self):
     assert run('1 + 2') == 3
     assert run('1 + 2 + 3') == 6
Ejemplo n.º 14
0
 def test_assing_variable_using_expr(self):
     e = env()
     run('x = 1 + 2 + 3', e)
     assert e[Symbol('x')] == 6
Ejemplo n.º 15
0
 def test_assign_variable_add_to_env(self):
     e = env()
     run('x = 1', e)
     assert e[Symbol('x')] == 1