From d49875940d14bd8fb85763752d8dc9e5afb92044 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:01:52 -0700 Subject: [PATCH 01/10] bug fix and added mathjax_ignore to tests --- pandas/io/formats/html.py | 1 + pandas/tests/io/formats/style/test_style.py | 4 ++-- pandas/tests/io/formats/test_to_html.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/io/formats/html.py b/pandas/io/formats/html.py index fdea1831d5596..c4884ef4ce4a9 100644 --- a/pandas/io/formats/html.py +++ b/pandas/io/formats/html.py @@ -241,6 +241,7 @@ def _write_table(self, indent: int = 0) -> None: use_mathjax = get_option("display.html.use_mathjax") if not use_mathjax: _classes.append("tex2jax_ignore") + _classes.append("mathjax_ignore") if self.classes is not None: if isinstance(self.classes, str): self.classes = self.classes.split() diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index e9fc2b2d27afd..411487117f7b6 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -487,10 +487,10 @@ def test_repr_html_ok(self, styler): def test_repr_html_mathjax(self, styler): # gh-19824 / 41395 - assert "tex2jax_ignore" not in styler._repr_html_() + assert "tex2jax_ignore" and "mathjax_ignore" not in styler._repr_html_() with option_context("styler.html.mathjax", False): - assert "tex2jax_ignore" in styler._repr_html_() + assert "tex2jax_ignore" and "mathjax_ignore" in styler._repr_html_() def test_update_ctx(self, styler): styler._update_ctx(DataFrame({"A": ["color: red", "color: blue"]})) diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index 8031f67cd0567..7d98e9c88ca81 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -933,10 +933,10 @@ def test_repr_html(self, float_frame): def test_repr_html_mathjax(self): df = DataFrame([[1, 2], [3, 4]]) - assert "tex2jax_ignore" not in df._repr_html_() + assert "tex2jax_ignore" and "mathjax_ignore" not in df._repr_html_() with option_context("display.html.use_mathjax", False): - assert "tex2jax_ignore" in df._repr_html_() + assert "tex2jax_ignore" and "mathjax_ignore" in df._repr_html_() def test_repr_html_wide(self): max_cols = 20 From 4f0d662be1a050f235803390c6a6be9afab4a959 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:07:50 -0700 Subject: [PATCH 02/10] added bug fix in what's new for 3.0 --- doc/source/whatsnew/v3.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index e5376177d3381..c7b1bc9daddba 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -698,6 +698,7 @@ I/O - Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`) - Bug in :meth:`read_stata` where extreme value integers were incorrectly interpreted as missing for format versions 111 and prior (:issue:`58130`) - Bug in :meth:`read_stata` where the missing code for double was not recognised for format versions 105 and prior (:issue:`58149`) +- Bug in :meth:`set_option` where disabling pandas option display.html.use_mathjax has no effect (:issue:`59884`) Period ^^^^^^ From 66f098f04739768f308a42d40447c2015be58853 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Tue, 15 Oct 2024 06:49:05 +0800 Subject: [PATCH 03/10] Update test_style.py --- 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 411487117f7b6..d0fa1591a70e6 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -487,10 +487,10 @@ def test_repr_html_ok(self, styler): def test_repr_html_mathjax(self, styler): # gh-19824 / 41395 - assert "tex2jax_ignore" and "mathjax_ignore" not in styler._repr_html_() + assert "tex2jax_ignore" not in styler._repr_html_() and "mathjax_ignore" not in styler._repr_html_() with option_context("styler.html.mathjax", False): - assert "tex2jax_ignore" and "mathjax_ignore" in styler._repr_html_() + assert "tex2jax_ignore" in styler._repr_html_() and "mathjax_ignore" in styler._repr_html_() def test_update_ctx(self, styler): styler._update_ctx(DataFrame({"A": ["color: red", "color: blue"]})) From bac4dc4145dcd765b4cf588787788dad082cc0a8 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Tue, 15 Oct 2024 06:49:53 +0800 Subject: [PATCH 04/10] Update test_to_html.py --- pandas/tests/io/formats/test_to_html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index 7d98e9c88ca81..002911b10fc6f 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -933,10 +933,10 @@ def test_repr_html(self, float_frame): def test_repr_html_mathjax(self): df = DataFrame([[1, 2], [3, 4]]) - assert "tex2jax_ignore" and "mathjax_ignore" not in df._repr_html_() + assert "tex2jax_ignore" not in df._repr_html_() and "mathjax_ignore" not in df._repr_html_() with option_context("display.html.use_mathjax", False): - assert "tex2jax_ignore" and "mathjax_ignore" in df._repr_html_() + assert "tex2jax_ignore" in df._repr_html_() and "mathjax_ignore" in df._repr_html_() def test_repr_html_wide(self): max_cols = 20 From c85871a4fdf75a5ab3579d3ce126906fcb4621f7 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Tue, 15 Oct 2024 07:12:02 +0800 Subject: [PATCH 05/10] Update test_style.py --- pandas/tests/io/formats/style/test_style.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index d0fa1591a70e6..ff8a1b9f570ab 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -487,10 +487,12 @@ def test_repr_html_ok(self, styler): def test_repr_html_mathjax(self, styler): # gh-19824 / 41395 - assert "tex2jax_ignore" not in styler._repr_html_() and "mathjax_ignore" not in styler._repr_html_() + assert "tex2jax_ignore" not in styler._repr_html_() + assert "mathjax_ignore" not in styler._repr_html_() with option_context("styler.html.mathjax", False): - assert "tex2jax_ignore" in styler._repr_html_() and "mathjax_ignore" in styler._repr_html_() + assert "tex2jax_ignore" in styler._repr_html_() + assert "mathjax_ignore" in styler._repr_html_() def test_update_ctx(self, styler): styler._update_ctx(DataFrame({"A": ["color: red", "color: blue"]})) From c068e2140300c54dfe3a08b9db323d5e9b02f4e1 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Tue, 15 Oct 2024 07:12:34 +0800 Subject: [PATCH 06/10] Update test_to_html.py --- pandas/tests/io/formats/test_to_html.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index 002911b10fc6f..b1a437bfdbd8a 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -933,10 +933,12 @@ def test_repr_html(self, float_frame): def test_repr_html_mathjax(self): df = DataFrame([[1, 2], [3, 4]]) - assert "tex2jax_ignore" not in df._repr_html_() and "mathjax_ignore" not in df._repr_html_() + assert "tex2jax_ignore" not in df._repr_html_() + assert "mathjax_ignore" not in df._repr_html_() with option_context("display.html.use_mathjax", False): - assert "tex2jax_ignore" in df._repr_html_() and "mathjax_ignore" in df._repr_html_() + assert "tex2jax_ignore" in df._repr_html_() + assert "mathjax_ignore" in df._repr_html_() def test_repr_html_wide(self): max_cols = 20 From 41521d4a3b74b134842cb1c4bf6b46e8c043a6f2 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:20:55 -0700 Subject: [PATCH 07/10] updated style_render to include mathjax_ignore --- pandas/io/formats/style_render.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 08d9fd938c873..37aff2c239381 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -366,9 +366,11 @@ def _translate( if not get_option("styler.html.mathjax"): table_attr = table_attr or "" if 'class="' in table_attr: - table_attr = table_attr.replace('class="', 'class="tex2jax_ignore ') + table_attr = table_attr.replace( + 'class="', 'class="tex2jax_ignore mathjax_ignore"' + ) else: - table_attr += ' class="tex2jax_ignore"' + table_attr += ' class="tex2jax_ignore mathjax_ignore"' d.update({"table_attributes": table_attr}) if self.tooltips: From f015fb1e3d20377bd54e8174e9e7010fc168c4e1 Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:30:58 -0700 Subject: [PATCH 08/10] Update doc/source/whatsnew/v3.0.0.rst Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com> --- doc/source/whatsnew/v3.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index c7b1bc9daddba..ad30dc5b9b56b 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -698,7 +698,7 @@ I/O - Bug in :meth:`read_stata` raising ``KeyError`` when input file is stored in big-endian format and contains strL data. (:issue:`58638`) - Bug in :meth:`read_stata` where extreme value integers were incorrectly interpreted as missing for format versions 111 and prior (:issue:`58130`) - Bug in :meth:`read_stata` where the missing code for double was not recognised for format versions 105 and prior (:issue:`58149`) -- Bug in :meth:`set_option` where disabling pandas option display.html.use_mathjax has no effect (:issue:`59884`) +- Bug in :meth:`set_option` where setting the pandas option ``display.html.use_mathjax`` to ``False`` has no effect (:issue:`59884`) Period ^^^^^^ From 5e9a6757488ab5444cc8f97125d7838cf1546eea Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:34:21 -0700 Subject: [PATCH 09/10] Update style_render.py Fixed error in prepending existing class in table_attr --- pandas/io/formats/style_render.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 37aff2c239381..211f7fdb7e35d 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -367,10 +367,10 @@ def _translate( table_attr = table_attr or "" if 'class="' in table_attr: table_attr = table_attr.replace( - 'class="', 'class="tex2jax_ignore mathjax_ignore"' + 'class="', 'class="tex2jax_ignore mathjax_ignore ' ) else: - table_attr += ' class="tex2jax_ignore mathjax_ignore"' + table_attr += 'class="tex2jax_ignore mathjax_ignore"' d.update({"table_attributes": table_attr}) if self.tooltips: From e9f488ee28efdf009c0f79db291b37b6767e123a Mon Sep 17 00:00:00 2001 From: Maru5er <74164821+Maru5er@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:35:15 -0800 Subject: [PATCH 10/10] updated style_render.py --- pandas/io/formats/style_render.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 211f7fdb7e35d..84503944378f1 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -367,10 +367,10 @@ def _translate( table_attr = table_attr or "" if 'class="' in table_attr: table_attr = table_attr.replace( - 'class="', 'class="tex2jax_ignore mathjax_ignore ' + 'class="', ' class="tex2jax_ignore mathjax_ignore ' ) else: - table_attr += 'class="tex2jax_ignore mathjax_ignore"' + table_attr += ' class="tex2jax_ignore mathjax_ignore"' d.update({"table_attributes": table_attr}) if self.tooltips: