Conversation
Since davidusb-geek#1032 a result frame with number_of_batteries above 1 carries SOC_opt_<k> per battery and no bare SOC_opt, so get_injection_dict found no SOC column and the web UI showed no SOC chart at all. Collect SOC_opt and every SOC_opt_<k> column and plot them on the one figure, with the palette sized to the SOC traces instead of borrowing the one sized for the power columns. One battery renders exactly as before.
Contributor
Reviewer's GuideRestores the web UI SOC chart for multi-battery result frames by discovering valid per-battery SOC columns, plotting each as a trace, and assigning a palette sized to the trace count while preserving single-battery behavior. New tests cover column filtering, chart generation, trace output, and distinct colors. Flow diagram for SOC column discovery and plottingflowchart TD
A[get_injection_dict] --> B[Filter dataframe columns]
B --> C{Valid SOC columns found?}
C -->|No| D[No SOC figure]
C -->|Yes| E[Build palette sized to SOC traces]
E --> F[Plot each SOC column as a trace]
F --> G[Render Battery SOC figure]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Since #1032, a result frame with
number_of_batteriesabove 1 carriesSOC_opt_<k>per battery and no bareSOC_optcolumn.get_injection_dictonly looked for the bare column, so the web UI showed no SOC chart at all for multi-battery users. Powers and costs were still plotted, the SOC figure was simply missing.The fix
get_injection_dictnow collectsSOC_optand everySOC_opt_<k>column and plots them on the one SOC figure, one trace per battery. With one battery the same single column is plotted as before, same trace name, legend and colour. The column filter is exact (SOC_opt, orSOC_opt_followed by digits), so nothing else that happens to start withSOC_optis picked up.The SOC figure used to borrow the palette sized for the power figure, which was harmless with one trace. With two batteries and a typical 9 to 16 power columns, both SOC traces would land on the first two samples of the jet ramp, two dark blues you can't tell apart. The palette is now sized to the SOC traces, the same way the thermal figure already does it. With one battery that is the same colour as before.
Not touched: the y-axis label says "Battery SOC (%)" while the column is a fraction, which predates this change.
Tests
Four new tests in
tests/test_utils.py: one battery still gets the SOC figure, two batteries get the figure with both traces, the two traces get the two ends of the colour ramp, and a frame with no SOC column (plus a decoy column) gets no SOC figure. The two-battery test was proven to fail on the current master.Context: this is one of the two small fixes I said I'd send in #1150 ahead of the multi-inverter work, which adds more per-device columns to the same chart.
Summary by Sourcery
Restore battery state-of-charge charting for multi-battery optimization results while preserving single-battery behavior.
Bug Fixes:
Enhancements:
Tests: