Skip to content

Fix chart interpolation for rows mixing real sensors with flex-config constants - #2356

Open
sankalpsthakur wants to merge 1 commit into
FlexMeasures:mainfrom
sankalpsthakur:fix/2253-constant-sensor-interpolation
Open

Fix chart interpolation for rows mixing real sensors with flex-config constants#2356
sankalpsthakur wants to merge 1 commit into
FlexMeasures:mainfrom
sankalpsthakur:fix/2253-constant-sensor-interpolation

Conversation

@sankalpsthakur

Copy link
Copy Markdown
Contributor

Description

  • Fix create_line_layer in flexmeasures/data/models/charts/belief_charts.py so that a chart row's interpolation mode (linear vs step-after) is decided only by the real sensors in that row, not by fixed-value/constant sensors sourced from flex-model / flex-context (e.g. soc-min, soc-max, capacities). Fixed-value sensors always report event_resolution == timedelta(0) by construction (they're synthetic, not backed by timed data), so a row mixing a real, non-instantaneous sensor with any such constant was incorrectly forced to linear interpolation instead of the correct step-after.
  • Added changelog item in documentation/changelog.rst

Look & Feel

No screenshot from this environment — the change affects the Vega-Lite mark.interpolate value driving line rendering (straight-line "linear" vs staircase "step-after"), which is exactly what the two new regression tests assert on directly. The original bug report's before/after screenshots show a real (should be step-after) sensor's line rendering as smoothly interpolated/linear whenever it shares a row with a flex-model/flex-context constant.

How to test

Run the two new tests in flexmeasures/data/tests/test_belief_charts.py:

pytest flexmeasures/data/tests/test_belief_charts.py -k "test_mixed_row_with_fixed_value_sensor_keeps_step_after or test_real_instantaneous_sensor_still_uses_linear" -q
  • test_mixed_row_with_fixed_value_sensor_keeps_step_after is the regression case: a real 15-min-resolution sensor sharing a row with a soc-min fixed-value constant must produce step-after. Fails on main (asserts linear == step-afterAssertionError), passes with this fix.
  • test_real_instantaneous_sensor_still_uses_linear is a guard case proving a real instantaneous sensor alone still correctly gets linear.

Full file for no-regression check: pytest flexmeasures/data/tests/test_belief_charts.py -q (33 passed).

Further Improvements

None identified — this is a targeted fix to the interpolation-selection predicate.

Related Items

Fixes #2253


AI/LLM disclosure

  • AI coding tools (Claude Code, Anthropic) were used to help draft/modify this code, test, changelog entry, and this PR description.
  • I reviewed the complete change, understand the reasoning, and ran the reported local tests before submitting.
  • This submission is original work of authorship under the project CLA / contributor terms; AI output was not pasted unreviewed.

Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

@sankalpsthakur
sankalpsthakur force-pushed the fix/2253-constant-sensor-interpolation branch from 9aa7117 to 0a72506 Compare July 25, 2026 09:54
@sankalpsthakur
sankalpsthakur force-pushed the fix/2253-constant-sensor-interpolation branch from 0a72506 to eb7bdbd Compare July 28, 2026 10:14
…rs with flex-config constants

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
@sankalpsthakur
sankalpsthakur force-pushed the fix/2253-constant-sensor-interpolation branch from eb7bdbd to 0ae1fec Compare July 30, 2026 09:02
@Ahmad-Wahid

Copy link
Copy Markdown
Contributor

@sankalpsthakur could you share some screenshots after the fixes?

@sankalpsthakur

Copy link
Copy Markdown
Contributor Author

attached before/after — rendered straight from create_line_layer's real mark.interpolate output (linear vs step-after) using the same setup as the regression test's battery_with_interval_sensor_and_soc_min fixture, with representative sample values standing in for a live sensor since standing up a seeded deployment wasn't practical here.

before (main): soc-min forces the whole row to linear
before

after (this PR): real 15-min sensor correctly keeps step-after
after

@nhoening
nhoening requested a review from Ahmad-Wahid August 6, 2026 13:49
@nhoening nhoening added this to the 1.1.0 milestone Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI shows non-instantaneous data as instantaneous data when shown together with a flex-config constant

3 participants