From 5eac018dfbe907929fb66040b9f4ac28c0cffc9b Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sat, 14 Aug 2021 09:03:58 +0200 Subject: [PATCH 01/14] dont manipulate styler object on render through args --- pandas/io/formats/style.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index a72de753d6a8a..135b9ada8ec72 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -885,11 +885,13 @@ def to_html( -------- DataFrame.to_html: Write a DataFrame to a file, buffer or string in HTML format. """ + obj = self._copy(deepcopy=True) # manipulate table_styles on obj, not self + if table_uuid: - self.set_uuid(table_uuid) + obj.set_uuid(table_uuid) if table_attributes: - self.set_table_attributes(table_attributes) + obj.set_table_attributes(table_attributes) if sparse_index is None: sparse_index = get_option("styler.sparse.index") @@ -897,7 +899,7 @@ def to_html( sparse_columns = get_option("styler.sparse.columns") # Build HTML string.. - html = self._render_html( + html = obj._render_html( sparse_index=sparse_index, sparse_columns=sparse_columns, exclude_styles=exclude_styles, From 94f482e2bd73ecb19184aad65c8fe8324cc698fc Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sat, 14 Aug 2021 09:13:33 +0200 Subject: [PATCH 02/14] copy uuid on Styler --- pandas/io/formats/style.py | 2 +- pandas/tests/io/formats/style/test_style.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index a72de753d6a8a..a99fa2df9ac32 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1063,7 +1063,6 @@ def _copy(self, deepcopy: bool = False) -> Styler: # GH 40675 styler = Styler( self.data, # populates attributes 'data', 'columns', 'index' as shallow - uuid_len=self.uuid_len, ) shallow = [ # simple string or boolean immutables "hide_index_", @@ -1071,6 +1070,7 @@ def _copy(self, deepcopy: bool = False) -> Styler: "table_attributes", "cell_ids", "caption", + "uuid", ] deep = [ # nested lists or dicts "_display_funcs", diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 6cc4b889d369a..f4bb2c7680bb0 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -203,7 +203,6 @@ def test_copy(comprehensive, render, deepcopy, mi_styler, mi_styler_comp): excl = [ "na_rep", # deprecated "precision", # deprecated - "uuid", # special "cellstyle_map", # render time vars.. "cellstyle_map_columns", "cellstyle_map_index", @@ -217,6 +216,7 @@ def test_copy(comprehensive, render, deepcopy, mi_styler, mi_styler_comp): "columns", "index", "uuid_len", + "uuid", "caption", "cell_ids", "hide_index_", From abba0a5d0779b073b910d853eff4c81dbf0a82b5 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sat, 14 Aug 2021 09:15:33 +0200 Subject: [PATCH 03/14] copy uuid on Styler --- doc/source/whatsnew/v1.4.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index f0af60f80edd5..806b8154c1e54 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -238,6 +238,7 @@ Categorical - Bug in :meth:`Series.where` with ``CategoricalDtype`` when passing a dtype-incompatible value raising ``ValueError`` instead of ``TypeError`` (:issue:`41919`) - Bug in :meth:`Categorical.fillna` when passing a dtype-incompatible value raising ``ValueError`` instead of ``TypeError`` (:issue:`41919`) - Bug in :meth:`Categorical.fillna` with a tuple-like category raising ``ValueError`` instead of ``TypeError`` when filling with a non-category tuple (:issue:`41919`) +- Bug in :meth:`.Styler.copy` where ``uuid`` was not previously copied (:issue:`40675`) - Datetimelike From 57a81801d1416e01fa996667dbc9c49e304f97b6 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sat, 14 Aug 2021 09:42:46 +0200 Subject: [PATCH 04/14] check clearing tests --- pandas/tests/io/formats/style/test_style.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index f4bb2c7680bb0..ca9a1b43e441d 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -41,8 +41,8 @@ def mi_styler(mi_df): @pytest.fixture def mi_styler_comp(mi_styler): # comprehensively add features to mi_styler - mi_styler.uuid_len = 5 - mi_styler.uuid = "abcde_" + mi_styler.uuid_len = 8 + mi_styler.uuid = "abcdefgh_" mi_styler.set_caption("capt") mi_styler.set_table_styles([{"selector": "a", "props": "a:v;"}]) mi_styler.hide_columns() @@ -242,7 +242,7 @@ def test_clear(mi_styler_comp): # to ensure proper testing of the 'copy', 'clear', 'export' methods with new feature # GH 40675 styler = mi_styler_comp - styler.to_html() # new attrs maybe created on render + styler._compute() # execute applied methods clean_copy = Styler(styler.data, uuid=styler.uuid) @@ -250,8 +250,6 @@ def test_clear(mi_styler_comp): "data", "index", "columns", - "uuid", - "uuid_len", "cell_ids", "cellstyle_map", # execution time only "cellstyle_map_columns", # execution time only From 5d235616ec6b411325a32117980c360bc76ff1d2 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sat, 14 Aug 2021 09:42:46 +0200 Subject: [PATCH 05/14] check clearing tests --- pandas/tests/io/formats/style/test_style.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index f4bb2c7680bb0..ca9a1b43e441d 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -41,8 +41,8 @@ def mi_styler(mi_df): @pytest.fixture def mi_styler_comp(mi_styler): # comprehensively add features to mi_styler - mi_styler.uuid_len = 5 - mi_styler.uuid = "abcde_" + mi_styler.uuid_len = 8 + mi_styler.uuid = "abcdefgh_" mi_styler.set_caption("capt") mi_styler.set_table_styles([{"selector": "a", "props": "a:v;"}]) mi_styler.hide_columns() @@ -242,7 +242,7 @@ def test_clear(mi_styler_comp): # to ensure proper testing of the 'copy', 'clear', 'export' methods with new feature # GH 40675 styler = mi_styler_comp - styler.to_html() # new attrs maybe created on render + styler._compute() # execute applied methods clean_copy = Styler(styler.data, uuid=styler.uuid) @@ -250,8 +250,6 @@ def test_clear(mi_styler_comp): "data", "index", "columns", - "uuid", - "uuid_len", "cell_ids", "cellstyle_map", # execution time only "cellstyle_map_columns", # execution time only From df9f50ef354727f339d71d567c1786dcbc930f92 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sat, 14 Aug 2021 16:08:08 +0200 Subject: [PATCH 06/14] revert uuid len --- pandas/tests/io/formats/style/test_style.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index ca9a1b43e441d..a8bc361f255e4 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -41,8 +41,8 @@ def mi_styler(mi_df): @pytest.fixture def mi_styler_comp(mi_styler): # comprehensively add features to mi_styler - mi_styler.uuid_len = 8 - mi_styler.uuid = "abcdefgh_" + mi_styler.uuid_len = 5 + mi_styler.uuid = "abcde_" mi_styler.set_caption("capt") mi_styler.set_table_styles([{"selector": "a", "props": "a:v;"}]) mi_styler.hide_columns() From 8d8d1e567bbbeb25a16b64e26e50fc3dabea68ec Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sat, 14 Aug 2021 16:40:27 +0200 Subject: [PATCH 07/14] address the floating "_" in styler.uuid --- pandas/io/formats/style_render.py | 4 +-- pandas/io/formats/templates/html_style.tpl | 2 +- pandas/io/formats/templates/html_table.tpl | 4 +-- pandas/tests/io/formats/style/test_html.py | 28 +++++++++---------- pandas/tests/io/formats/style/test_style.py | 8 +++--- pandas/tests/io/formats/style/test_tooltip.py | 24 ++++++++-------- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index aa58b3abbd06c..241ae945039a5 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -90,7 +90,7 @@ def __init__( if not isinstance(uuid_len, int) or not uuid_len >= 0: raise TypeError("``uuid_len`` must be an integer in range [0, 32].") self.uuid_len = min(32, uuid_len) - self.uuid = (uuid or uuid4().hex[: self.uuid_len]) + "_" + self.uuid = uuid or uuid4().hex[: self.uuid_len] self.table_styles = table_styles self.table_attributes = table_attributes self.caption = caption @@ -1210,7 +1210,7 @@ def _pseudo_css(self, uuid: str, name: str, row: int, col: int, text: str): ------- pseudo_css : List """ - selector_id = "#T_" + uuid + "row" + str(row) + "_col" + str(col) + selector_id = "#T_" + uuid + "_row" + str(row) + "_col" + str(col) return [ { "selector": selector_id + f":hover .{name}", diff --git a/pandas/io/formats/templates/html_style.tpl b/pandas/io/formats/templates/html_style.tpl index 5b0e7a2ed882b..5c3fcd97f51bb 100644 --- a/pandas/io/formats/templates/html_style.tpl +++ b/pandas/io/formats/templates/html_style.tpl @@ -14,7 +14,7 @@ {% block cellstyle %} {% for cs in [cellstyle, cellstyle_index, cellstyle_columns] %} {% for s in cs %} -{% for selector in s.selectors %}{% if not loop.first %}, {% endif %}#T_{{uuid}}{{selector}}{% endfor %} { +{% for selector in s.selectors %}{% if not loop.first %}, {% endif %}#T_{{uuid}}_{{selector}}{% endfor %} { {% for p,val in s.props %} {{p}}: {{val}}; {% endfor %} diff --git a/pandas/io/formats/templates/html_table.tpl b/pandas/io/formats/templates/html_table.tpl index 3e3a40b9fdaa6..3ecd911c1ec07 100644 --- a/pandas/io/formats/templates/html_table.tpl +++ b/pandas/io/formats/templates/html_table.tpl @@ -27,7 +27,7 @@ {% else %} {% for c in r %} {% if c.is_visible != False %} - <{{c.type}} {%- if c.id is defined %} id="T_{{uuid}}{{c.id}}" {%- endif %} class="{{c.class}}" {{c.attributes}}>{{c.value}} + <{{c.type}} {%- if c.id is defined %} id="T_{{uuid}}_{{c.id}}" {%- endif %} class="{{c.class}}" {{c.attributes}}>{{c.value}} {% endif %} {% endfor %} {% endif %} @@ -49,7 +49,7 @@ {% endif %}{% endfor %} {% else %} {% for c in r %}{% if c.is_visible != False %} - <{{c.type}} {%- if c.id is defined %} id="T_{{uuid}}{{c.id}}" {%- endif %} class="{{c.class}}" {{c.attributes}}>{{c.display_value}} + <{{c.type}} {%- if c.id is defined %} id="T_{{uuid}}_{{c.id}}" {%- endif %} class="{{c.class}}" {{c.attributes}}>{{c.display_value}} {% endif %}{% endfor %} {% endif %} diff --git a/pandas/tests/io/formats/style/test_html.py b/pandas/tests/io/formats/style/test_html.py index bcf3c4dbad3a8..5b718a84a0a24 100644 --- a/pandas/tests/io/formats/style/test_html.py +++ b/pandas/tests/io/formats/style/test_html.py @@ -99,7 +99,7 @@ def test_w3_html_format(styler): #T_ th { att2: v2; } - #T_row0_col0, #T_row1_col0 { + #T__row0_col0, #T__row1_col0 { att1: v1; } @@ -108,17 +108,17 @@ def test_w3_html_format(styler):   - A + A - a - 2.6 + a + 2.6 - b - 2.7 + b + 2.7 @@ -142,7 +142,7 @@ def test_rowspan_w3(): def test_styles(styler): - styler.set_uuid("abc_") + styler.set_uuid("abc") styler.set_table_styles([{"selector": "td", "props": "color: red;"}]) result = styler.to_html(doctype_html=True) expected = dedent( @@ -152,13 +152,13 @@ def test_styles(styler): - +
@@ -418,15 +418,15 @@ def test_applymap_header_cell_ids(styler, index, columns): # test index header ids where needed and css styles assert ( - '' in result + '' in result ) is index assert ( - '' in result + '' in result ) is index - assert ("#T_level0_row0, #T_level0_row1 {\n attr: val;\n}" in result) is index + assert ("#T__level0_row0, #T__level0_row1 {\n attr: val;\n}" in result) is index # test column header ids where needed and css styles assert ( - '' in result + '' in result ) is columns - assert ("#T_level0_col0 {\n attr: val;\n}" in result) is columns + assert ("#T__level0_col0 {\n attr: val;\n}" in result) is columns diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 6cc4b889d369a..746ddb4d72232 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -1331,11 +1331,11 @@ def test_column_and_row_styling(self): df = DataFrame(data=[[0, 1], [1, 2]], columns=["A", "B"]) s = Styler(df, uuid_len=0) s = s.set_table_styles({"A": [{"selector": "", "props": [("color", "blue")]}]}) - assert "#T__ .col0 {\n color: blue;\n}" in s.render() + assert "#T_ .col0 {\n color: blue;\n}" in s.render() s = s.set_table_styles( {0: [{"selector": "", "props": [("color", "blue")]}]}, axis=1 ) - assert "#T__ .row0 {\n color: blue;\n}" in s.render() + assert "#T_ .row0 {\n color: blue;\n}" in s.render() @pytest.mark.parametrize("len_", [1, 5, 32, 33, 100]) def test_uuid_len(self, len_): @@ -1345,9 +1345,9 @@ def test_uuid_len(self, len_): strt = s.find('id="T_') end = s[strt + 6 :].find('"') if len_ > 32: - assert end == 32 + 1 + assert end == 32 else: - assert end == len_ + 1 + assert end == len_ @pytest.mark.parametrize("len_", [-2, "bad", None]) def test_uuid_len_raises(self, len_): diff --git a/pandas/tests/io/formats/style/test_tooltip.py b/pandas/tests/io/formats/style/test_tooltip.py index 71ce496cca030..bd34051cf29e1 100644 --- a/pandas/tests/io/formats/style/test_tooltip.py +++ b/pandas/tests/io/formats/style/test_tooltip.py @@ -39,23 +39,23 @@ def test_tooltip_render(ttips, styler): result = styler.set_tooltips(ttips).render() # test tooltip table level class - assert "#T__ .pd-t {\n visibility: hidden;\n" in result + assert "#T_ .pd-t {\n visibility: hidden;\n" in result # test 'Min' tooltip added - assert "#T__ #T__row0_col0:hover .pd-t {\n visibility: visible;\n}" in result - assert '#T__ #T__row0_col0 .pd-t::after {\n content: "Min";\n}' in result + assert "#T_ #T__row0_col0:hover .pd-t {\n visibility: visible;\n}" in result + assert '#T_ #T__row0_col0 .pd-t::after {\n content: "Min";\n}' in result assert 'class="data row0 col0" >0' in result # test 'Max' tooltip added - assert "#T__ #T__row0_col2:hover .pd-t {\n visibility: visible;\n}" in result - assert '#T__ #T__row0_col2 .pd-t::after {\n content: "Max";\n}' in result + assert "#T_ #T__row0_col2:hover .pd-t {\n visibility: visible;\n}" in result + assert '#T_ #T__row0_col2 .pd-t::after {\n content: "Max";\n}' in result assert 'class="data row0 col2" >2' in result # test Nan, empty string and bad column ignored - assert "#T__ #T__row1_col0:hover .pd-t {\n visibility: visible;\n}" not in result - assert "#T__ #T__row1_col1:hover .pd-t {\n visibility: visible;\n}" not in result - assert "#T__ #T__row0_col1:hover .pd-t {\n visibility: visible;\n}" not in result - assert "#T__ #T__row1_col2:hover .pd-t {\n visibility: visible;\n}" not in result + assert "#T_ #T__row1_col0:hover .pd-t {\n visibility: visible;\n}" not in result + assert "#T_ #T__row1_col1:hover .pd-t {\n visibility: visible;\n}" not in result + assert "#T_ #T__row0_col1:hover .pd-t {\n visibility: visible;\n}" not in result + assert "#T_ #T__row1_col2:hover .pd-t {\n visibility: visible;\n}" not in result assert "Bad-Col" not in result @@ -73,8 +73,8 @@ def test_tooltip_css_class(styler): css_class="other-class", props=[("color", "green")], ).render() - assert "#T__ .other-class {\n color: green;\n" in result - assert '#T__ #T__row0_col0 .other-class::after {\n content: "tooltip";\n' in result + assert "#T_ .other-class {\n color: green;\n" in result + assert '#T_ #T__row0_col0 .other-class::after {\n content: "tooltip";\n' in result # GH 39563 result = styler.set_tooltips( # set_tooltips overwrites previous @@ -82,4 +82,4 @@ def test_tooltip_css_class(styler): css_class="another-class", props="color:green;color:red;", ).render() - assert "#T__ .another-class {\n color: green;\n color: red;\n}" in result + assert "#T_ .another-class {\n color: green;\n color: red;\n}" in result From 321e7ca195002cd2dee77c481919b53c5a28159c Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sat, 14 Aug 2021 16:52:58 +0200 Subject: [PATCH 08/14] address the floating "_" in styler.uuid --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index f0af60f80edd5..9dc369d8c4258 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -349,7 +349,7 @@ ExtensionArray Styler ^^^^^^ -- +- Minor bug in :class:`.Styler` where the ``uuid`` at initialization maintained a floating underscore (:issue:`43037`) - Other From 47f216e05842cb6148b0be19d04e9ce3837ef4d3 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sun, 15 Aug 2021 08:02:15 +0200 Subject: [PATCH 09/14] uuid test --- pandas/tests/io/formats/style/test_style.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 67a8f94e5138e..15a856e701ace 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -251,6 +251,8 @@ def test_clear(mi_styler_comp): "index", "columns", "cell_ids", + "uuid", + "uuid_len", # uuid is set to be the same on styler and clean_copy "cellstyle_map", # execution time only "cellstyle_map_columns", # execution time only "cellstyle_map_index", # execution time only From 0e29614d10f7911a496a2ebcfe40a8bc2a796b4f Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Tue, 17 Aug 2021 19:24:10 +0200 Subject: [PATCH 10/14] copy uuid_len --- pandas/io/formats/style.py | 1 + pandas/io/formats/style_render.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 821e139c129ce..452b478623fa6 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1087,6 +1087,7 @@ def _copy(self, deepcopy: bool = False) -> Styler: "cell_ids", "caption", "uuid", + "uuid_len", ] deep = [ # nested lists or dicts "_display_funcs", diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 8c8112cf585a1..faabab9e269fd 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -89,8 +89,8 @@ def __init__( self.columns: Index = data.columns if not isinstance(uuid_len, int) or not uuid_len >= 0: raise TypeError("``uuid_len`` must be an integer in range [0, 32].") - self.uuid_len = min(32, uuid_len) - self.uuid = uuid or uuid4().hex[: self.uuid_len] + self.uuid = uuid or uuid4().hex[: min(32, uuid_len)] + self.uuid_len = len(self.uuid) self.table_styles = table_styles self.table_attributes = table_attributes self.caption = caption From 840a2a6431b3bc057e254624c82c67b1d1534571 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Tue, 17 Aug 2021 19:26:09 +0200 Subject: [PATCH 11/14] revert order --- pandas/tests/io/formats/style/test_style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 0a574f17421f0..f86206416d286 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -250,9 +250,9 @@ def test_clear(mi_styler_comp): "data", "index", "columns", - "cell_ids", "uuid", "uuid_len", # uuid is set to be the same on styler and clean_copy + "cell_ids", "cellstyle_map", # execution time only "cellstyle_map_columns", # execution time only "cellstyle_map_index", # execution time only From 6520cfe79d882a1758b4f7b679a8d575d71ad44c Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Thu, 19 Aug 2021 17:02:19 +0200 Subject: [PATCH 12/14] also copy templates --- pandas/io/formats/style.py | 4 ++++ pandas/tests/io/formats/style/test_html.py | 2 +- pandas/tests/io/formats/style/test_style.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index f2e411e28471d..eff0bd9637859 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1090,6 +1090,10 @@ def _copy(self, deepcopy: bool = False) -> Styler: "caption", "uuid", "uuid_len", + "template_latex", # also copy templates if these have been customised + "template_html_style", + "template_html_table", + "template_html", ] deep = [ # nested lists or dicts "_display_funcs", diff --git a/pandas/tests/io/formats/style/test_html.py b/pandas/tests/io/formats/style/test_html.py index 0087090feafce..777afe0ff0da4 100644 --- a/pandas/tests/io/formats/style/test_html.py +++ b/pandas/tests/io/formats/style/test_html.py @@ -260,7 +260,7 @@ def test_from_custom_template_style(tmpdir): assert result.env is not Styler.env assert result.template_html_style is not Styler.template_html_style styler = result(DataFrame({"A": [1, 2]})) - assert '\n\n\n\n Date: Thu, 19 Aug 2021 17:10:17 +0200 Subject: [PATCH 13/14] whats new --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 33179cbd3a4d2..d37fffb0b4e8f 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -355,7 +355,7 @@ ExtensionArray Styler ^^^^^^ - Minor bug in :class:`.Styler` where the ``uuid`` at initialization maintained a floating underscore (:issue:`43037`) -- +- Bug in :meth:`.Style.to_html` where the ``Styler`` object was updated if the ``to_html`` method was called with some args (:issue:`43034`) Other ^^^^^ From 7b661adb7bc459c159fe90aa71c2b1a2b6407566 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Thu, 19 Aug 2021 17:10:42 +0200 Subject: [PATCH 14/14] whats new --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index d37fffb0b4e8f..daa6a5d894191 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -355,7 +355,7 @@ ExtensionArray Styler ^^^^^^ - Minor bug in :class:`.Styler` where the ``uuid`` at initialization maintained a floating underscore (:issue:`43037`) -- Bug in :meth:`.Style.to_html` where the ``Styler`` object was updated if the ``to_html`` method was called with some args (:issue:`43034`) +- Bug in :meth:`.Styler.to_html` where the ``Styler`` object was updated if the ``to_html`` method was called with some args (:issue:`43034`) Other ^^^^^
 aabbAA