Skip to content

Commit

Permalink
fix: ignoring config of precomputed reports
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarros authored and aquemy committed Dec 21, 2022
1 parent 3d60556 commit 6478c40
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/pandas_profiling/compare_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas as pd

from pandas_profiling.config import Settings
from pandas_profiling.config import Correlation, Settings
from pandas_profiling.profile_report import ProfileReport


Expand Down Expand Up @@ -184,6 +184,42 @@ def validate_reports(
)


def _apply_config(description: dict, config: Settings) -> dict:
"""Apply the configuration for visualilzation purposes.
This handles the cases in which the report description
was computed prior to comparison with a different config
Args:
description: report summary
config: the settings object for the ProfileReport
Returns:
the updated description
"""
description["missing"] = {
k: v for k, v in description["missing"].items() if config.missing_diagrams[k]
}

description["correlations"] = {
k: v
for k, v in description["correlations"].items()
if config.correlations.get(k, Correlation(calculate=False).calculate)
}

samples = [config.samples.head, config.samples.tail, config.samples.random]
samples = [s > 0 for s in samples]
description["sample"] = description["sample"] if any(samples) else []
description["duplicates"] = (
description["duplicates"] if config.duplicates.head > 0 else [None, None]
)
description["scatter"] = (
description["scatter"] if config.interactions.continuous else {}
)

return description


def compare(
reports: List[ProfileReport],
config: Optional[Settings] = None,
Expand All @@ -207,7 +243,7 @@ def compare(
return reports[0]

if config is None:
_config = Settings()
_config = Settings()
else:
_config = config.copy()
for report in reports:
Expand Down Expand Up @@ -236,5 +272,5 @@ def compare(
res["analysis"]["title"] = _compare_title(res["analysis"]["title"])

profile = ProfileReport(None, config=_config)
profile._description_set = res
profile._description_set = _apply_config(res, _config)
return profile

0 comments on commit 6478c40

Please sign in to comment.