From 74327aad4a39f2c70b5cf0957d55fc894c6eec7a Mon Sep 17 00:00:00 2001 From: Fabiana <30911746+fabclmnt@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:55:04 -0700 Subject: [PATCH 1/7] fix: add html metrics support for compare --- .../report/presentation/core/scores.py | 5 +- .../flavours/html/templates/scores.html | 70 ++++++++++++++----- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/ydata_profiling/report/presentation/core/scores.py b/src/ydata_profiling/report/presentation/core/scores.py index 62b001bff..6a962fca8 100644 --- a/src/ydata_profiling/report/presentation/core/scores.py +++ b/src/ydata_profiling/report/presentation/core/scores.py @@ -3,6 +3,7 @@ """ from typing import Any, Dict, List, Optional +from ydata_profiling.config import Style from ydata_profiling.report.presentation.core.item_renderer import ItemRenderer @@ -11,15 +12,15 @@ def __init__( self, items: List[Dict], overall_score: float, + style: Style, name: Optional[str], - caption: Optional[str], **kwargs ): content = { "items": items, "overall_score": overall_score, "name": name, - "caption": caption, + "style": style } super().__init__("scores", content=content, **kwargs) diff --git a/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html b/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html index f0bf8e895..90ad82cda 100644 --- a/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html +++ b/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html @@ -1,44 +1,78 @@
-
-
Overall Data Quality Score
-
{{ overall_score }}
-
+
+
Overall Data Quality Score
+
+ {% for i in range(overall_score | length) %} +
+ {% if overall_score | length > 1 %} +
{{ name[i]}}
+ {% endif %} +
{{ overall_score[i]}}
+
+ {% endfor %} +
+
-
+
{% for metric in items %}
-
-
{{ metric.name }}
-
-
+
+
{{ metric.name }}
+ {% for j in range(metric.submetrics| length) %} + {% if metric.submetrics | length > 1 %} +
{{ name[j] }}
+ {% endif %} +
+
+ {{ metric.submetrics[j].value }}% +
-
-
{{ metric.value }}%
+ {% endfor %}
{% endfor %}
+ + From 91fda2a3cdf7f4be78f674f78a5ffb9b5473d8d7 Mon Sep 17 00:00:00 2001 From: Fabiana <30911746+fabclmnt@users.noreply.github.com> Date: Tue, 25 Mar 2025 10:55:04 -0700 Subject: [PATCH 2/7] fix: add html metrics support for compare --- .../report/presentation/core/scores.py | 5 +- .../flavours/html/templates/scores.html | 70 ++++++++++++++----- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/ydata_profiling/report/presentation/core/scores.py b/src/ydata_profiling/report/presentation/core/scores.py index 62b001bff..6a962fca8 100644 --- a/src/ydata_profiling/report/presentation/core/scores.py +++ b/src/ydata_profiling/report/presentation/core/scores.py @@ -3,6 +3,7 @@ """ from typing import Any, Dict, List, Optional +from ydata_profiling.config import Style from ydata_profiling.report.presentation.core.item_renderer import ItemRenderer @@ -11,15 +12,15 @@ def __init__( self, items: List[Dict], overall_score: float, + style: Style, name: Optional[str], - caption: Optional[str], **kwargs ): content = { "items": items, "overall_score": overall_score, "name": name, - "caption": caption, + "style": style } super().__init__("scores", content=content, **kwargs) diff --git a/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html b/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html index f0bf8e895..90ad82cda 100644 --- a/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html +++ b/src/ydata_profiling/report/presentation/flavours/html/templates/scores.html @@ -1,44 +1,78 @@
-
-
Overall Data Quality Score
-
{{ overall_score }}
-
+
+
Overall Data Quality Score
+
+ {% for i in range(overall_score | length) %} +
+ {% if overall_score | length > 1 %} +
{{ name[i]}}
+ {% endif %} +
{{ overall_score[i]}}
+
+ {% endfor %} +
+
-
+
{% for metric in items %}
-
-
{{ metric.name }}
-
-
+
+
{{ metric.name }}
+ {% for j in range(metric.submetrics| length) %} + {% if metric.submetrics | length > 1 %} +
{{ name[j] }}
+ {% endif %} +
+
+ {{ metric.submetrics[j].value }}% +
-
-
{{ metric.value }}%
+ {% endfor %}
{% endfor %}
+ + From 5eebf21b73bf18992b546665d837704cce12c026 Mon Sep 17 00:00:00 2001 From: Azory YData Bot Date: Tue, 25 Mar 2025 20:28:44 +0000 Subject: [PATCH 3/7] fix(linting): code formatting --- src/ydata_profiling/report/presentation/core/scores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ydata_profiling/report/presentation/core/scores.py b/src/ydata_profiling/report/presentation/core/scores.py index 6a962fca8..7ff70570a 100644 --- a/src/ydata_profiling/report/presentation/core/scores.py +++ b/src/ydata_profiling/report/presentation/core/scores.py @@ -20,7 +20,7 @@ def __init__( "items": items, "overall_score": overall_score, "name": name, - "style": style + "style": style, } super().__init__("scores", content=content, **kwargs) From 21dba167d64533e72928cfaed515126be7284612 Mon Sep 17 00:00:00 2001 From: Fabiana <30911746+fabclmnt@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:56:01 -0700 Subject: [PATCH 4/7] chore: fix test to include request header --- tests/issues/test_issue537.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/issues/test_issue537.py b/tests/issues/test_issue537.py index 7248a3ac8..a8ec067a4 100644 --- a/tests/issues/test_issue537.py +++ b/tests/issues/test_issue537.py @@ -34,7 +34,14 @@ def test_multiprocessing_describe1d(config, summarizer, typeset): def download_and_process_data(): """Downloads and processes the dataset into a Pandas DataFrame.""" - response = requests.get("https://ndownloader.figshare.com/files/5976042") + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/122.0.0.0 Safari/537.36" + } + response = requests.get("https://ndownloader.figshare.com/files/5976042", + headers=headers) + response.raise_for_status() # Ensure successful download file = decompress(response.content) From 98c8de22efd623d5d727be0856caf7e27dc1e160 Mon Sep 17 00:00:00 2001 From: Azory YData Bot Date: Tue, 25 Mar 2025 21:59:29 +0000 Subject: [PATCH 5/7] fix(linting): code formatting --- tests/issues/test_issue537.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/issues/test_issue537.py b/tests/issues/test_issue537.py index a8ec067a4..f0a2c9f0a 100644 --- a/tests/issues/test_issue537.py +++ b/tests/issues/test_issue537.py @@ -36,11 +36,12 @@ def download_and_process_data(): """Downloads and processes the dataset into a Pandas DataFrame.""" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " - "AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/122.0.0.0 Safari/537.36" + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/122.0.0.0 Safari/537.36" } - response = requests.get("https://ndownloader.figshare.com/files/5976042", - headers=headers) + response = requests.get( + "https://ndownloader.figshare.com/files/5976042", headers=headers + ) response.raise_for_status() # Ensure successful download From 781215e9915886293bec5d584e86a0f2128b29fa Mon Sep 17 00:00:00 2001 From: Fabiana <30911746+fabclmnt@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:49:41 -0700 Subject: [PATCH 6/7] chore: add unit tests for the compat file --- tests/unit/test_pandas/test_compat.py | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/unit/test_pandas/test_compat.py diff --git a/tests/unit/test_pandas/test_compat.py b/tests/unit/test_pandas/test_compat.py new file mode 100644 index 000000000..d0e0c6848 --- /dev/null +++ b/tests/unit/test_pandas/test_compat.py @@ -0,0 +1,43 @@ +import unittest +import pandas as pd +from ydata_profiling.utils.compat import optional_option_context, pandas_version_info + + +class TestCompatUtils(unittest.TestCase): + + def test_pandas_version_info_format(self): + version_info = pandas_version_info() + self.assertIsInstance(version_info, tuple) + self.assertTrue(all(isinstance(i, int) for i in version_info)) + + expected_prefix = tuple(int(x) for x in pd.__version__.split(".")[: len(version_info)]) + self.assertEqual(version_info, expected_prefix) + + def test_optional_option_context_with_existing_option(self): + option = "display.max_rows" + original_value = pd.get_option(option) + + with optional_option_context(option, 123): + self.assertEqual(pd.get_option(option), 123) + + self.assertEqual(pd.get_option(option), original_value) + + def test_optional_option_context_with_missing_option(self): + class FakeOptionContext: + def __init__(self, *args, **kwargs): + raise pd.errors.OptionError("Simulated OptionError") + + original_option_context = pd.option_context + pd.option_context = FakeOptionContext + + try: + # Should not raise, even though the option is invalid + with optional_option_context("non.existent.option", 456): + pass + finally: + # Restore the original option_context + pd.option_context = original_option_context + + +if __name__ == "__main__": + unittest.main() From 54bb88275214d800815564d8aa879c7efac96298 Mon Sep 17 00:00:00 2001 From: Azory YData Bot Date: Tue, 25 Mar 2025 22:52:43 +0000 Subject: [PATCH 7/7] fix(linting): code formatting --- tests/unit/test_pandas/test_compat.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_pandas/test_compat.py b/tests/unit/test_pandas/test_compat.py index d0e0c6848..b0dd94d39 100644 --- a/tests/unit/test_pandas/test_compat.py +++ b/tests/unit/test_pandas/test_compat.py @@ -1,16 +1,19 @@ import unittest + import pandas as pd + from ydata_profiling.utils.compat import optional_option_context, pandas_version_info class TestCompatUtils(unittest.TestCase): - def test_pandas_version_info_format(self): version_info = pandas_version_info() self.assertIsInstance(version_info, tuple) self.assertTrue(all(isinstance(i, int) for i in version_info)) - expected_prefix = tuple(int(x) for x in pd.__version__.split(".")[: len(version_info)]) + expected_prefix = tuple( + int(x) for x in pd.__version__.split(".")[: len(version_info)] + ) self.assertEqual(version_info, expected_prefix) def test_optional_option_context_with_existing_option(self):