Skip to content

Commit 7215e84

Browse files
add mean transform to linear plot tooltip (#151)
Co-authored-by: Matt Seddon <[email protected]>
1 parent 012111f commit 7215e84

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module = [
106106
ignore_missing_imports = true
107107

108108
[tool.codespell]
109-
ignore-words-list = " "
109+
ignore-words-list = "fpr"
110110

111111
[tool.ruff]
112112
ignore = [

src/dvc_render/vega_templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ class SmoothLinearTemplate(Template):
594594
{"calculate": Template.anchor("pivot_field"), "as": "pivot_field"},
595595
{
596596
"pivot": "pivot_field",
597+
"op": "mean",
597598
"value": Template.anchor("y"),
598599
"groupby": [Template.anchor("x")],
599600
},

tests/test_vega.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,46 @@ def test_no_revs_with_datapoints():
604604
}
605605

606606

607+
# https://github.com/iterative/studio/issues/8851
608+
def test_linear_tooltip_groupby():
609+
datapoints = [
610+
{
611+
"filename": "roc.json",
612+
"fpr": 0.00399400898652022,
613+
"tpr": 0.193158953722334,
614+
"rev": "main",
615+
"threshold": 0.84,
616+
},
617+
{
618+
"filename": "roc.json",
619+
"fpr": 0.00399400898652022,
620+
"tpr": 0.2012072434607646,
621+
"rev": "main",
622+
"threshold": 0.829854797979798,
623+
},
624+
{
625+
"filename": "roc.json",
626+
"fpr": 0.00399400898652022,
627+
"tpr": 0.20724346076458752,
628+
"rev": "main",
629+
"threshold": 0.8266666666666667,
630+
},
631+
]
632+
633+
props = {
634+
"anchors_y_definitions": [{"filename": "test", "field": "fpr"}],
635+
"revs_with_datapoints": ["main"],
636+
"template": "linear",
637+
"x": "fpr",
638+
"y": "tpr",
639+
}
640+
641+
renderer = VegaRenderer(datapoints, "foo", **props)
642+
plot_content = renderer.get_filled_template()
643+
644+
assert plot_content["layer"][3]["transform"][1]["op"] == "mean"
645+
646+
607647
@pytest.mark.parametrize(
608648
(
609649
"anchors_y_definitions",

0 commit comments

Comments
 (0)