Skip to content

Commit

Permalink
accomodate zoom and pan anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Oct 3, 2023
1 parent bd39ba6 commit c63b19a
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions tests/integration/plots/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def verify_vega(
html_result,
json_result,
split_json_result,
title,
x_label,
y_label,
):
Expand All @@ -125,16 +126,27 @@ def verify_vega(
assert "<DVC_METRIC_Y_LABEL>" in split_json_result[0]["content"]

def _assert_templates_equal(
html_template, filled_template, split_template, x_label, y_label
html_template, filled_template, split_template, title, x_label, y_label
):
# besides split anchors, json and split json should be equal
paths = [["data", "values"], ["encoding", "color"]]
tmp1 = deepcopy(html_template)
tmp2 = deepcopy(filled_template)
tmp3 = json.loads(
split_template[:]
.replace("<DVC_METRIC_TITLE>", title)
.replace("<DVC_METRIC_X_LABEL>", x_label)
.replace("<DVC_METRIC_Y_LABEL>", y_label)
.replace(
'"<DVC_METRIC_ZOOM_AND_PAN>"',
json.dumps(
{
"name": "grid",
"select": "interval",
"bind": "scales",
}
),
)
)
for path in paths:
dpath.set(tmp1, path, {})
Expand All @@ -147,6 +159,7 @@ def _assert_templates_equal(
html_result,
json_result[0]["content"],
split_json_result[0]["content"],
title,
x_label,
y_label,
)
Expand Down Expand Up @@ -235,15 +248,16 @@ def test_repo_with_plots(tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_
)
verify_image(tmp_dir, "workspace", "image.png", image_v1, html_path, json_data)

for plot, x_label, y_label in [
("linear.json", "x", "y"),
("confusion.json", "predicted", "actual"),
for plot, title, x_label, y_label in [
("linear.json", "linear", "x", "y"),
("confusion.json", "confusion matrix", "predicted", "actual"),
]:
verify_vega(
"workspace",
html_result[plot],
json_data[plot],
split_json_data[plot],
title,
x_label,
y_label,
)
Expand All @@ -264,15 +278,16 @@ def test_repo_with_plots(tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_
verify_image(tmp_dir, "workspace", "image.png", image_v2, html_path, json_data)
verify_image(tmp_dir, "HEAD", "image.png", image_v1, html_path, json_data)

for plot, x_label, y_label in [
("linear.json", "x", "y"),
("confusion.json", "predicted", "actual"),
for plot, title, x_label, y_label in [
("linear.json", "linear", "x", "y"),
("confusion.json", "confusion matrix", "predicted", "actual"),
]:
verify_vega(
["HEAD", "workspace"],
html_result[plot],
json_data[plot],
split_json_data[plot],
title,
x_label,
y_label,
)
Expand Down Expand Up @@ -340,15 +355,16 @@ def test_repo_with_plots(tmp_dir, scm, dvc, capsys, run_copy_metrics, repo_with_
},
)

for plot, x_label, y_label in [
("../linear.json", "x", "y"),
("../confusion.json", "predicted", "actual"),
for plot, title, x_label, y_label in [
("../linear.json", "linear", "x", "y"),
("../confusion.json", "confusion matrix", "predicted", "actual"),
]:
verify_vega(
["HEAD", "workspace"],
html_result[plot],
json_data[plot],
split_json_data[plot],
title,
x_label,
y_label,
)
Expand Down

0 comments on commit c63b19a

Please sign in to comment.