Skip to content

Commit

Permalink
fix: Value distribution should use sums for graphs, not counts, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jan 26, 2023
1 parent 51eb34f commit 691809c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 10 additions & 0 deletions backend/exporter/leaf_tags/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ def counts_result_box_image(tag: LeafTag, data: Dict[str, Any]) -> etree.Element
)


@leaf("resultBoxImage")
def sums_result_box_image(tag: LeafTag, data: Dict[str, Any]) -> etree.Element:
return box_image(
tag,
graphs.bar_result_box,
f"resultBoxImage_{data['name']}.png",
data["sums_pairs"],
)


@leaf("resultBoxImage")
def passed_result_box_image(tag: LeafTag, data: Dict[str, Any]) -> etree.Element:
return box_image(
Expand Down
13 changes: 6 additions & 7 deletions backend/exporter/template_tags/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ocid_count,
passed_result_box_image,
result,
sums_result_box_image,
table_result_box_image,
top3_amount,
top3_count,
Expand Down Expand Up @@ -98,7 +99,7 @@ def finalize_arguments(self) -> None:
if check_type == "donut":
self.tags += (donut_share, donut_count, donut_examples, counts_result_box_image)
elif check_type == "bar":
self.tags += (bar_share, bar_count, bar_examples, bar_sum, counts_result_box_image)
self.tags += (bar_share, bar_count, bar_examples, bar_sum, sums_result_box_image)
elif check_type == "top3":
self.tags += (top3_share, top3_count, top3_examples, top3_amount, table_result_box_image)
elif check_type == "numeric":
Expand Down Expand Up @@ -163,20 +164,18 @@ def get_context(self) -> Dict[str, Any]:
if check.result is not None:
data["shares"] = {key.replace("_", "-"): value for key, value in check.meta["shares"].items()}
data["counts"] = {key.replace("_", "-"): value for key, value in check.meta["counts"].items()}
data["counts_pairs"] = [
(key.replace("_", "-"), value) for key, value in check.meta["counts"].items()
]
data["sums"] = {key.replace("_", "-"): value for key, value in check.meta["sums"].items()}
data["sums_pairs"] = [(key.replace("_", "-"), value) for key, value in check.meta["sums"].items()]
data["examples"] = {
key.replace("_", "-"): [example["ocid"] for example in examples]
for key, examples in check.meta["examples"].items()
}
data["sums"] = {key.replace("_", "-"): value for key, value in check.meta["sums"].items()}
else:
data["shares"] = {}
data["counts"] = {}
data["counts_pairs"] = []
data["examples"] = {}
data["sums"] = {}
data["sums_pairs"] = []
data["examples"] = {}
elif check_type == "top3":
data["shares"] = {str(index + 1): el["share"] for index, el in enumerate(check.meta["most_frequent"])}
data["counts"] = {str(index + 1): el["count"] for index, el in enumerate(check.meta["most_frequent"])}
Expand Down

0 comments on commit 691809c

Please sign in to comment.