From 38715bce70d4be5ed42cb86bd1e8a3ee0744cfa4 Mon Sep 17 00:00:00 2001 From: Felix Claessen <30658763+Flix6x@users.noreply.github.com> Date: Fri, 23 Jun 2023 12:15:08 +0200 Subject: [PATCH] Backport PR #743: fix: relax constraint for overlaying plot traces for sensors with various resolutions (#743) This PR makes it possible to show e.g. two price sensors in one chart, where one of them records hourly prices and the other records quarterhourly prices. * fix: relax constraint for overlaying plot traces for sensors with various resolutions Signed-off-by: F.N. Claessen * docs: changelog entry Signed-off-by: F.N. Claessen --------- Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + flexmeasures/data/models/charts/belief_charts.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 8050dfd70..f56f388d4 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -12,6 +12,7 @@ Bugfixes * Relax constraint validation of `StorageScheduler` to accommodate violations caused by floating point precision [see `PR #731 `_] * Avoid saving any :abbr:`NaN (not a number)` values to the database, when calling ``flexmeasures add report`` [see `PR #735 `_] * Fix browser console error when loading asset or sensor page with only a single data point [see `PR #732 `_] +* Relax constraint for overlaying plot traces for sensors with various resolutions, making it possible to show e.g. two price sensors in one chart, where one of them records hourly prices and the other records quarter-hourly prices [see `PR #743 `_] v0.14.0 | June 15, 2023 diff --git a/flexmeasures/data/models/charts/belief_charts.py b/flexmeasures/data/models/charts/belief_charts.py index 09782470e..7baab4757 100644 --- a/flexmeasures/data/models/charts/belief_charts.py +++ b/flexmeasures/data/models/charts/belief_charts.py @@ -271,9 +271,9 @@ def create_line_layer( event_value_field_definition: dict, ): event_resolutions = list(set([sensor.event_resolution for sensor in sensors])) - assert ( - len(event_resolutions) == 1 - ), "Sensors shown within one row must share the same event resolution." + assert all(res == timedelta(0) for res in event_resolutions) or all( + res != timedelta(0) for res in event_resolutions + ), "Sensors shown within one row must all be instantaneous (zero event resolution) or all be non-instantatneous (non-zero event resolution)." event_resolution = event_resolutions[0] line_layer = { "mark": {