File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ Version 1.1.2
1212Changelog
1313---------
1414
15+ - |Fix | A default HTML representation is shown for meta-estimators with invalid
16+ parameters. :pr: `24015 ` by `Thomas Fan `_.
17+
1518:mod: `sklearn.cluster `
1619......................
1720
Original file line number Diff line number Diff line change 11from contextlib import closing
2- from contextlib import suppress
32from io import StringIO
43from string import Template
54import html
@@ -103,8 +102,16 @@ def _write_label_html(
103102
104103def _get_visual_block (estimator ):
105104 """Generate information about how to display an estimator."""
106- with suppress (AttributeError ):
107- return estimator ._sk_visual_block_ ()
105+ if hasattr (estimator , "_sk_visual_block_" ):
106+ try :
107+ return estimator ._sk_visual_block_ ()
108+ except Exception :
109+ return _VisualBlock (
110+ "single" ,
111+ estimator ,
112+ names = estimator .__class__ .__name__ ,
113+ name_details = str (estimator ),
114+ )
108115
109116 if isinstance (estimator , str ):
110117 return _VisualBlock (
Original file line number Diff line number Diff line change @@ -309,3 +309,14 @@ def test_show_arrow_pipeline():
309309 'class="sk-toggleable__label sk-toggleable__label-arrow">Pipeline'
310310 in html_output
311311 )
312+
313+
314+ def test_invalid_parameters_in_stacking ():
315+ """Invalidate stacking configuration uses default repr.
316+
317+ Non-regression test for #24009.
318+ """
319+ stacker = StackingClassifier (estimators = [])
320+
321+ html_output = estimator_html_repr (stacker )
322+ assert html .escape (str (stacker )) in html_output
You can’t perform that action at this time.
0 commit comments