Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ultmaster committed Nov 6, 2023
1 parent f147d8e commit 7e5477a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
26 changes: 13 additions & 13 deletions coml/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
</style>
"""

VERIFY_STATUS_ICON = {
"error": "❌",
"warning": "⚠️",
"info": "ℹ️",
"ok": "✅",
None: "❔",
True: "✅",
False: "❌",
}


@magics_class
class CoMLMagics(Magics):
Expand Down Expand Up @@ -253,18 +263,8 @@ def comlverify(self, line):
error, output = parse_cell_outputs(target_cell["outputs"])
generated_vis = output and "<image/svg+xml>" in output

status_icon = {
"error": "❌",
"warning": "⚠️",
"info": "ℹ️",
"ok": "✅",
"unknown": "❔",
True: "✅",
False: "❌",
}

def display_statuses(statuses):
# clear_output(wait=True)
clear_output(wait=True)
html = VERIFY_STYLE + "\n"
display_names = {
"lint": "PyLint",
Expand All @@ -287,7 +287,7 @@ def display_statuses(statuses):
display_names[name],
loading
if name not in statuses
else status_icon[statuses[name]["result"]],
else VERIFY_STATUS_ICON[statuses[name]["result"]],
detail_message,
)

Expand Down Expand Up @@ -327,7 +327,7 @@ def display_statuses(statuses):
)
details = ""
for detail in visualization_check_details:
details += status_icon[detail[0]] + " " + detail[1] + "\n"
details += VERIFY_STATUS_ICON[detail[0]] + " " + detail[1] + "\n"
result["vis"] = {
"result": visualization_check_result,
"details": details,
Expand Down
23 changes: 9 additions & 14 deletions coml/vis_utils/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,6 @@ def check_order(order: dict, chart_info: dict):


NUM_SAMPLE = 3
ANSWER_TYPE = {
"right": True,
"wrong": False,
"unknown": "unknown",
}


class VisVerifier:
Expand All @@ -634,11 +629,11 @@ def _add_verification(self, verification):
self.verifications.append(verification)
# display
answer = ""
if verification["answer"] == ANSWER_TYPE["wrong"]:
answer = "❌"
elif verification["answer"] == ANSWER_TYPE["right"]:
if verification["answer"] is True:
answer = "✅"
elif verification["answer"] == ANSWER_TYPE["unknown"]:
elif verification["answer"] is False:
answer = "❌"
elif verification["answer"] is None:
answer = "❔"
aspect = verification["aspect"].capitalize()
rationale = verification["rationale"]
Expand All @@ -654,7 +649,7 @@ def verify(
):
self.verifications = []
understand_fail_result = {
"answer": ANSWER_TYPE["unknown"],
"answer": None,
"aspect": "Visualization understanding",
"rationale": "Cannot understand the visualization.",
}
Expand All @@ -671,7 +666,7 @@ def verify(
self.verify_chart_info(request, chart_info, variable_descriptions)
pass_verify = all(
[
verification["answer"] == ANSWER_TYPE["right"]
verification["answer"] is True
for verification in self.verifications
]
)
Expand Down Expand Up @@ -728,7 +723,7 @@ def verify_data(
if "title" not in encoding[channel]:
verification = {
"aspect": channel + " label",
"answer": ANSWER_TYPE["unknown"],
"answer": None,
"rationale": "Channel "
+ channel
+ " is not labeled, so accurate understanding of the data on the graph is difficult.",
Expand Down Expand Up @@ -768,12 +763,12 @@ def verify_data(
if verification:
self._add_verification(verification)
verifications.append(verification)
if verification["answer"] != ANSWER_TYPE["right"]:
if verification["answer"] is not True:
break

pass_verify = all(
[
verification["answer"] == ANSWER_TYPE["right"]
verification["answer"] is True
for verification in verifications
]
)
Expand Down

0 comments on commit 7e5477a

Please sign in to comment.