Skip to content

Commit d72597e

Browse files
committed
show transformed data not dataop itself in fit report
1 parent 9f793ba commit d72597e

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

skrub/_data_ops/_inspection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def _use_table_report_display():
5050

5151

5252
def node_report(data_op, mode="preview", environment=None, **report_kwargs):
53-
result = evaluate(data_op, mode=mode, environment=environment)
53+
if mode in data_op._skrub_impl.results:
54+
result = data_op._skrub_impl.results[mode]
55+
else:
56+
result = evaluate(data_op, mode=mode, environment=environment)
5457
if sbd.is_column(result):
5558
# TODO say in page that it was a column not df
5659
# maybe this should be handled by tablereport? or we should have a

skrub/_data_ops/tests/test_inspection.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import sys
44
import webbrowser
5+
from pathlib import Path
56
from unittest.mock import Mock
67

78
import pytest
@@ -84,6 +85,25 @@ def test_full_report_failed_apply():
8485
assert report["error"] is not None
8586

8687

88+
@pytest.mark.skipif(not _inspection._has_graphviz(), reason="report requires graphviz")
89+
def test_report_fit_mode():
90+
# non-regression: in fit mode the individual node pages used to show the
91+
# dataop itself as the output instead of the result of fit_transform for
92+
# intermediate nodes.
93+
learner = (
94+
skrub.var("a")
95+
.skb.apply_func(lambda x: x[::-1])
96+
.skb.apply_func(lambda x: x.upper())
97+
.skb.make_learner()
98+
)
99+
report = learner.report(environment={"a": "hello"}, mode="fit", open=False)
100+
report_dir = Path(report["report_path"]).parent
101+
node_1_report = (report_dir / "node_1.html").read_text("utf-8")
102+
# the page does display the actual output rather than the repr of the node
103+
# ('hello'[::-1] = 'olleh')
104+
assert "olleh" in node_1_report
105+
106+
87107
@pytest.mark.skipif(not _inspection._has_graphviz(), reason="report requires graphviz")
88108
def test_full_report_open(monkeypatch):
89109
mock = Mock()

0 commit comments

Comments
 (0)