-
Notifications
You must be signed in to change notification settings - Fork 17
Fix succeeded_power
calculation in PV power distribution
#1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This was reported incorrectly earlier using a variable that was never set. That variable and related (unused) channels have been removed. This also updates the PV pool tests to ensure that the distribution results are accurate. Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an incorrect calculation of succeeded_power during PV power distribution and removes unused variables/channels.
- Updates the succeeded_power logic in the PV inverter manager to subtract both failed and remaining power.
- Adjusts test assertions and expected values in the PV pool tests to reflect the new calculation.
- Revises release notes to document the correction.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/timeseries/_pv_pool/test_pv_pool_control_methods.py | Updated test assertions and expected values to match the new succeeded_power calculation. |
src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_pv_inverter_manager/_pv_inverter_manager.py | Revised succeeded_power calculation by switching from self._target_power to request.power and adjusting for remaining power. |
RELEASE_NOTES.md | Updated release notes to accurately document the bug fix and expected behavior. |
Comments suppressed due to low confidence (1)
tests/timeseries/_pv_pool/test_pv_pool_control_methods.py:303
- [nitpick] Consider adding additional tests to cover edge cases where the request.power significantly deviates from component defaults, ensuring comprehensive coverage of the new succeeded_power logic.
await pv_pool.propose_power(Power.from_watts(-200000.0))
@@ -241,7 +238,7 @@ async def _set_api_power( # pylint: disable=too-many-locals | |||
failed_components=failed_components, | |||
succeeded_components=succeeded_components, | |||
failed_power=failed_power, | |||
succeeded_power=self._target_power - failed_power, | |||
succeeded_power=request.power - failed_power - remaining_power, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding a brief comment or updating the docstring here to clarify why the succeeded_power is calculated as request.power minus both the failed_power and remaining_power.
Copilot uses AI. Check for mistakes.
@@ -250,7 +247,7 @@ async def _set_api_power( # pylint: disable=too-many-locals | |||
await self._results_sender.send( | |||
Success( | |||
succeeded_components=succeeded_components, | |||
succeeded_power=self._target_power, | |||
succeeded_power=request.power - remaining_power, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] A comment explaining why the succeeded_power calculation in this branch excludes failed_power (compared to the previous branch) would improve maintainability and clarity.
Copilot uses AI. Check for mistakes.
This was reported incorrectly earlier using a variable that was never
set. That variable and related (unused) channels have been removed.
This also updates the PV pool tests to ensure that the distribution
results are accurate.