From 98edbe0b94b8c6bb68d18f20d33af4b56b499298 Mon Sep 17 00:00:00 2001 From: AdamFinkle <77808710+AdamFinkle@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:22:38 -0500 Subject: [PATCH] Fixed errors that CI workflow caught (#285) --- python/src/rules_engine/engine.py | 25 ++++++++++--------- python/tests/test_rules_engine/test_engine.py | 8 +++--- python/tests/test_rules_engine/test_utils.py | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/python/src/rules_engine/engine.py b/python/src/rules_engine/engine.py index 1424ee15..2715412d 100644 --- a/python/src/rules_engine/engine.py +++ b/python/src/rules_engine/engine.py @@ -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 @@ -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 @@ -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 @@ -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( @@ -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] @@ -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. @@ -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( diff --git a/python/tests/test_rules_engine/test_engine.py b/python/tests/test_rules_engine/test_engine.py index cfd1723e..e4e165b9 100644 --- a/python/tests/test_rules_engine/test_engine.py +++ b/python/tests/test_rules_engine/test_engine.py @@ -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, @@ -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, diff --git a/python/tests/test_rules_engine/test_utils.py b/python/tests/test_rules_engine/test_utils.py index 08efa0b8..0eba5cc3 100644 --- a/python/tests/test_rules_engine/test_utils.py +++ b/python/tests/test_rules_engine/test_utils.py @@ -14,6 +14,7 @@ TemperatureInput, ) + # TODO: Need to be reviewed class Summary(HeatLoadInput, HeatLoadOutput): """