Skip to content

Commit

Permalink
lint and fix detect_imm_leafs for empty behav
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Nov 12, 2024
1 parent 15cebc0 commit e45abd7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions seal5/backends/report/status/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def get_status(filtered_metrics, instr_name, invert: bool = False):
data_["n_failed"] = len(data_["failed"])
del data_["failed"]
data_["n_total"] = data_["n_failed"] + data_["n_skipped"] + data_["n_success"]

def helper(success, skipped, failed):
if failed:
return "bad"
Expand All @@ -201,6 +202,7 @@ def helper(success, skipped, failed):
if success:
return "good"
return "unknown"

data_["status"] = helper(data_["n_success"], data_["n_skipped"], data_["n_failed"])
status_data.append(data_)
status_df = pd.DataFrame(status_data)
Expand Down
1 change: 1 addition & 0 deletions seal5/backends/report/test_results/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def get_unused_tests(tests, used_keys):
counts = group_df["result"].value_counts()
n_pass = counts.get("PASS", 0)
n_fail = counts.get("FAIL", 0)

def helper(n_tests, n_pass, n_fail):
if n_fail:
return "bad"
Expand Down
2 changes: 1 addition & 1 deletion seal5/backends/report/times/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def traverse(x, prefix=None):
if args.pass_times:
pass_times_df = pd.DataFrame(pass_times).sort_values("start")
if args.sum_level:
pass_times_df["pass"] = pass_times_df["pass"].apply(lambda x: ".".join(x.split(".")[:args.sum_level]))
pass_times_df["pass"] = pass_times_df["pass"].apply(lambda x: ".".join(x.split(".")[: args.sum_level]))
pass_times_df = pass_times_df.groupby("pass", as_index=False).agg({"start": "min", "end": "max"})
pass_times_df["time_s"] = pass_times_df["end"] - pass_times_df["start"]
pass_times_df.sort_values("start", inplace=True)
Expand Down
3 changes: 0 additions & 3 deletions seal5/transform/detect_imm_leafs/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ def run(args):
operand = instr_def.operands.get(name)
assert operand is not None
operand.attributes[seal5.model.Seal5OperandAttribute.IS_IMM_LEAF] = []
# print("operand.attributes", operand.attributes)
# input("??")
instr_def.operands[name] = operand
metrics["n_success"] += 1
metrics["success_instructions"].append(instr_def.name)
except Exception as ex:
logger.exception(ex)
input(">>>2")
metrics["n_failed"] += 1
metrics["failed_instructions"].append(instr_def.name)

Expand Down
2 changes: 1 addition & 1 deletion seal5/transform/detect_imm_leafs/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def block(self: behav.Block, context):
continue
stmts.append(stmt)

return reduce(lambda x, y: x | y, stmts)
return reduce(lambda x, y: x | y, stmts) if len(stmts) > 0 else Mode.NONE


def binary_operation(self: behav.BinaryOperation, context):
Expand Down

0 comments on commit e45abd7

Please sign in to comment.