Skip to content

Commit

Permalink
pre-commit and tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardo-imadeira committed Mar 6, 2024
1 parent fbf020f commit 466622b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
6 changes: 5 additions & 1 deletion aeon/synthesis_grammar/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ def gen_grammar_nodes(
Returns:
list[type]: The list of generated grammar nodes.
"""
vars_to_ignore = metadata[synth_func_name]["syn_ignore"]
vars_to_ignore = (
metadata[synth_func_name]["syn_ignore"]
if synth_func_name in metadata and "syn_ignore" in metadata[synth_func_name].keys()
else []
)
if grammar_nodes is None:
grammar_nodes = []
for var in ctx.vars():
Expand Down
2 changes: 1 addition & 1 deletion tests/hole_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def extract_target_functions(source):
prog = parse_program(source)
prog = apply_decorators_in_program(prog)
core, ctx, _ = desugar(prog)
core, ctx, _, _ = desugar(prog)
core_anf = ensure_anf(core)
check_type_errors(ctx, core_anf, top)
return incomplete_functions_and_holes(ctx, core_anf)
Expand Down
2 changes: 1 addition & 1 deletion tests/native_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def check_compile(source, ty):
p, ctx, ectx = desugar(parse_program(source))
p, ctx, ectx, _ = desugar(parse_program(source))
assert check_type(ctx, p, ty)
assert eval(p, ectx) == 2

Expand Down
3 changes: 2 additions & 1 deletion tests/optimization_decorators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def extract_core(source: str) -> Term:
prog = parse_program(source)
core, ctx, _ = desugar(prog)
core, ctx, _, _ = desugar(prog)
core_anf = ensure_anf(core)
check_type_errors(ctx, core_anf, top)
return core_anf
Expand Down Expand Up @@ -41,6 +41,7 @@ def main(args:Int) : Unit {
core_ast,
typing_ctx,
evaluation_ctx,
metadata,
) = desugar(prog)

core_ast_anf = ensure_anf(core_ast)
Expand Down
2 changes: 1 addition & 1 deletion tests/pow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def check_compile(source, ty):
p, ctx, _ = desugar(parse_program(source))
p, ctx, _, _ = desugar(parse_program(source))
assert check_type(ctx, p, ty)


Expand Down
2 changes: 1 addition & 1 deletion tests/recursion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def check_compile(source, ty, res):
p, ctx, ectx = desugar(parse_program(source))
p, ctx, ectx, _ = desugar(parse_program(source))
assert check_type(ctx, p, ty)
# assert eval(p, ectx) == res

Expand Down
10 changes: 5 additions & 5 deletions tests/smt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def extract_core(source: str) -> Term:
prog = parse_program(source)
core, ctx, _ = desugar(prog)
core, ctx, _, _ = desugar(prog)
core_anf = ensure_anf(core)
check_type_errors(ctx, core_anf, top)
return core_anf
Expand All @@ -30,8 +30,7 @@ def extract_core(source: str) -> Term:
"x",
t_int,
LiquidApp("==", [LiquidVar("x"), LiquidLiteralInt(3)]),
LiquidConstraint(LiquidApp(
"==", [LiquidVar("x"), LiquidLiteralInt(3)])),
LiquidConstraint(LiquidApp("==", [LiquidVar("x"), LiquidLiteralInt(3)])),
)


Expand All @@ -47,8 +46,7 @@ def test_smt_example3():
"y",
BaseType("a"),
LiquidApp("==", [LiquidVar("x"), LiquidVar("y")]),
LiquidConstraint(LiquidApp(
"==", [LiquidVar("x"), LiquidVar("y")])),
LiquidConstraint(LiquidApp("==", [LiquidVar("x"), LiquidVar("y")])),
),
)

Expand Down Expand Up @@ -80,6 +78,7 @@ def main (x:Int) : Unit {
core_ast,
typing_ctx,
evaluation_ctx,
metadata,
) = desugar(prog)

core_ast_anf = ensure_anf(core_ast)
Expand All @@ -104,6 +103,7 @@ def main (x:Int) : Unit {
core_ast,
typing_ctx,
evaluation_ctx,
metadata,
) = desugar(prog)

core_ast_anf = ensure_anf(core_ast)
Expand Down
8 changes: 4 additions & 4 deletions tests/synth_fitness_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def synth (i: Int): Int { (?hole: Int) * i}
def __internal__fitness_function_synth : Int = year - synth(7);
"""
prog = parse_program(code)
p, ctx, ectx = desugar(prog)
p, ctx, ectx, _ = desugar(prog)
p = ensure_anf(p)
check_type_errors(ctx, p, top)
term = synthesize(ctx, ectx, p, [("synth", ["hole"])])
term = synthesize(ctx, ectx, p, [("synth", ["hole"])], {})

assert isinstance(term, Term)

Expand All @@ -50,9 +50,9 @@ def test_fitness2():
def synth (i:Int) : Int {(?hole: Int) * i}
"""
prog = parse_program(code)
p, ctx, ectx = desugar(prog)
p, ctx, ectx, _ = desugar(prog)
p = ensure_anf(p)
check_type_errors(ctx, p, top)
term = synthesize(ctx, ectx, p, [("synth", ["hole"])])
term = synthesize(ctx, ectx, p, [("synth", ["hole"])], {})

assert isinstance(term, Term)

0 comments on commit 466622b

Please sign in to comment.