Skip to content

Commit d7ddf32

Browse files
committed
Fix: Handle KeyError in StatisticalPlotStyle duration calculation
`mode()` to return an empty `Series` during duration calculation in `StatisticalPlotStyle.get_plot_styles()`. Set duration to `None` to allow plot style generation to proceed without error. Signed-off-by: cyiallou - Costas <[email protected]>
1 parent 9108ac5 commit d7ddf32

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
- Introduced `NoDataAvailableError` exception to represent situations where no data is available and to skip such cases during workflow execution and plotting.
1818
- Fixed a bug introduced in version `v0.5.2` where the microgrid tabular overview excluded current-day values from the total production for the past 30 and 365 days, causing inconsistencies with metrics that included today's data.
19+
- Fixed a crash in statistical plot style generation when the input data index is empty or contains only a single timestamp. Duration is now set to `None` when no `mode` can be determined.

src/frequenz/lib/notebooks/solar/maintenance/plot_styles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def get_plot_styles(
164164
.total_seconds()
165165
/ 60
166166
)
167+
except KeyError:
168+
duration = None # occurs when data_index is empty or has a single value
167169

168170
axes_params: dict[str, dict[str, str | int | list[str] | None]] = {
169171
"grouped": {

0 commit comments

Comments
 (0)