Skip to content

Commit

Permalink
feat: group comparisons
Browse files Browse the repository at this point in the history
feat: group comparisons
  • Loading branch information
Patil committed Jul 7, 2022
1 parent 8e8ac00 commit 67d54af
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
3 changes: 2 additions & 1 deletion popmon/visualization/histogram_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ def transform(self, data_obj: dict, sections: Optional[list] = None):
plot_type_layouts["heatmap"] = hplots[0]["layout"]

plots = hplots + plots
# print(plot_types,layouts)

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": plot_type_layouts,
"plots": plots,
}
)

sections.append(
{
"section_title": self.section_name,
Expand Down
41 changes: 29 additions & 12 deletions popmon/visualization/section_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

from popmon.analysis.comparison import Comparisons
from popmon.analysis.profiling import Profiles

from ..base import Module
from ..config import Report
from ..config import Report, Settings, Comparison
from ..utils import filter_metrics, parallel, short_date
from ..visualization.utils import _prune, plot_bars

Expand Down Expand Up @@ -126,13 +125,12 @@ def __init__(
self.skip_empty_plots = settings.skip_empty_plots
self.description = description
self.show_stats = settings.show_stats if not settings.extended_report else None

self.primary_color = settings.primary_color
self.tl_colors = settings.tl_colors

def get_description(self):
return self.section_name

def transform(
self,
data_obj: dict,
Expand Down Expand Up @@ -204,14 +202,33 @@ def transform(
del layouts["shapes"]
if "range" in layouts["yaxis"]:
del layouts["yaxis"]["range"]

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": sorted(plots, key=lambda plot: plot["name"]),
}
)


if(self.section_name == "Comparisons"):
prev_key = "Rolling Reference " + "(window = " + str(Comparison().window) + ", Shift = " + str(Comparison().shift) + ")"
reference_key = Settings().reference_type + " Reference"
grouped_metrics = {reference_key: [], prev_key:[]}
for plot in plots:
if "ref" in plot["name"]:
grouped_metrics[reference_key].append(plot)
else :
grouped_metrics[prev_key].append(plot)

features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": grouped_metrics,
}
)
else:
features_w_metrics.append(
{
"name": feature,
"plot_type_layouts": {"barplot": layouts},
"plots": plots,
}
)

sections.append(
{
Expand Down
5 changes: 5 additions & 0 deletions popmon/visualization/templates/assets/css/custom-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ section {
padding: 70px 0
}

h3 {
width: calc(100% - 100px);
margin: 20px 20px 20px 20px;
}

a.nav-link {
cursor: pointer;
font-weight: 300;
Expand Down
13 changes: 13 additions & 0 deletions popmon/visualization/templates/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,25 @@ <h2>{{ section_title }}</h2>
{%- endfor -%}
</script>
<div class="row section_feature" data-section-feature="{{ feature.name }}">
{%- if feature.plots is mapping -%}
{%- for ref,plots in feature.plots.items() -%}
{%- set count = (plots|length + 1)*(loop.index - 1) -%}
<h3> {{ref}} </h3>
{%- for metric in plots -%}
{%- set plt = count + loop.index -%}
{%- with metric=metric -%}
{%- include 'card.html' -%}
{%- endwith -%}
{%- endfor -%}
{%- endfor -%}
{%- else -%}
{%- for metric in feature.plots -%}
{%- set plt = loop.index -%}
{%- with metric=metric -%}
{%- include 'card.html' -%}
{%- endwith -%}
{%- endfor -%}
{%- endif-%}
</div>
{%- endfor -%}
{%- else -%}
Expand Down

0 comments on commit 67d54af

Please sign in to comment.