@@ -234,7 +234,7 @@ def show_granular_attributions(
234
234
if display :
235
235
ts .show (fig )
236
236
if return_html :
237
- return ts .render_to_html ( fig )
237
+ return ts .lowering . render_to_html_as_root ( fg . treescope_part_from_display_object ( fig ) )
238
238
239
239
240
240
def show_token_attributions (
@@ -372,7 +372,7 @@ def show_token_attributions(
372
372
if display :
373
373
ts .show (fig )
374
374
if return_html :
375
- return ts .render_to_html ( fig )
375
+ return ts .lowering . render_to_html_as_root ( fg . treescope_part_from_display_object ( fig ) )
376
376
377
377
378
378
def get_attribution_colors (
@@ -621,12 +621,12 @@ def get_single_token_heatmap_treescope(
621
621
parts .append (rp .text (repl ))
622
622
if (show_empty_tokens and token != "" ) or curr_tok != "" :
623
623
show_token = token if show_empty_tokens and curr_tok == "" else curr_tok
624
- highlighted_text = fg .treescope_part_from_display_object (
625
- fg .text_on_color (show_token , value = round (score , rounding ), vmin = min_val , vmax = max_val , colormap = colormap )
626
- )
627
- parts [idx_highlight ] = highlighted_text
628
624
else :
629
- parts .pop (idx_highlight )
625
+ show_token = " "
626
+ highlighted_text = fg .treescope_part_from_display_object (
627
+ fg .text_on_color (show_token , value = round (score , rounding ), vmin = min_val , vmax = max_val , colormap = colormap )
628
+ )
629
+ parts [idx_highlight ] = highlighted_text
630
630
if return_highlighted_idx :
631
631
return parts , idx_highlight , show_token
632
632
return parts
0 commit comments