Skip to content

Commit

Permalink
fix: formatters for timedelta missing listargs decoration (ydataai#1526)
Browse files Browse the repository at this point in the history
* test: add test for timedelta comparison report

* fix: formatters timedelta missing decoration

* fix: remove unused import
  • Loading branch information
alexbarros authored Jan 8, 2024
1 parent 4b36db1 commit 3d4e482
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/ydata_profiling/profile_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from pathlib import Path
from typing import Any, Optional, Union

from PIL import Image

with warnings.catch_warnings():
warnings.simplefilter("ignore")
import pkg_resources
Expand Down
1 change: 1 addition & 0 deletions src/ydata_profiling/report/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def pluralize(count: Any, singular: str, plural: Optional[str] = None) -> str:
return concatenate(result)


@list_args
def fmt_timespan_timedelta(
delta: Any, detailed: bool = False, max_units: int = 3, precision: int = 10
) -> str:
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,35 @@ def test_generate_comparison():
p2 = ProfileReport(df2, title="p1")
html = p1.compare(p2).to_html()
assert len(html) > 0


def test_compare_timeseries(test_output_dir):
data = {
"feature_A": {
pd.Timestamp("2023-04-03 00:00:00"): 53321.6700520833,
pd.Timestamp("2023-04-03 01:00:00"): 53552.70312500002,
pd.Timestamp("2023-04-03 02:00:00"): 48905.89615885409,
pd.Timestamp("2023-04-03 03:00:00"): 46832.90592447904,
pd.Timestamp("2023-04-03 04:00:00"): 51819.66223958326,
}
}

df1 = pd.DataFrame.from_dict(data)
df2 = pd.DataFrame.from_dict(data)

latest_training_report = ProfileReport(
df1,
title="Report 1",
tsmode=True,
)
production_training_report = ProfileReport(
df2,
title="Report 2",
tsmode=True,
)

comparison_report = compare([latest_training_report, production_training_report])
output_file = test_output_dir / "comparison.html"
comparison_report.to_file(output_file)
assert (test_output_dir / "comparison.html").exists(), "Output file does not exist"
assert comparison_report is not None

0 comments on commit 3d4e482

Please sign in to comment.