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

Fixed errors that CI workflow caught #285

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions python/src/rules_engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ def convert_to_intermediate_processed_energy_bills(
default_inclusion=default_inclusion,
inclusion_override=processed_energy_bill_input.inclusion_override,
)
intermediate_processed_energy_bill_inputs.append(
intermediate_energy_bill
)
intermediate_processed_energy_bill_inputs.append(intermediate_energy_bill)

return intermediate_processed_energy_bill_inputs

Expand Down Expand Up @@ -489,7 +487,9 @@ def _calculate_avg_summer_usage(self) -> None:
"""
Calculate average daily summer usage
"""
summer_usage_total = sum([bp.usage for bp in self.summer_processed_energy_bills])
summer_usage_total = sum(
[bp.usage for bp in self.summer_processed_energy_bills]
)
summer_days = sum([bp.days for bp in self.summer_processed_energy_bills])
if summer_days != 0:
self.avg_summer_usage = summer_usage_total / summer_days
Expand Down Expand Up @@ -517,7 +517,7 @@ def _calculate_balance_point_and_ua(
stdev_pct_max: float = 0.10,
max_stdev_pct_diff: float = 0.01,
next_balance_point_sensitivity: float = 0.5,
) -> any:
) -> None:
"""
Calculates the estimated balance point and UA coefficient for
the home, removing UA outliers based on a normalized standard
Expand Down Expand Up @@ -546,7 +546,10 @@ def _calculate_balance_point_and_ua(
self._refine_balance_point(initial_balance_point_sensitivity)

while self.stdev_pct > stdev_pct_max:
outliers = [abs(bill.ua - self.avg_ua) for bill in self.winter_processed_energy_bills]
outliers = [
abs(bill.ua - self.avg_ua)
for bill in self.winter_processed_energy_bills
]
biggest_outlier = max(outliers)
biggest_outlier_idx = outliers.index(biggest_outlier)
outlier = self.winter_processed_energy_bills.pop(
Expand Down Expand Up @@ -592,7 +595,8 @@ def _refine_balance_point(self, balance_point_sensitivity: float) -> None:
break # may want to raise some kind of warning as well

period_hdds_i = [
period_hdd(bill.avg_temps, bp_i) for bill in self.winter_processed_energy_bills
period_hdd(bill.avg_temps, bp_i)
for bill in self.winter_processed_energy_bills
]
uas_i = [
bill.partial_ua / period_hdds_i[n]
Expand Down Expand Up @@ -672,9 +676,7 @@ def calculate(

return home_instance

def initialize_ua(
self, intermediate_energy_bill: IntermediateEnergyBill
) -> None:
def initialize_ua(self, intermediate_energy_bill: IntermediateEnergyBill) -> None:
"""
Average heating usage, partial UA, initial UA. requires that
self.home have non heating usage calculated.
Expand All @@ -686,8 +688,7 @@ def initialize_ua(
intermediate_energy_bill
)
intermediate_energy_bill.ua = (
intermediate_energy_bill.partial_ua
/ intermediate_energy_bill.total_hdd
intermediate_energy_bill.partial_ua / intermediate_energy_bill.total_hdd
)

def calculate_partial_ua(
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_rules_engine/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@


@pytest.fixture()
def sample_intermediate_energy_bill_inputs() -> (
list[engine.IntermediateEnergyBill]
):
def sample_intermediate_energy_bill_inputs() -> list[engine.IntermediateEnergyBill]:
intermediate_energy_bill_inputs = [
engine.IntermediateEnergyBill(
_dummy_processed_energy_bill_input,
Expand Down Expand Up @@ -316,7 +314,9 @@ def test_get_average_indoor_temperature():
assert engine.get_average_indoor_temperature(set_temp, setback, setback_hrs) == 66


def test_bp_ua_estimates(sample_heat_load_inputs, sample_intermediate_energy_bill_inputs):
def test_bp_ua_estimates(
sample_heat_load_inputs, sample_intermediate_energy_bill_inputs
):
home = engine.Home.calculate(
sample_heat_load_inputs,
sample_intermediate_energy_bill_inputs,
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_rules_engine/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
TemperatureInput,
)


# TODO: Need to be reviewed
class Summary(HeatLoadInput, HeatLoadOutput):
"""
Expand Down
Loading