File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -1049,10 +1049,12 @@ def to_latex(
1049
1049
clines = clines ,
1050
1050
)
1051
1051
1052
- encoding = encoding or get_option ("styler.render.encoding" )
1053
- return save_to_buffer (
1054
- latex , buf = buf , encoding = None if buf is None else encoding
1052
+ encoding = (
1053
+ (encoding or get_option ("styler.render.encoding" ))
1054
+ if isinstance (buf , str ) # i.e. a filepath
1055
+ else encoding
1055
1056
)
1057
+ return save_to_buffer (latex , buf = buf , encoding = encoding )
1056
1058
1057
1059
def to_html (
1058
1060
self ,
@@ -1173,15 +1175,14 @@ def to_html(
1173
1175
if caption is not None :
1174
1176
obj .set_caption (caption )
1175
1177
1176
- encoding = encoding or get_option ("styler.render.encoding" )
1177
1178
# Build HTML string..
1178
1179
html = obj ._render_html (
1179
1180
sparse_index = sparse_index ,
1180
1181
sparse_columns = sparse_columns ,
1181
1182
max_rows = max_rows ,
1182
1183
max_cols = max_columns ,
1183
1184
exclude_styles = exclude_styles ,
1184
- encoding = encoding ,
1185
+ encoding = encoding or get_option ( "styler.render.encoding" ) ,
1185
1186
doctype_html = doctype_html ,
1186
1187
** kwargs ,
1187
1188
)
Original file line number Diff line number Diff line change @@ -1547,3 +1547,10 @@ def test_col_trimming_hide_columns():
1547
1547
assert ctx ["head" ][0 ][c + 2 ]["is_visible" ] == vals [1 ]
1548
1548
1549
1549
assert len (ctx ["body" ][0 ]) == 6 # index + 2 hidden + 2 visible + trimming col
1550
+
1551
+
1552
+ @pytest .mark .parametrize ("format" , ["html" , "latex" ])
1553
+ def test_output_buffer (mi_styler , format ):
1554
+ # gh 47053
1555
+ with open (f"delete_me.{ format } " , "w" ) as f :
1556
+ getattr (mi_styler , f"to_{ format } " )(f )
You can’t perform that action at this time.
0 commit comments