Skip to content
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

Feature/gsye 636 #477

Merged
merged 5 commits into from
Oct 16, 2023
Merged

Feature/gsye 636 #477

merged 5 commits into from
Oct 16, 2023

Conversation

spyrostz
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #477 (e98e43f) into master (a7733c6) will increase coverage by 0.45%.
Report is 1 commits behind head on master.
The diff coverage is 76.00%.

❗ Current head e98e43f differs from pull request most recent head 52c8e47. Consider uploading reports for the commit 52c8e47 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #477      +/-   ##
==========================================
+ Coverage   65.95%   66.40%   +0.45%     
==========================================
  Files          78       78              
  Lines        5128     5144      +16     
  Branches      848      851       +3     
==========================================
+ Hits         3382     3416      +34     
+ Misses       1589     1566      -23     
- Partials      157      162       +5     

…alidator. Corrected temperature and price validations.
Comment on lines 475 to 478
def convert_kWh_to_W(energy_kWh, slot_length):
"""Convert W power into energy in Wh (based on the duration of the market slot)."""
energy_Wh = energy_kWh * 1000.0
return energy_Wh / (slot_length / duration(hours=1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which unit or type has the slot_length ? From the code, I see that it should be pendulum.duration, right?
If so, I propose

Suggested change
def convert_kWh_to_W(energy_kWh, slot_length):
"""Convert W power into energy in Wh (based on the duration of the market slot)."""
energy_Wh = energy_kWh * 1000.0
return energy_Wh / (slot_length / duration(hours=1))
def convert_kWh_to_W(energy_kWh: float, slot_length: duration) -> float:
"""Convert W power into energy in Wh (based on the duration of the market slot)."""
energy_Wh = energy_kWh * 1000.0
return energy_Wh / slot_length.total_hours()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the type hints, however did not follow the total_hours suggestion, in order to be more evident on how the kWh -> W conversion is done here. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to simplify the (slot_length / duration(hours=1)).
IMO we could use the features pendulum comes with.
But if you do not like this, I am convinced to leave it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct from a software developer perspective, however it is hiding the actual calculation of the units, which we want to indicate that this is the opposite of the kW -> kWh calculation. We could of course change all these methods to use the total_hours() pendulum call, however it hides the conversion from the reader of the code IMO, and will not be clear on how this calculation is done.

@@ -186,7 +186,7 @@ class HeatPumpSettings:
"""Default values for the heat pump."""
# range limits
MAX_POWER_RATING_KW_LIMIT = RangeLimit(0, sys.maxsize)
TEMP_C_LIMIT = RangeLimit(-273.15, 6000)
TEMP_C_LIMIT = RangeLimit(0.0, 200.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-D
Finally somebody reacted to my easter egg.


if not min_temp_c <= max_temp_c:
if not min_temp_c <= initial_temp_c <= max_temp_c:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great! Thank you!

@@ -78,8 +84,8 @@ def validate_rate(cls, **kwargs):
for buying_rate_arg_name in buying_rate_arg_names:
cls._check_range(
name=buying_rate_arg_name, value=kwargs[buying_rate_arg_name],
min_value=HeatPumpSettings.TEMP_C_LIMIT.min,
max_value=HeatPumpSettings.TEMP_C_LIMIT.max)
min_value=HeatPumpSettings.BUYING_RATE_LIMIT.initial,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upsi

hannesdiedrich
hannesdiedrich previously approved these changes Oct 11, 2023
Copy link
Member

@hannesdiedrich hannesdiedrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only jabbering comments. LGTM

Copy link
Member

@hannesdiedrich hannesdiedrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@hannesdiedrich hannesdiedrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@spyrostz spyrostz merged commit a77bc00 into master Oct 16, 2023
@spyrostz spyrostz deleted the feature/GSYE-636 branch October 16, 2023 13:29
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.

2 participants