Test cleanup#3953
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the soc_kw-based test data generation to better support find_battery_size() calibration and refactors Inverter.find_battery_size() to parse SOC history via minute_data() (including deriving SOC% from soc_kw history).
Changes:
- Updated
test_find_battery_sizesoc_kw history generation so charge windows reach a full charge at least once (improvingsoc_maxinference). - Refactored
Inverter.find_battery_size()to parsesoc_percent/soc_kwhistory into minute-indexed dicts and compute SOC% consistently before estimation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/predbat/tests/test_find_battery_size.py | Tweaks soc_kw mock history generation to ensure a full charge is observed and clarifies intent in comments. |
| apps/predbat/inverter.py | Refactors find_battery_size() history parsing, including deriving SOC% from soc_kw history using minute_data(). |
Comment on lines
+713
to
+725
| soc_kw_minute, _ = minute_data( | ||
| soc_kw_data[0], | ||
| self.base.max_days_previous, | ||
| self.base.now_utc, | ||
| "state", | ||
| "last_updated", | ||
| backwards=True, | ||
| clean_increment=False, | ||
| smoothing=False, | ||
| divide_by=1.0, | ||
| scale=1.0, | ||
| required_unit="kWh", | ||
| ) |
Comment on lines
135
to
+139
| else: | ||
| battery_power = 0 | ||
| if hour == 1 or hour == 17: | ||
| current_soc_kwh = battery_size_kwh * 0.20 | ||
| # Reset to near-empty before each charge session | ||
| if hour == 17: | ||
| current_soc_kwh = battery_size_kwh * 0.05 |
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.
No description provided.