Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
NormannK committed Jan 13, 2025
1 parent 86d5f6b commit 3811caa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/akkudoktoreos/utils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


class VisualizationReport(ConfigMixin):
def __init__(self, filename: str = "visualization_results.pdf") -> None:
def __init__(self, filename: str = "visualization_results.pdf", version: str = "0.0.1") -> None:
# Initialize the report with a given filename and empty groups
self.filename = filename
self.groups: list[list[Callable[[], None]]] = [] # Store groups of charts
self.current_group: list[
Callable[[], None]
] = [] # Store current group of charts being created
self.pdf_pages = PdfPages(filename, metadata={}) # Initialize PdfPages without metadata
self.version = "0.0.1"
self.version = version # overwrite version as test for constant output of pdf for test

def add_chart_to_group(self, chart_func: Callable[[], None]) -> None:
"""Add a chart function to the current group."""
Expand Down Expand Up @@ -86,7 +86,10 @@ def _save_group_to_pdf(self, group: list[Callable[[], None]]) -> None:
axs = list(np.array(axs).reshape(-1))

# Add footer text with current time to each page
current_time = to_datetime(as_string="YYYY-MM-DD HH:mm:ss")
if self.version == "test":
current_time = "test"
else:
current_time = to_datetime(as_string="YYYY-MM-DD HH:mm:ss")
fig.text(
0.5,
0.02,
Expand Down Expand Up @@ -615,7 +618,7 @@ def prepare_visualize(

def generate_example_report(filename: str = "example_report.pdf") -> None:
"""Generate example visualization report."""
report = VisualizationReport(filename)
report = VisualizationReport(filename, "test")
x_hours = 0 # Define x-axis start values (e.g., hours)

# Group 1: Adding charts to be displayed on the same page
Expand Down
Binary file modified tests/testdata/test_example_report.pdf
Binary file not shown.

0 comments on commit 3811caa

Please sign in to comment.