Skip to content

Commit

Permalink
Fixed errors that CI workflow caught (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamFinkle authored Dec 16, 2024
1 parent 790b019 commit 98edbe0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
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

0 comments on commit 98edbe0

Please sign in to comment.