def test_evaluate_expression_syntax_error(self): df = pd.DataFrame(data=[[nan, 'gnu', 3], [4, 'gnat', '{{((((*+-/ x y heres_a_syntax_error!!!!!!!!!!!!!!!!}}']], columns=['a', 'b', 'c']) col_specs = {n: ColumnMetadata(Unit(u)) for n, u in zip(['a', 'b', 'c'], ['-', 'text', 'm'])} t = Table(df=df, name='some_table', col_specs=col_specs, destinations=['success', 'glory']) with raises(SyntaxError, match=r"Syntax error in expression in table 'some_table', column 2, row 1"): t.evaluate_expressions({'x': 7, 'y': 9}, inplace=False)
def test_evaluate_expressions(self, some_table: Table): env: Environment = make_root_environment().define('x', 42).define('y', 7) assert some_table.evaluate_expressions(env, inplace=False).df.iloc[1, 2] == 49 context_dict = {'x': 7, 'y': 9} assert some_table.evaluate_expressions(context_dict, inplace=False).df.iloc[1, 2] == 16 env.update([('y', 10)]) some_table.evaluate_expressions(env, inplace=True) assert some_table.df.iloc[1, 2] == 52